2 * windows.c: Windows front end for my puzzle collection.
16 #define IDM_NEW 0x0010
17 #define IDM_RESTART 0x0020
18 #define IDM_UNDO 0x0030
19 #define IDM_REDO 0x0040
20 #define IDM_QUIT 0x0050
21 #define IDM_CONFIG 0x0060
22 #define IDM_PRESETS 0x0100
25 static FILE *debug_fp = NULL;
26 static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
27 static int debug_got_console = 0;
33 if (!debug_got_console) {
35 debug_got_console = 1;
36 debug_hdl = GetStdHandle(STD_OUTPUT_HANDLE);
40 debug_fp = fopen("debug.log", "w");
43 if (debug_hdl != INVALID_HANDLE_VALUE) {
44 WriteFile(debug_hdl, buf, strlen(buf), &dw, NULL);
50 void debug_printf(char *fmt, ...)
56 vsprintf(buf, fmt, ap);
61 #define debug(x) (debug_printf x)
81 HWND hwnd, statusbar, cfgbox;
83 HBITMAP bitmap, prevbm;
91 game_params **presets;
95 struct cfg_aux *cfgaux;
100 void fatal(char *fmt, ...)
106 vsprintf(buf, fmt, ap);
109 MessageBox(NULL, buf, "Fatal error", MB_ICONEXCLAMATION | MB_OK);
114 void status_bar(frontend *fe, char *text)
116 SetWindowText(fe->statusbar, text);
119 void frontend_default_colour(frontend *fe, float *output)
121 DWORD c = GetSysColor(COLOR_MENU); /* ick */
123 output[0] = (float)(GetRValue(c) / 255.0);
124 output[1] = (float)(GetGValue(c) / 255.0);
125 output[2] = (float)(GetBValue(c) / 255.0);
128 void clip(frontend *fe, int x, int y, int w, int h)
131 fe->clip = CreateRectRgn(0, 0, 1, 1);
132 GetClipRgn(fe->hdc_bm, fe->clip);
135 IntersectClipRect(fe->hdc_bm, x, y, x+w, y+h);
138 void unclip(frontend *fe)
141 SelectClipRgn(fe->hdc_bm, fe->clip);
144 void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
145 int align, int colour, char *text)
150 * Find or create the font.
152 for (i = 0; i < fe->nfonts; i++)
153 if (fe->fonts[i].type == fonttype && fe->fonts[i].size == fontsize)
156 if (i == fe->nfonts) {
157 if (fe->fontsize <= fe->nfonts) {
158 fe->fontsize = fe->nfonts + 10;
159 fe->fonts = sresize(fe->fonts, fe->fontsize, struct font);
164 fe->fonts[i].type = fonttype;
165 fe->fonts[i].size = fontsize;
168 * FIXME: Really I should make at least _some_ effort to
169 * pick the correct font.
171 fe->fonts[i].font = CreateFont(-fontsize, 0, 0, 0, 0,
172 FALSE, FALSE, FALSE, DEFAULT_CHARSET,
173 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
175 (fonttype == FONT_FIXED ?
176 FIXED_PITCH | FF_DONTCARE :
177 VARIABLE_PITCH | FF_SWISS),
182 * Position and draw the text.
189 oldfont = SelectObject(fe->hdc_bm, fe->fonts[i].font);
190 if (GetTextMetrics(fe->hdc_bm, &tm)) {
191 if (align & ALIGN_VCENTRE)
192 y -= (tm.tmAscent+tm.tmDescent)/2;
196 if (GetTextExtentPoint32(fe->hdc_bm, text, strlen(text), &size)) {
197 if (align & ALIGN_HCENTRE)
199 else if (align & ALIGN_HRIGHT)
202 SetBkMode(fe->hdc_bm, TRANSPARENT);
203 TextOut(fe->hdc_bm, x, y, text, strlen(text));
204 SelectObject(fe->hdc_bm, oldfont);
208 void draw_rect(frontend *fe, int x, int y, int w, int h, int colour)
210 if (w == 1 && h == 1) {
212 * Rectangle() appears to get uppity if asked to draw a 1x1
213 * rectangle, presumably on the grounds that that's beneath
214 * its dignity and you ought to be using SetPixel instead.
217 SetPixel(fe->hdc_bm, x, y, fe->colours[colour]);
219 HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
220 HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
221 Rectangle(fe->hdc_bm, x, y, x+w, y+h);
222 SelectObject(fe->hdc_bm, oldbrush);
223 SelectObject(fe->hdc_bm, oldpen);
227 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
229 HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
230 MoveToEx(fe->hdc_bm, x1, y1, NULL);
231 LineTo(fe->hdc_bm, x2, y2);
232 SetPixel(fe->hdc_bm, x2, y2, fe->colours[colour]);
233 SelectObject(fe->hdc_bm, oldpen);
236 void draw_polygon(frontend *fe, int *coords, int npoints,
237 int fill, int colour)
239 POINT *pts = snewn(npoints+1, POINT);
242 for (i = 0; i <= npoints; i++) {
243 int j = (i < npoints ? i : 0);
244 pts[i].x = coords[j*2];
245 pts[i].y = coords[j*2+1];
249 HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
250 HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
251 Polygon(fe->hdc_bm, pts, npoints);
252 SelectObject(fe->hdc_bm, oldbrush);
253 SelectObject(fe->hdc_bm, oldpen);
255 HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
256 Polyline(fe->hdc_bm, pts, npoints+1);
257 SelectObject(fe->hdc_bm, oldpen);
263 void start_draw(frontend *fe)
266 hdc_win = GetDC(fe->hwnd);
267 fe->hdc_bm = CreateCompatibleDC(hdc_win);
268 fe->prevbm = SelectObject(fe->hdc_bm, fe->bitmap);
269 ReleaseDC(fe->hwnd, hdc_win);
271 SetMapMode(fe->hdc_bm, MM_TEXT);
274 void draw_update(frontend *fe, int x, int y, int w, int h)
283 InvalidateRect(fe->hwnd, &r, FALSE);
286 void end_draw(frontend *fe)
288 SelectObject(fe->hdc_bm, fe->prevbm);
289 DeleteDC(fe->hdc_bm);
291 DeleteObject(fe->clip);
296 void deactivate_timer(frontend *fe)
298 KillTimer(fe->hwnd, fe->timer);
302 void activate_timer(frontend *fe)
304 fe->timer = SetTimer(fe->hwnd, fe->timer, 20, NULL);
307 static frontend *new_window(HINSTANCE inst)
315 fe->me = midend_new(fe);
317 midend_new_game(fe->me, NULL);
318 midend_size(fe->me, &x, &y);
326 colours = midend_colours(fe->me, &ncolours);
328 fe->colours = snewn(ncolours, COLORREF);
329 fe->brushes = snewn(ncolours, HBRUSH);
330 fe->pens = snewn(ncolours, HPEN);
332 for (i = 0; i < ncolours; i++) {
333 fe->colours[i] = RGB(255 * colours[i*3+0],
334 255 * colours[i*3+1],
335 255 * colours[i*3+2]);
336 fe->brushes[i] = CreateSolidBrush(fe->colours[i]);
337 fe->pens[i] = CreatePen(PS_SOLID, 1, fe->colours[i]);
344 AdjustWindowRectEx(&r, WS_OVERLAPPEDWINDOW &~
345 (WS_THICKFRAME | WS_MAXIMIZEBOX | WS_OVERLAPPED),
348 fe->hwnd = CreateWindowEx(0, game_name, game_name,
349 WS_OVERLAPPEDWINDOW &~
350 (WS_THICKFRAME | WS_MAXIMIZEBOX),
351 CW_USEDEFAULT, CW_USEDEFAULT,
352 r.right - r.left, r.bottom - r.top,
353 NULL, NULL, inst, NULL);
356 HMENU bar = CreateMenu();
357 HMENU menu = CreateMenu();
359 AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)menu, "Game");
360 AppendMenu(menu, MF_ENABLED, IDM_NEW, "New");
361 AppendMenu(menu, MF_ENABLED, IDM_RESTART, "Restart");
363 if ((fe->npresets = midend_num_presets(fe->me)) > 0 ||
364 game_can_configure) {
365 HMENU sub = CreateMenu();
368 AppendMenu(bar, MF_ENABLED|MF_POPUP, (UINT)sub, "Type");
370 fe->presets = snewn(fe->npresets, game_params *);
372 for (i = 0; i < fe->npresets; i++) {
375 midend_fetch_preset(fe->me, i, &name, &fe->presets[i]);
378 * FIXME: we ought to go through and do something
379 * with ampersands here.
382 AppendMenu(sub, MF_ENABLED, IDM_PRESETS + 0x10 * i, name);
385 if (game_can_configure) {
386 AppendMenu(sub, MF_ENABLED, IDM_CONFIG, "Custom...");
390 AppendMenu(menu, MF_SEPARATOR, 0, 0);
391 AppendMenu(menu, MF_ENABLED, IDM_UNDO, "Undo");
392 AppendMenu(menu, MF_ENABLED, IDM_REDO, "Redo");
393 AppendMenu(menu, MF_SEPARATOR, 0, 0);
394 AppendMenu(menu, MF_ENABLED, IDM_QUIT, "Exit");
395 SetMenu(fe->hwnd, bar);
398 if (midend_wants_statusbar(fe->me)) {
399 fe->statusbar = CreateWindowEx(0, STATUSCLASSNAME, "ooh",
400 WS_CHILD | WS_VISIBLE,
401 0, 0, 0, 0, /* status bar does these */
402 fe->hwnd, NULL, inst, NULL);
403 GetWindowRect(fe->statusbar, &sr);
404 SetWindowPos(fe->hwnd, NULL, 0, 0,
405 r.right - r.left, r.bottom - r.top + sr.bottom - sr.top,
406 SWP_NOMOVE | SWP_NOZORDER);
407 SetWindowPos(fe->statusbar, NULL, 0, y, x, sr.bottom - sr.top,
410 fe->statusbar = NULL;
413 hdc = GetDC(fe->hwnd);
414 fe->bitmap = CreateCompatibleBitmap(hdc, x, y);
415 ReleaseDC(fe->hwnd, hdc);
417 SetWindowLong(fe->hwnd, GWL_USERDATA, (LONG)fe);
419 ShowWindow(fe->hwnd, SW_NORMAL);
420 SetForegroundWindow(fe->hwnd);
422 midend_redraw(fe->me);
427 static int CALLBACK ConfigDlgProc(HWND hwnd, UINT msg,
428 WPARAM wParam, LPARAM lParam)
430 frontend *fe = (frontend *)GetWindowLong(hwnd, GWL_USERDATA);
440 * OK and Cancel are special cases.
442 if ((HIWORD(wParam) == BN_CLICKED ||
443 HIWORD(wParam) == BN_DOUBLECLICKED) &&
444 (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)) {
445 if (LOWORD(wParam) == IDOK) {
446 char *err = midend_set_config(fe->me, fe->cfg);
449 MessageBox(hwnd, err, "Validation error",
450 MB_ICONERROR | MB_OK);
461 * First find the control whose id this is.
463 for (i = fe->cfg, j = fe->cfgaux; i->type != C_END; i++, j++) {
464 if (j->ctlid == LOWORD(wParam))
467 if (i->type == C_END)
468 return 0; /* not our problem */
470 if (i->type == C_STRING && HIWORD(wParam) == EN_CHANGE) {
472 GetDlgItemText(fe->cfgbox, j->ctlid, buffer, lenof(buffer));
473 buffer[lenof(buffer)-1] = '\0';
475 i->sval = dupstr(buffer);
476 } else if (i->type == C_BOOLEAN &&
477 (HIWORD(wParam) == BN_CLICKED ||
478 HIWORD(wParam) == BN_DOUBLECLICKED)) {
479 i->ival = IsDlgButtonChecked(fe->cfgbox, j->ctlid);
480 } else if (i->type == C_CHOICES &&
481 HIWORD(wParam) == CBN_SELCHANGE) {
482 i->ival = SendDlgItemMessage(fe->cfgbox, j->ctlid,
496 HWND mkctrl(frontend *fe, int x1, int x2, int y1, int y2,
497 char *wclass, int wstyle,
498 int exstyle, char *wtext, int wid)
501 ret = CreateWindowEx(exstyle, wclass, wtext,
502 wstyle | WS_CHILD | WS_VISIBLE, x1, y1, x2-x1, y2-y1,
503 fe->cfgbox, (HMENU) wid, fe->inst, NULL);
504 SendMessage(ret, WM_SETFONT, (WPARAM)fe->cfgfont, MAKELPARAM(TRUE, 0));
508 static int get_config(frontend *fe)
520 int winwidth, winheight, col1l, col1r, col2l, col2r, y;
521 int height, width, maxlabel, maxcheckbox;
523 wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW;
524 wc.lpfnWndProc = DefDlgProc;
526 wc.cbWndExtra = DLGWINDOWEXTRA + 8;
527 wc.hInstance = fe->inst;
529 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
530 wc.hbrBackground = (HBRUSH) (COLOR_BACKGROUND +1);
531 wc.lpszMenuName = NULL;
532 wc.lpszClassName = "GameConfigBox";
535 hdc = GetDC(fe->hwnd);
536 SetMapMode(hdc, MM_TEXT);
538 fe->cfg_done = FALSE;
540 fe->cfgfont = CreateFont(-MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72),
542 FALSE, FALSE, FALSE, DEFAULT_CHARSET,
543 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
548 oldfont = SelectObject(hdc, fe->cfgfont);
549 if (GetTextMetrics(hdc, &tm)) {
550 height = tm.tmAscent + tm.tmDescent;
551 width = tm.tmAveCharWidth;
556 fe->cfg = midend_get_config(fe->me);
559 * Figure out the layout of the config box by measuring the
560 * length of each piece of text.
562 maxlabel = maxcheckbox = 0;
563 winheight = height/2;
565 for (i = fe->cfg; i->type != C_END; i++) {
570 * Both these control types have a label filling only
571 * the left-hand column of the box.
573 if (GetTextExtentPoint32(hdc, i->name, strlen(i->name), &size) &&
576 winheight += height * 3 / 2 + (height / 2);
581 * Checkboxes take up the whole of the box width.
583 if (GetTextExtentPoint32(hdc, i->name, strlen(i->name), &size) &&
584 maxcheckbox < size.cx)
585 maxcheckbox = size.cx;
586 winheight += height + (height / 2);
591 winheight += height + height * 7 / 4; /* OK / Cancel buttons */
594 col1r = col1l + maxlabel;
595 col2l = col1r + 2*width;
596 col2r = col2l + 30*width;
597 if (col2r < col1l+2*height+maxcheckbox)
598 col2r = col1l+2*height+maxcheckbox;
599 winwidth = col2r + 2*width;
601 ReleaseDC(fe->hwnd, hdc);
604 * Create the dialog, now that we know its size.
611 r.bottom = winheight;
613 AdjustWindowRectEx(&r, (WS_OVERLAPPEDWINDOW /*|
614 DS_MODALFRAME | WS_POPUP | WS_VISIBLE |
615 WS_CAPTION | WS_SYSMENU*/) &~
616 (WS_MAXIMIZEBOX | WS_OVERLAPPED),
620 * Centre the dialog on its parent window.
624 GetWindowRect(fe->hwnd, &r2);
625 r.left = (r2.left + r2.right - r.right) / 2;
626 r.top = (r2.top + r2.bottom - r.bottom) / 2;
630 fe->cfgbox = CreateWindowEx(0, wc.lpszClassName, "Configuration",
631 DS_MODALFRAME | WS_POPUP | WS_VISIBLE |
632 WS_CAPTION | WS_SYSMENU,
634 r.right-r.left, r.bottom-r.top,
635 fe->hwnd, NULL, fe->inst, NULL);
638 SendMessage(fe->cfgbox, WM_SETFONT, (WPARAM)fe->cfgfont, FALSE);
640 SetWindowLong(fe->cfgbox, GWL_USERDATA, (LONG)fe);
641 SetWindowLong(fe->cfgbox, DWL_DLGPROC, (LONG)ConfigDlgProc);
644 * Count the controls so we can allocate cfgaux.
646 for (nctrls = 0, i = fe->cfg; i->type != C_END; i++)
648 fe->cfgaux = snewn(nctrls, struct cfg_aux);
652 for (i = fe->cfg, j = fe->cfgaux; i->type != C_END; i++, j++) {
656 * Edit box with a label beside it.
658 mkctrl(fe, col1l, col1r, y+height*1/8, y+height*9/8,
659 "Static", 0, 0, i->name, id++);
660 ctl = mkctrl(fe, col2l, col2r, y, y+height*3/2,
661 "EDIT", WS_TABSTOP | ES_AUTOHSCROLL,
662 WS_EX_CLIENTEDGE, "", (j->ctlid = id++));
663 SetWindowText(ctl, i->sval);
671 mkctrl(fe, col1l, col2r, y, y+height, "BUTTON",
672 BS_NOTIFY | BS_AUTOCHECKBOX | WS_TABSTOP,
673 0, i->name, (j->ctlid = id++));
679 * Drop-down list with a label beside it.
681 mkctrl(fe, col1l, col1r, y+height*1/8, y+height*9/8,
682 "STATIC", 0, 0, i->name, id++);
683 ctl = mkctrl(fe, col2l, col2r, y, y+height*41/2,
684 "COMBOBOX", WS_TABSTOP |
685 CBS_DROPDOWNLIST | CBS_HASSTRINGS,
686 WS_EX_CLIENTEDGE, "", (j->ctlid = id++));
688 char c, *p, *q, *str;
690 SendMessage(ctl, CB_RESETCONTENT, 0, 0);
695 while (*q && *q != c) q++;
696 str = snewn(q-p+1, char);
697 strncpy(str, p, q-p);
699 SendMessage(ctl, CB_ADDSTRING, 0, (LPARAM)str);
706 SendMessage(ctl, CB_SETCURSEL, i->ival, 0);
712 assert(y < winheight);
716 y += height/2; /* extra space before OK and Cancel */
717 mkctrl(fe, col1l, (col1l+col2r)/2-width, y, y+height*7/4, "BUTTON",
718 BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP | BS_DEFPUSHBUTTON, 0,
720 mkctrl(fe, (col1l+col2r)/2+width, col2r, y, y+height*7/4, "BUTTON",
721 BS_PUSHBUTTON | BS_NOTIFY | WS_TABSTOP, 0, "Cancel", IDCANCEL);
723 SendMessage(fe->cfgbox, WM_INITDIALOG, 0, 0);
725 EnableWindow(fe->hwnd, FALSE);
726 ShowWindow(fe->cfgbox, SW_NORMAL);
727 while ((gm=GetMessage(&msg, NULL, 0, 0)) > 0) {
728 if (!IsDialogMessage(fe->cfgbox, &msg))
729 DispatchMessage(&msg);
733 EnableWindow(fe->hwnd, TRUE);
734 SetForegroundWindow(fe->hwnd);
735 DestroyWindow(fe->cfgbox);
736 DeleteObject(fe->cfgfont);
741 return (fe->cfg_done == 2);
744 static void new_game_type(frontend *fe)
750 midend_new_game(fe->me, NULL);
751 midend_size(fe->me, &x, &y);
756 AdjustWindowRectEx(&r, WS_OVERLAPPEDWINDOW &~
757 (WS_THICKFRAME | WS_MAXIMIZEBOX |
761 if (fe->statusbar != NULL) {
762 GetWindowRect(fe->statusbar, &sr);
764 sr.left = sr.right = sr.top = sr.bottom = 0;
766 SetWindowPos(fe->hwnd, NULL, 0, 0,
768 r.bottom - r.top + sr.bottom - sr.top,
769 SWP_NOMOVE | SWP_NOZORDER);
770 if (fe->statusbar != NULL)
771 SetWindowPos(fe->statusbar, NULL, 0, y, x,
772 sr.bottom - sr.top, SWP_NOZORDER);
774 DeleteObject(fe->bitmap);
776 hdc = GetDC(fe->hwnd);
777 fe->bitmap = CreateCompatibleBitmap(hdc, x, y);
778 ReleaseDC(fe->hwnd, hdc);
780 midend_redraw(fe->me);
783 static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
784 WPARAM wParam, LPARAM lParam)
786 frontend *fe = (frontend *)GetWindowLong(hwnd, GWL_USERDATA);
793 switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
795 if (!midend_process_key(fe->me, 0, 0, 'n'))
799 if (!midend_process_key(fe->me, 0, 0, 'r'))
803 if (!midend_process_key(fe->me, 0, 0, 'u'))
807 if (!midend_process_key(fe->me, 0, 0, '\x12'))
811 if (!midend_process_key(fe->me, 0, 0, 'q'))
820 int p = ((wParam &~ 0xF) - IDM_PRESETS) / 0x10;
822 if (p >= 0 && p < fe->npresets) {
823 midend_set_params(fe->me, fe->presets[p]);
839 hdc = BeginPaint(hwnd, &p);
840 hdc2 = CreateCompatibleDC(hdc);
841 prevbm = SelectObject(hdc2, fe->bitmap);
843 p.rcPaint.left, p.rcPaint.top,
844 p.rcPaint.right - p.rcPaint.left,
845 p.rcPaint.bottom - p.rcPaint.top,
847 p.rcPaint.left, p.rcPaint.top,
849 SelectObject(hdc2, prevbm);
859 case VK_LEFT: key = CURSOR_LEFT; break;
860 case VK_RIGHT: key = CURSOR_RIGHT; break;
861 case VK_UP: key = CURSOR_UP; break;
862 case VK_DOWN: key = CURSOR_DOWN; break;
864 * Diagonal keys on the numeric keypad.
867 if (!(lParam & 0x01000000)) key = CURSOR_UP_RIGHT;
870 if (!(lParam & 0x01000000)) key = CURSOR_DOWN_RIGHT;
873 if (!(lParam & 0x01000000)) key = CURSOR_UP_LEFT;
876 if (!(lParam & 0x01000000)) key = CURSOR_DOWN_LEFT;
879 * Numeric keypad keys with Num Lock on.
881 case VK_NUMPAD4: key = CURSOR_LEFT; break;
882 case VK_NUMPAD6: key = CURSOR_RIGHT; break;
883 case VK_NUMPAD8: key = CURSOR_UP; break;
884 case VK_NUMPAD2: key = CURSOR_DOWN; break;
885 case VK_NUMPAD9: key = CURSOR_UP_RIGHT; break;
886 case VK_NUMPAD3: key = CURSOR_DOWN_RIGHT; break;
887 case VK_NUMPAD7: key = CURSOR_UP_LEFT; break;
888 case VK_NUMPAD1: key = CURSOR_DOWN_LEFT; break;
892 if (!midend_process_key(fe->me, 0, 0, key))
897 m.message = WM_KEYDOWN;
899 m.lParam = lParam & 0xdfff;
900 TranslateMessage(&m);
911 * Shift-clicks count as middle-clicks, since otherwise
912 * two-button Windows users won't have any kind of
913 * middle click to use.
915 if (message == WM_MBUTTONDOWN || (wParam & MK_SHIFT))
916 button = MIDDLE_BUTTON;
917 else if (message == WM_LBUTTONDOWN)
918 button = LEFT_BUTTON;
920 button = RIGHT_BUTTON;
922 if (!midend_process_key(fe->me, LOWORD(lParam),
923 HIWORD(lParam), button))
928 if (!midend_process_key(fe->me, 0, 0, (unsigned char)wParam))
933 midend_timer(fe->me, (float)0.02);
937 return DefWindowProc(hwnd, message, wParam, lParam);
940 int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
946 InitCommonControls();
952 wndclass.lpfnWndProc = WndProc;
953 wndclass.cbClsExtra = 0;
954 wndclass.cbWndExtra = 0;
955 wndclass.hInstance = inst;
956 wndclass.hIcon = LoadIcon(inst, IDI_APPLICATION);
957 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
958 wndclass.hbrBackground = NULL;
959 wndclass.lpszMenuName = NULL;
960 wndclass.lpszClassName = game_name;
962 RegisterClass(&wndclass);
967 while (GetMessage(&msg, NULL, 0, 0)) {
968 DispatchMessage(&msg);