Sync with trunk (r47116), hopefully without breaking anything.
[reactos.git] / base / applications / paint / main.c
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/paint/main.c
5 * PURPOSE: Initializing everything
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9 /* INCLUDES *********************************************************/
10
11 #include <windows.h>
12 #include <windowsx.h>
13 #include <commctrl.h>
14 #include <stdio.h>
15 #include <tchar.h>
16 #include "definitions.h"
17
18 #include "drawing.h"
19 #include "dib.h"
20
21 #include "globalvar.h"
22 #include "history.h"
23 #include "mouse.h"
24
25 #include "winproc.h"
26 #include "palette.h"
27 #include "toolsettings.h"
28 #include "selection.h"
29 #include "sizebox.h"
30
31 /* FUNCTIONS ********************************************************/
32
33 HDC hDrawingDC;
34 HDC hSelDC;
35 int *bmAddress;
36 BITMAPINFO bitmapinfo;
37 int imgXRes = 400;
38 int imgYRes = 300;
39
40 HBITMAP hBms[HISTORYSIZE];
41 int currInd = 0;
42 int undoSteps = 0;
43 int redoSteps = 0;
44 BOOL imageSaved = TRUE;
45
46 short startX;
47 short startY;
48 short lastX;
49 short lastY;
50 int lineWidth = 1;
51 int shapeStyle = 0;
52 int brushStyle = 0;
53 int activeTool = 7;
54 int airBrushWidth = 5;
55 int rubberRadius = 4;
56 int transpBg = 0;
57 int zoom = 1000;
58 int rectSel_src[4];
59 int rectSel_dest[4];
60 HWND hSelection;
61 HWND hImageArea;
62 HBITMAP hSelBm;
63 HBITMAP hSelMask;
64
65 /* initial palette colors; may be changed by the user during execution */
66 int palColors[28] = { 0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff, 0x0ec2ff,
67 0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
68 0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
69 0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
70 };
71
72 /* foreground and background colors with initial value */
73 int fgColor = 0x00000000;
74 int bgColor = 0x00ffffff;
75
76 HWND hStatusBar;
77 HWND hScrollbox;
78 HWND hMainWnd;
79 HWND hPalWin;
80 HWND hToolBoxContainer;
81 HWND hToolSettings;
82 HWND hTrackbarZoom;
83 CHOOSECOLOR choosecolor;
84 OPENFILENAME ofn;
85 OPENFILENAME sfn;
86 HICON hNontranspIcon;
87 HICON hTranspIcon;
88
89 HCURSOR hCurFill;
90 HCURSOR hCurColor;
91 HCURSOR hCurZoom;
92 HCURSOR hCurPen;
93 HCURSOR hCurAirbrush;
94
95 HWND hScrlClient;
96
97 HWND hToolBtn[16];
98
99 HINSTANCE hProgInstance;
100
101 TCHAR filename[256];
102 TCHAR filepathname[1000];
103 BOOL isAFile = FALSE;
104 int fileSize;
105 int fileHPPM = 2834;
106 int fileVPPM = 2834;
107 SYSTEMTIME fileTime;
108
109 BOOL showGrid = FALSE;
110 BOOL showMiniature = FALSE;
111
112 HWND hwndMiniature;
113
114 HWND hSizeboxLeftTop;
115 HWND hSizeboxCenterTop;
116 HWND hSizeboxRightTop;
117 HWND hSizeboxLeftCenter;
118 HWND hSizeboxRightCenter;
119 HWND hSizeboxLeftBottom;
120 HWND hSizeboxCenterBottom;
121 HWND hSizeboxRightBottom;
122
123 /* entry point */
124
125 int WINAPI
126 _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument, int nFunsterStil)
127 {
128 HWND hwnd; /* This is the handle for our window */
129 MSG messages; /* Here messages to the application are saved */
130
131 WNDCLASSEX wclScroll;
132 WNDCLASSEX wincl;
133 WNDCLASSEX wclPal;
134 WNDCLASSEX wclSettings;
135 WNDCLASSEX wclSelection;
136
137 TCHAR progtitle[1000];
138 TCHAR resstr[100];
139 HMENU menu;
140 HWND hToolbar;
141 HIMAGELIST hImageList;
142 HANDLE haccel;
143 HBITMAP tempBm;
144 int i;
145 TCHAR tooltips[16][30];
146 HDC hDC;
147
148 TCHAR *c;
149 TCHAR sfnFilename[1000];
150 TCHAR sfnFiletitle[256];
151 TCHAR sfnFilter[1000];
152 TCHAR ofnFilename[1000];
153 TCHAR ofnFiletitle[256];
154 TCHAR ofnFilter[1000];
155 TCHAR miniaturetitle[100];
156 static int custColors[16] = { 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff,
157 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff
158 };
159
160 hProgInstance = hThisInstance;
161
162 /* Necessary */
163 InitCommonControls();
164
165 /* initializing and registering the window class used for the main window */
166 wincl.hInstance = hThisInstance;
167 wincl.lpszClassName = _T("WindowsApp");
168 wincl.lpfnWndProc = WindowProcedure;
169 wincl.style = CS_DBLCLKS;
170 wincl.cbSize = sizeof(WNDCLASSEX);
171 wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
172 wincl.hIconSm = LoadIcon(hThisInstance, MAKEINTRESOURCE(500));
173 wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
174 wincl.lpszMenuName = NULL;
175 wincl.cbClsExtra = 0;
176 wincl.cbWndExtra = 0;
177 wincl.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
178 RegisterClassEx (&wincl);
179
180 /* initializing and registering the window class used for the scroll box */
181 wclScroll.hInstance = hThisInstance;
182 wclScroll.lpszClassName = _T("Scrollbox");
183 wclScroll.lpfnWndProc = WindowProcedure;
184 wclScroll.style = 0;
185 wclScroll.cbSize = sizeof(WNDCLASSEX);
186 wclScroll.hIcon = NULL;
187 wclScroll.hIconSm = NULL;
188 wclScroll.hCursor = LoadCursor(NULL, IDC_ARROW);
189 wclScroll.lpszMenuName = NULL;
190 wclScroll.cbClsExtra = 0;
191 wclScroll.cbWndExtra = 0;
192 wclScroll.hbrBackground = GetSysColorBrush(COLOR_APPWORKSPACE);
193 RegisterClassEx (&wclScroll);
194
195 /* initializing and registering the window class used for the palette window */
196 wclPal.hInstance = hThisInstance;
197 wclPal.lpszClassName = _T("Palette");
198 wclPal.lpfnWndProc = PalWinProc;
199 wclPal.style = CS_DBLCLKS;
200 wclPal.cbSize = sizeof(WNDCLASSEX);
201 wclPal.hIcon = NULL;
202 wclPal.hIconSm = NULL;
203 wclPal.hCursor = LoadCursor(NULL, IDC_ARROW);
204 wclPal.lpszMenuName = NULL;
205 wclPal.cbClsExtra = 0;
206 wclPal.cbWndExtra = 0;
207 wclPal.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
208 RegisterClassEx (&wclPal);
209
210 /* initializing and registering the window class for the settings window */
211 wclSettings.hInstance = hThisInstance;
212 wclSettings.lpszClassName = _T("ToolSettings");
213 wclSettings.lpfnWndProc = SettingsWinProc;
214 wclSettings.style = CS_DBLCLKS;
215 wclSettings.cbSize = sizeof(WNDCLASSEX);
216 wclSettings.hIcon = NULL;
217 wclSettings.hIconSm = NULL;
218 wclSettings.hCursor = LoadCursor(NULL, IDC_ARROW);
219 wclSettings.lpszMenuName = NULL;
220 wclSettings.cbClsExtra = 0;
221 wclSettings.cbWndExtra = 0;
222 wclSettings.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
223 RegisterClassEx (&wclSettings);
224
225 /* initializing and registering the window class for the selection frame */
226 wclSelection.hInstance = hThisInstance;
227 wclSelection.lpszClassName = _T("Selection");
228 wclSelection.lpfnWndProc = SelectionWinProc;
229 wclSelection.style = CS_DBLCLKS;
230 wclSelection.cbSize = sizeof(WNDCLASSEX);
231 wclSelection.hIcon = NULL;
232 wclSelection.hIconSm = NULL;
233 wclSelection.hCursor = LoadCursor(NULL, IDC_SIZEALL);
234 wclSelection.lpszMenuName = NULL;
235 wclSelection.cbClsExtra = 0;
236 wclSelection.cbWndExtra = 0;
237 wclSelection.hbrBackground = NULL;
238 RegisterClassEx (&wclSelection);
239
240 /* initializing and registering the window class for the size boxes */
241 wclSettings.hInstance = hThisInstance;
242 wclSettings.lpszClassName = _T("Sizebox");
243 wclSettings.lpfnWndProc = SizeboxWinProc;
244 wclSettings.style = CS_DBLCLKS;
245 wclSettings.cbSize = sizeof(WNDCLASSEX);
246 wclSettings.hIcon = NULL;
247 wclSettings.hIconSm = NULL;
248 wclSettings.hCursor = LoadCursor(NULL, IDC_ARROW);
249 wclSettings.lpszMenuName = NULL;
250 wclSettings.cbClsExtra = 0;
251 wclSettings.cbWndExtra = 0;
252 wclSettings.hbrBackground = GetSysColorBrush(COLOR_HIGHLIGHT);
253 RegisterClassEx (&wclSettings);
254
255 LoadString(hThisInstance, IDS_DEFAULTFILENAME, filename, SIZEOF(filename));
256 LoadString(hThisInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
257 _stprintf(progtitle, resstr, filename);
258 LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle, SIZEOF(miniaturetitle));
259
260 /* create main window */
261 hwnd =
262 CreateWindowEx(0, _T("WindowsApp"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544,
263 375, HWND_DESKTOP, NULL, hThisInstance, NULL);
264 hMainWnd = hwnd;
265
266 hwndMiniature =
267 CreateWindowEx(WS_EX_PALETTEWINDOW, _T("WindowsApp"), miniaturetitle,
268 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, 180, 200, 120, 100, hwnd,
269 NULL, hThisInstance, NULL);
270
271 /* loading and setting the window menu from resource */
272 menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
273 SetMenu(hwnd, menu);
274 haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800));
275
276 /* preloading the draw transparent/nontransparent icons for later use */
277 hNontranspIcon =
278 LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_NONTRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR);
279 hTranspIcon =
280 LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_TRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR);
281
282 hCurFill = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_FILL));
283 hCurColor = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_COLOR));
284 hCurZoom = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_ZOOM));
285 hCurPen = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN));
286 hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));
287
288 CreateWindowEx(0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
289 hThisInstance, NULL);
290
291 hToolBoxContainer =
292 CreateWindowEx(0, _T("WindowsApp"), _T(""), WS_CHILD | WS_VISIBLE, 2, 2, 52, 350, hwnd, NULL,
293 hThisInstance, NULL);
294 /* creating the 16 bitmap radio buttons and setting the bitmap */
295
296
297 /*
298 * FIXME: Unintentionally there is a line above the tool bar.
299 * To prevent cropping of the buttons height has been increased from 200 to 205
300 */
301 hToolbar =
302 CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
303 WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS,
304 1, 1, 50, 205, hToolBoxContainer, NULL, hThisInstance, NULL);
305 hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
306 SendMessage(hToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImageList);
307 tempBm = LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
308 ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
309 DeleteObject(tempBm);
310 SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
311
312 for(i = 0; i < 16; i++)
313 {
314 TBBUTTON tbbutton;
315 int wrapnow = 0;
316
317 if (i % 2 == 1)
318 wrapnow = TBSTATE_WRAP;
319
320 LoadString(hThisInstance, IDS_TOOLTIP1 + i, tooltips[i], 30);
321 ZeroMemory(&tbbutton, sizeof(TBBUTTON));
322 tbbutton.iString = (INT_PTR) tooltips[i];
323 tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
324 tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
325 tbbutton.idCommand = ID_FREESEL + i;
326 tbbutton.iBitmap = i;
327 SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
328 }
329
330 SendMessage(hToolbar, TB_CHECKBUTTON, ID_PEN, MAKELONG(TRUE, 0));
331 SendMessage(hToolbar, TB_SETMAXTEXTROWS, 0, 0);
332 SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25));
333
334 /* creating the tool settings child window */
335 hToolSettings =
336 CreateWindowEx(0, _T("ToolSettings"), _T(""), WS_CHILD | WS_VISIBLE, 5, 208, 42, 140,
337 hToolBoxContainer, NULL, hThisInstance, NULL);
338 hTrackbarZoom =
339 CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD | TBS_VERT | TBS_AUTOTICKS, 1, 1, 40, 64,
340 hToolSettings, NULL, hThisInstance, NULL);
341 SendMessage(hTrackbarZoom, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
342 SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
343
344 /* creating the palette child window */
345 hPalWin =
346 CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL,
347 hThisInstance, NULL);
348
349 /* creating the scroll box */
350 hScrollbox =
351 CreateWindowEx(WS_EX_CLIENTEDGE, _T("Scrollbox"), _T(""),
352 WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 56, 49, 472, 248, hwnd,
353 NULL, hThisInstance, NULL);
354
355 /* creating the status bar */
356 hStatusBar =
357 CreateWindowEx(0, STATUSCLASSNAME, _T(""), SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd,
358 NULL, hThisInstance, NULL);
359 SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
360
361 hScrlClient =
362 CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL,
363 hThisInstance, NULL);
364
365 /* create selection window (initially hidden) */
366 hSelection =
367 CreateWindowEx(WS_EX_TRANSPARENT, _T("Selection"), _T(""), WS_CHILD | BS_OWNERDRAW, 350, 0, 100, 100,
368 hScrlClient, NULL, hThisInstance, NULL);
369
370 /* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
371 hImageArea =
372 CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
373 NULL, hThisInstance, NULL);
374
375 hDC = GetDC(hImageArea);
376 hDrawingDC = CreateCompatibleDC(hDC);
377 hSelDC = CreateCompatibleDC(hDC);
378 ReleaseDC(hImageArea, hDC);
379 SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, fgColor));
380 SelectObject(hDrawingDC, CreateSolidBrush(bgColor));
381
382 hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
383 SelectObject(hDrawingDC, hBms[0]);
384 Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
385
386 if (lpszArgument[0] != 0)
387 {
388 HBITMAP bmNew = NULL;
389 LoadDIBFromFile(&bmNew, lpszArgument, &fileTime, &fileSize, &fileHPPM, &fileVPPM);
390 if (bmNew != NULL)
391 {
392 TCHAR tempstr[1000];
393 TCHAR resstr[100];
394 TCHAR *temp;
395 insertReversible(bmNew);
396 GetFullPathName(lpszArgument, SIZEOF(filepathname), filepathname, &temp);
397 _tcscpy(filename, temp);
398 LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
399 _stprintf(tempstr, resstr, filename);
400 SetWindowText(hMainWnd, tempstr);
401 clearHistory();
402 isAFile = TRUE;
403 }
404 }
405
406 /* initializing the CHOOSECOLOR structure for use with ChooseColor */
407 choosecolor.lStructSize = sizeof(CHOOSECOLOR);
408 choosecolor.hwndOwner = hwnd;
409 choosecolor.hInstance = NULL;
410 choosecolor.rgbResult = 0x00ffffff;
411 choosecolor.lpCustColors = (COLORREF*) &custColors;
412 choosecolor.Flags = 0;
413 choosecolor.lCustData = 0;
414 choosecolor.lpfnHook = NULL;
415 choosecolor.lpTemplateName = NULL;
416
417 /* initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName */
418 CopyMemory(ofnFilename, filename, sizeof(filename));
419 LoadString(hThisInstance, IDS_OPENFILTER, ofnFilter, SIZEOF(ofnFilter));
420 for(c = ofnFilter; *c; c++)
421 if (*c == '\1')
422 *c = '\0';
423 ZeroMemory(&ofn, sizeof(OPENFILENAME));
424 ofn.lStructSize = sizeof(OPENFILENAME);
425 ofn.hwndOwner = hwnd;
426 ofn.hInstance = hThisInstance;
427 ofn.lpstrFilter = ofnFilter;
428 ofn.lpstrFile = ofnFilename;
429 ofn.nMaxFile = SIZEOF(ofnFilename);
430 ofn.lpstrFileTitle = ofnFiletitle;
431 ofn.nMaxFileTitle = SIZEOF(ofnFiletitle);
432 ofn.Flags = OFN_HIDEREADONLY;
433
434 CopyMemory(sfnFilename, filename, sizeof(filename));
435 LoadString(hThisInstance, IDS_SAVEFILTER, sfnFilter, SIZEOF(sfnFilter));
436 for(c = sfnFilter; *c; c++)
437 if (*c == '\1')
438 *c = '\0';
439 ZeroMemory(&sfn, sizeof(OPENFILENAME));
440 sfn.lStructSize = sizeof(OPENFILENAME);
441 sfn.hwndOwner = hwnd;
442 sfn.hInstance = hThisInstance;
443 sfn.lpstrFilter = sfnFilter;
444 sfn.lpstrFile = sfnFilename;
445 sfn.nMaxFile = SIZEOF(sfnFilename);
446 sfn.lpstrFileTitle = sfnFiletitle;
447 sfn.nMaxFileTitle = SIZEOF(sfnFiletitle);
448 sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
449
450 /* creating the size boxes */
451 hSizeboxLeftTop =
452 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
453 hThisInstance, NULL);
454 hSizeboxCenterTop =
455 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
456 hThisInstance, NULL);
457 hSizeboxRightTop =
458 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
459 hThisInstance, NULL);
460 hSizeboxLeftCenter =
461 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
462 hThisInstance, NULL);
463 hSizeboxRightCenter =
464 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
465 hThisInstance, NULL);
466 hSizeboxLeftBottom =
467 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
468 hThisInstance, NULL);
469 hSizeboxCenterBottom =
470 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
471 hThisInstance, NULL);
472 hSizeboxRightBottom =
473 CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
474 hThisInstance, NULL);
475 /* placing the size boxes around the image */
476 SendMessage(hImageArea, WM_SIZE, 0, 0);
477
478 /* by moving the window, the things in WM_SIZE are done */
479 MoveWindow(hwnd, 100, 100, 600, 450, TRUE);
480
481 /* Make the window visible on the screen */
482 ShowWindow (hwnd, nFunsterStil);
483
484 /* Run the message loop. It will run until GetMessage() returns 0 */
485 while (GetMessage(&messages, NULL, 0, 0))
486 {
487 TranslateAccelerator(hwnd, haccel, &messages);
488
489 /* Translate virtual-key messages into character messages */
490 TranslateMessage(&messages);
491 /* Send message to WindowProcedure */
492 DispatchMessage(&messages);
493 }
494
495 /* The program return-value is 0 - The value that PostQuitMessage() gave */
496 return messages.wParam;
497 }