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