2 * PROJECT: PAINT for ReactOS
5 * PURPOSE: Window procedure of the main window and all children apart from
6 * hPalWin, hToolSettings and hSelection
7 * PROGRAMMERS: Benedikt Freisen
10 /* INCLUDES *********************************************************/
14 //#include <htmlhelp.h>
17 #include "definitions.h"
18 #include "globalvar.h"
26 /* FUNCTIONS ********************************************************/
28 void selectTool(int tool
)
30 ShowWindow(hSelection
, SW_HIDE
);
32 pointSP
= 0; // resets the point-buffer of the polygon and bezier functions
33 SendMessage(hToolSettings
, WM_PAINT
, 0, 0);
35 ShowWindow(hTrackbarZoom
, SW_SHOW
);
37 ShowWindow(hTrackbarZoom
, SW_HIDE
);
40 void updateCanvasAndScrollbars()
42 ShowWindow(hSelection
, SW_HIDE
);
43 MoveWindow(hImageArea
, 3, 3, imgXRes
*zoom
/1000, imgYRes
*zoom
/1000, FALSE
);
44 InvalidateRect(hScrollbox
, NULL
, TRUE
);
45 InvalidateRect(hImageArea
, NULL
, FALSE
);
47 SetScrollPos(hScrollbox
, SB_HORZ
, 0, TRUE
);
48 SetScrollPos(hScrollbox
, SB_VERT
, 0, TRUE
);
51 void ZoomTo(int newZoom
)
54 updateCanvasAndScrollbars();
56 int tempZoom
= newZoom
;
60 tempZoom
= tempZoom
>>1;
62 SendMessage(hTrackbarZoom
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)tbPos
);
68 LRESULT CALLBACK
WindowProcedure (HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
70 switch (message
) /* handle the messages */
73 PostQuitMessage (0); /* send a WM_QUIT to the message queue */
76 if (hwnd
==hwndMiniature
)
78 ShowWindow(hwndMiniature
, SW_HIDE
);
79 showMiniature
= FALSE
;
84 TCHAR programname
[20];
85 TCHAR saveprompttext
[100];
87 LoadString(hProgInstance
, IDS_PROGRAMNAME
, programname
, SIZEOF(programname
));
88 LoadString(hProgInstance
, IDS_SAVEPROMPTTEXT
, saveprompttext
, SIZEOF(saveprompttext
));
89 _stprintf(temptext
, saveprompttext
, filename
);
90 switch (MessageBox(hwnd
, temptext
, programname
, MB_YESNOCANCEL
| MB_ICONQUESTION
))
96 SendMessage(hwnd
, WM_COMMAND
, IDM_FILESAVEAS
, 0);
106 case WM_INITMENUPOPUP
:
112 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERPLANE
, MF_ENABLED
| MF_BYCOMMAND
);
113 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERCENTERED
, MF_ENABLED
| MF_BYCOMMAND
);
114 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERSTRETCHED
, MF_ENABLED
| MF_BYCOMMAND
);
118 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERPLANE
, MF_GRAYED
| MF_BYCOMMAND
);
119 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERCENTERED
, MF_GRAYED
| MF_BYCOMMAND
);
120 EnableMenuItem(GetMenu(hMainWnd
), IDM_FILEASWALLPAPERSTRETCHED
, MF_GRAYED
| MF_BYCOMMAND
);
125 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITUNDO
, MF_ENABLED
| MF_BYCOMMAND
);
127 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITUNDO
, MF_GRAYED
| MF_BYCOMMAND
);
129 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITREDO
, MF_ENABLED
| MF_BYCOMMAND
);
131 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITREDO
, MF_GRAYED
| MF_BYCOMMAND
);
132 if (IsWindowVisible(hSelection
))
134 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCUT
, MF_ENABLED
| MF_BYCOMMAND
);
135 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCOPY
, MF_ENABLED
| MF_BYCOMMAND
);
136 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITDELETESELECTION
, MF_ENABLED
| MF_BYCOMMAND
);
137 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITINVERTSELECTION
, MF_ENABLED
| MF_BYCOMMAND
);
138 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCOPYTO
, MF_ENABLED
| MF_BYCOMMAND
);
142 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCUT
, MF_GRAYED
| MF_BYCOMMAND
);
143 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCOPY
, MF_GRAYED
| MF_BYCOMMAND
);
144 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITDELETESELECTION
, MF_GRAYED
| MF_BYCOMMAND
);
145 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITINVERTSELECTION
, MF_GRAYED
| MF_BYCOMMAND
);
146 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITCOPYTO
, MF_GRAYED
| MF_BYCOMMAND
);
148 OpenClipboard(hMainWnd
);
149 if (GetClipboardData(CF_BITMAP
)!=NULL
)
150 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITPASTE
, MF_ENABLED
| MF_BYCOMMAND
);
152 EnableMenuItem(GetMenu(hMainWnd
), IDM_EDITPASTE
, MF_GRAYED
| MF_BYCOMMAND
);
156 if (IsWindowVisible(hSelection
))
157 EnableMenuItem(GetMenu(hMainWnd
), IDM_IMAGECROP
, MF_ENABLED
| MF_BYCOMMAND
);
159 EnableMenuItem(GetMenu(hMainWnd
), IDM_IMAGECROP
, MF_GRAYED
| MF_BYCOMMAND
);
161 CheckMenuItem(GetMenu(hMainWnd
), IDM_IMAGEDRAWOPAQUE
, MF_CHECKED
| MF_BYCOMMAND
);
163 CheckMenuItem(GetMenu(hMainWnd
), IDM_IMAGEDRAWOPAQUE
, MF_UNCHECKED
| MF_BYCOMMAND
);
167 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWSHOWGRID
, MF_CHECKED
| MF_BYCOMMAND
);
169 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWSHOWGRID
, MF_UNCHECKED
| MF_BYCOMMAND
);
171 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWSHOWMINIATURE
, MF_CHECKED
| MF_BYCOMMAND
);
173 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWSHOWMINIATURE
, MF_UNCHECKED
| MF_BYCOMMAND
);
176 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM125
, MF_CHECKED
| MF_BYCOMMAND
);
178 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM125
, MF_UNCHECKED
| MF_BYCOMMAND
);
180 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM25
, MF_CHECKED
| MF_BYCOMMAND
);
182 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM25
, MF_UNCHECKED
| MF_BYCOMMAND
);
184 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM50
, MF_CHECKED
| MF_BYCOMMAND
);
186 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM50
, MF_UNCHECKED
| MF_BYCOMMAND
);
188 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM100
, MF_CHECKED
| MF_BYCOMMAND
);
190 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM100
, MF_UNCHECKED
| MF_BYCOMMAND
);
192 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM200
, MF_CHECKED
| MF_BYCOMMAND
);
194 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM200
, MF_UNCHECKED
| MF_BYCOMMAND
);
196 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM400
, MF_CHECKED
| MF_BYCOMMAND
);
198 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM400
, MF_UNCHECKED
| MF_BYCOMMAND
);
200 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM800
, MF_CHECKED
| MF_BYCOMMAND
);
202 CheckMenuItem(GetMenu(hMainWnd
), IDM_VIEWZOOM800
, MF_UNCHECKED
| MF_BYCOMMAND
);
208 int test
[] = {LOWORD(lParam
)-260, LOWORD(lParam
)-140, LOWORD(lParam
)-20};
209 SendMessage(hStatusBar
, WM_SIZE
, wParam
, lParam
);
210 SendMessage(hStatusBar
, SB_SETPARTS
, 3, (int)&test
);
211 MoveWindow(hScrollbox
, 56, 49,LOWORD(lParam
)-56, HIWORD(lParam
)-72, TRUE
);
212 //InvalidateRect(hwnd, NULL, TRUE);
214 if (hwnd
==hImageArea
)
216 MoveWindow(hSizeboxLeftTop
,
219 MoveWindow(hSizeboxCenterTop
,
220 imgXRes
*zoom
/2000+3*3/4,
222 MoveWindow(hSizeboxRightTop
,
225 MoveWindow(hSizeboxLeftCenter
,
227 imgYRes
*zoom
/2000+3*3/4, 3, 3, TRUE
);
228 MoveWindow(hSizeboxRightCenter
,
230 imgYRes
*zoom
/2000+3*3/4, 3, 3, TRUE
);
231 MoveWindow(hSizeboxLeftBottom
,
233 imgYRes
*zoom
/1000+3, 3, 3, TRUE
);
234 MoveWindow(hSizeboxCenterBottom
,
235 imgXRes
*zoom
/2000+3*3/4,
236 imgYRes
*zoom
/1000+3, 3, 3, TRUE
);
237 MoveWindow(hSizeboxRightBottom
,
239 imgYRes
*zoom
/1000+3, 3, 3, TRUE
);
241 if ((hwnd
==hImageArea
)||(hwnd
==hScrollbox
))
243 long clientRectScrollbox
[4];
244 long clientRectImageArea
[4];
245 SCROLLINFO horzScroll
;
246 SCROLLINFO vertScroll
;
247 GetClientRect(hScrollbox
, (LPRECT
)&clientRectScrollbox
);
248 GetClientRect(hImageArea
, (LPRECT
)&clientRectImageArea
);
249 MoveWindow(hScrlClient
, 0, 0, max(clientRectImageArea
[2]+6, clientRectScrollbox
[2]), max(clientRectImageArea
[3]+6, clientRectScrollbox
[3]), TRUE
);
250 horzScroll
.cbSize
= sizeof(SCROLLINFO
);
251 horzScroll
.fMask
= SIF_PAGE
| SIF_RANGE
;
252 horzScroll
.nMax
= 10000;
254 horzScroll
.nPage
= clientRectScrollbox
[2]*10000/(clientRectImageArea
[2]+6);
256 horzScroll
.nTrackPos
= 0;
257 SetScrollInfo(hScrollbox
, SB_HORZ
, &horzScroll
, TRUE
);
258 GetClientRect(hScrollbox
, (LPRECT
)clientRectScrollbox
);
259 vertScroll
.cbSize
= sizeof(SCROLLINFO
);
260 vertScroll
.fMask
= SIF_PAGE
| SIF_RANGE
;
261 vertScroll
.nMax
= 10000;
263 vertScroll
.nPage
= clientRectScrollbox
[3]*10000/(clientRectImageArea
[3]+6);
265 vertScroll
.nTrackPos
= 0;
266 SetScrollInfo(hScrollbox
, SB_VERT
, &vertScroll
, TRUE
);
270 if (hwnd
==hScrollbox
)
272 if ((LOWORD(wParam
)==SB_THUMBPOSITION
)||(LOWORD(wParam
)==SB_THUMBTRACK
))
274 SetScrollPos(hScrollbox
, SB_HORZ
, HIWORD(wParam
), TRUE
);
275 MoveWindow(hScrlClient
, -(imgXRes
*zoom
/1000+6)*GetScrollPos(hScrollbox
, SB_HORZ
)/10000,
276 -(imgYRes
*zoom
/1000+6)*GetScrollPos(hScrollbox
, SB_VERT
)/10000, imgXRes
*zoom
/1000+6, imgYRes
*zoom
/1000+6, TRUE
);
281 if (hwnd
==hScrollbox
)
283 if ((LOWORD(wParam
)==SB_THUMBPOSITION
)||(LOWORD(wParam
)==SB_THUMBTRACK
))
285 SetScrollPos(hScrollbox
, SB_VERT
, HIWORD(wParam
), TRUE
);
286 MoveWindow(hScrlClient
, -(imgXRes
*zoom
/1000+6)*GetScrollPos(hScrollbox
, SB_HORZ
)/10000,
287 -(imgYRes
*zoom
/1000+6)*GetScrollPos(hScrollbox
, SB_VERT
)/10000, imgXRes
*zoom
/1000+6, imgYRes
*zoom
/1000+6, TRUE
);
291 case WM_GETMINMAXINFO
:
294 MINMAXINFO
*mm
= (LPMINMAXINFO
)lParam
;
295 (*mm
).ptMinTrackSize
.x
= 330;
296 (*mm
).ptMinTrackSize
.y
= 430;
300 DefWindowProc (hwnd
, message
, wParam
, lParam
);
301 if (hwnd
==hImageArea
)
303 HDC hdc
= GetDC(hImageArea
);
304 StretchBlt(hdc
, 0, 0, imgXRes
*zoom
/1000, imgYRes
*zoom
/1000, hDrawingDC
, 0, 0, imgXRes
, imgYRes
, SRCCOPY
);
305 if (showGrid
&& (zoom
>=4000))
307 HPEN oldPen
= SelectObject(hdc
, CreatePen(PS_SOLID
, 1, 0x00a0a0a0));
309 for (counter
= 0; counter
<= imgYRes
; counter
++)
311 MoveToEx(hdc
, 0, counter
*zoom
/1000, NULL
);
312 LineTo(hdc
, imgXRes
*zoom
/1000, counter
*zoom
/1000);
314 for (counter
= 0; counter
<= imgXRes
; counter
++)
316 MoveToEx(hdc
, counter
*zoom
/1000, 0, NULL
);
317 LineTo(hdc
, counter
*zoom
/1000, imgYRes
*zoom
/1000);
319 DeleteObject(SelectObject(hdc
, oldPen
));
321 ReleaseDC(hImageArea
, hdc
);
322 SendMessage(hSelection
, WM_PAINT
, 0, 0);
323 SendMessage(hwndMiniature
, WM_PAINT
, 0, 0);
325 if (hwnd
==hwndMiniature
)
329 GetClientRect(hwndMiniature
, (LPRECT
)&mclient
);
330 hdc
= GetDC(hwndMiniature
);
331 BitBlt(hdc
, -min(imgXRes
*GetScrollPos(hScrollbox
, SB_HORZ
)/10000, imgXRes
-mclient
[2]),
332 -min(imgYRes
*GetScrollPos(hScrollbox
, SB_VERT
)/10000, imgYRes
-mclient
[3]), imgXRes
, imgYRes
, hDrawingDC
, 0, 0, SRCCOPY
);
333 ReleaseDC(hwndMiniature
, hdc
);
337 // mouse events used for drawing
340 if (hwnd
==hImageArea
)
348 SetCursor(hCurColor
);
357 SetCursor(hCurAirbrush
);
360 SetCursor(LoadCursor(NULL
, IDC_CROSS
));
362 } else DefWindowProc(hwnd
, message
, wParam
, lParam
);
365 if (hwnd
==hImageArea
)
367 if ((!drawing
)||(activeTool
==5))
369 SetCapture(hImageArea
);
371 startPaintingL(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
374 SendMessage(hwnd
, WM_LBUTTONUP
, wParam
, lParam
);
377 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
378 if ((activeTool
==6)&&(zoom
<8000)) ZoomTo(zoom
*2);
382 if (hwnd
==hImageArea
)
384 if ((!drawing
)||(activeTool
==5))
386 SetCapture(hImageArea
);
388 startPaintingR(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
391 SendMessage(hwnd
, WM_RBUTTONUP
, wParam
, lParam
);
394 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
395 if ((activeTool
==6)&&(zoom
>125)) ZoomTo(zoom
/2);
399 if ((hwnd
==hImageArea
)&&drawing
)
403 endPaintingL(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
404 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
407 int tempColor
= GetPixel(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
);
408 if (tempColor
!=CLR_INVALID
) fgColor
= tempColor
;
409 SendMessage(hPalWin
, WM_PAINT
, 0, 0);
411 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
)"");
415 if ((hwnd
==hImageArea
)&&drawing
)
419 endPaintingR(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
420 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
423 int tempColor
= GetPixel(hDrawingDC
, LOWORD(lParam
)*1000/zoom
, HIWORD(lParam
)*1000/zoom
);
424 if (tempColor
!=CLR_INVALID
) bgColor
= tempColor
;
425 SendMessage(hPalWin
, WM_PAINT
, 0, 0);
427 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
)"");
431 if (hwnd
==hImageArea
)
433 if ((!drawing
)||(activeTool
<=9))
436 _stprintf(coordStr
, _T("%d, %d"), (short)LOWORD(lParam
)*1000/zoom
, (short)HIWORD(lParam
)*1000/zoom
);
437 SendMessage(hStatusBar
, SB_SETTEXT
, 1, (LPARAM
)coordStr
);
441 if ((wParam
&MK_LBUTTON
)!=0)
443 whilePaintingL(hDrawingDC
, (short)LOWORD(lParam
)*1000/zoom
, (short)HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
444 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
445 if ((activeTool
>=10)||(activeTool
==2))
448 _stprintf(sizeStr
, _T("%d x %d"), (short)LOWORD(lParam
)*1000/zoom
-startX
, (short)HIWORD(lParam
)*1000/zoom
-startY
);
449 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
)sizeStr
);
452 if ((wParam
&MK_RBUTTON
)!=0)
454 whilePaintingR(hDrawingDC
, (short)LOWORD(lParam
)*1000/zoom
, (short)HIWORD(lParam
)*1000/zoom
, fgColor
, bgColor
);
455 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
459 _stprintf(sizeStr
, _T("%d x %d"), (short)LOWORD(lParam
)*1000/zoom
-startX
, (short)HIWORD(lParam
)*1000/zoom
-startY
);
460 SendMessage(hStatusBar
, SB_SETTEXT
, 2, (LPARAM
)sizeStr
);
466 SendMessage(hStatusBar
, SB_SETTEXT
, 1, (LPARAM
)_T(""));
470 // menu and button events
473 switch (LOWORD(wParam
))
477 HICON paintIcon
= LoadIcon(hProgInstance
, MAKEINTRESOURCE(IDI_APPICON
));
478 TCHAR infotitle
[100];
480 LoadString(hProgInstance
, IDS_INFOTITLE
, infotitle
, SIZEOF(infotitle
));
481 LoadString(hProgInstance
, IDS_INFOTEXT
, infotext
, SIZEOF(infotext
));
482 ShellAbout(hMainWnd
, infotitle
, infotext
, paintIcon
);
483 DeleteObject(paintIcon
);
486 case IDM_HELPHELPTOPICS
:
487 //HtmlHelp(hMainWnd, "help\\Paint.chm", 0, 0);
490 SendMessage(hwnd
, WM_CLOSE
, wParam
, lParam
);
493 Rectangle(hDrawingDC
, 0-1, 0-1, imgXRes
+1, imgYRes
+1);
494 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
497 if (GetOpenFileName(&ofn
)!=0)
499 HBITMAP bmNew
= (HBITMAP
)LoadDIBFromFile(ofn
.lpstrFile
);
504 insertReversible(bmNew
);
505 updateCanvasAndScrollbars();
506 CopyMemory(filename
, ofn
.lpstrFileTitle
, sizeof(filename
));
507 CopyMemory(filepathname
, ofn
.lpstrFileTitle
, sizeof(filepathname
));
508 LoadString(hProgInstance
, IDS_WINDOWTITLE
, resstr
, SIZEOF(resstr
));
509 _stprintf(tempstr
, resstr
, filename
);
510 SetWindowText(hMainWnd
, tempstr
);
519 SaveDIBToFile(hBms
[currInd
], filepathname
, hDrawingDC
);
523 SendMessage(hwnd
, WM_COMMAND
, IDM_FILESAVEAS
, 0);
526 if (GetSaveFileName(&sfn
)!=0)
530 SaveDIBToFile(hBms
[currInd
], sfn
.lpstrFile
, hDrawingDC
);
531 CopyMemory(filename
, sfn
.lpstrFileTitle
, sizeof(filename
));
532 CopyMemory(filepathname
, sfn
.lpstrFile
, sizeof(filepathname
));
533 LoadString(hProgInstance
, IDS_WINDOWTITLE
, resstr
, SIZEOF(resstr
));
534 _stprintf(tempstr
, resstr
, filename
);
535 SetWindowText(hMainWnd
, tempstr
);
540 case IDM_FILEASWALLPAPERPLANE
:
541 SetWallpaper(filepathname
, 1, 1);
543 case IDM_FILEASWALLPAPERCENTERED
:
544 SetWallpaper(filepathname
, 1, 0);
546 case IDM_FILEASWALLPAPERSTRETCHED
:
547 SetWallpaper(filepathname
, 2, 0);
551 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
555 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
558 OpenClipboard(hMainWnd
);
560 SetClipboardData(CF_BITMAP
, CopyImage(hSelBm
, IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
564 OpenClipboard(hMainWnd
);
565 if (GetClipboardData(CF_BITMAP
)!=NULL
)
567 DeleteObject(SelectObject(hSelDC
, hSelBm
= CopyImage(GetClipboardData(CF_BITMAP
), IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
)));
569 rectSel_src
[0] = rectSel_src
[1] = rectSel_src
[2] = rectSel_src
[3] = 0;
570 rectSel_dest
[0] = rectSel_dest
[1] = 0;
571 rectSel_dest
[2] = GetDIBWidth(hSelBm
);
572 rectSel_dest
[3] = GetDIBHeight(hSelBm
);
573 BitBlt(hDrawingDC
, rectSel_dest
[0], rectSel_dest
[1], rectSel_dest
[2], rectSel_dest
[3], hSelDC
, 0, 0, SRCCOPY
);
575 ShowWindow(hSelection
, SW_SHOW
);
579 case IDM_EDITDELETESELECTION
:
580 ShowWindow(hSelection
, SW_HIDE
);
582 case IDM_EDITSELECTALL
:
585 startPaintingL(hDrawingDC
, 0, 0, fgColor
, bgColor
);
586 whilePaintingL(hDrawingDC
, imgXRes
, imgYRes
, fgColor
, bgColor
);
587 endPaintingL(hDrawingDC
, imgXRes
, imgYRes
, fgColor
, bgColor
);
591 if (GetSaveFileName(&ofn
)!=0) SaveDIBToFile(hSelBm
, ofn
.lpstrFile
, hDrawingDC
);
593 case IDM_COLORSEDITPALETTE
:
594 if (ChooseColor(&choosecolor
))
596 fgColor
= choosecolor
.rgbResult
;
597 SendMessage(hPalWin
, WM_PAINT
, 0, 0);
600 case IDM_IMAGEINVERTCOLORS
:
604 SetRect(&tempRect
, 0, 0, imgXRes
, imgYRes
);
605 InvertRect(hDrawingDC
, &tempRect
);
606 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
609 case IDM_IMAGEDELETEIMAGE
:
611 Rect(hDrawingDC
, 0, 0, imgXRes
, imgYRes
, bgColor
, bgColor
, 0, TRUE
);
612 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
614 case IDM_IMAGEROTATEMIRROR
:
615 switch (mirrorRotateDlg())
619 StretchBlt(hDrawingDC
, imgXRes
-1, 0, -imgXRes
, imgYRes
, hDrawingDC
, 0, 0, imgXRes
, imgYRes
, SRCCOPY
);
620 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
624 StretchBlt(hDrawingDC
, 0, imgYRes
-1, imgXRes
, -imgYRes
, hDrawingDC
, 0, 0, imgXRes
, imgYRes
, SRCCOPY
);
625 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
629 StretchBlt(hDrawingDC
, imgXRes
-1, imgYRes
-1, -imgXRes
, -imgYRes
, hDrawingDC
, 0, 0, imgXRes
, imgYRes
, SRCCOPY
);
630 SendMessage(hImageArea
, WM_PAINT
, 0, 0);
634 case IDM_IMAGEATTRIBUTES
:
636 int retVal
= attributesDlg();
637 if ((LOWORD(retVal
)!=0)&&(HIWORD(retVal
)!=0))
639 cropReversible(LOWORD(retVal
), HIWORD(retVal
), 0, 0);
640 updateCanvasAndScrollbars();
644 case IDM_IMAGECHANGESIZE
:
646 int retVal
= changeSizeDlg();
647 if ((LOWORD(retVal
)!=0)&&(HIWORD(retVal
)!=0))
649 insertReversible(CopyImage(hBms
[currInd
], IMAGE_BITMAP
, imgXRes
*LOWORD(retVal
)/100, imgYRes
*HIWORD(retVal
)/100, 0));
650 updateCanvasAndScrollbars();
654 case IDM_IMAGEDRAWOPAQUE
:
655 transpBg
= 1-transpBg
;
656 SendMessage(hToolSettings
, WM_PAINT
, 0, 0);
659 insertReversible(CopyImage(hSelBm
, IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
));
660 updateCanvasAndScrollbars();
663 case IDM_VIEWSHOWGRID
:
664 showGrid
= !showGrid
;
666 case IDM_VIEWSHOWMINIATURE
:
667 showMiniature
= !showMiniature
;
669 ShowWindow(hwndMiniature
, SW_SHOW
);
671 ShowWindow(hwndMiniature
, SW_HIDE
);
674 case IDM_VIEWZOOM125
:
683 case IDM_VIEWZOOM100
:
686 case IDM_VIEWZOOM200
:
689 case IDM_VIEWZOOM400
:
692 case IDM_VIEWZOOM800
:
746 return DefWindowProc (hwnd
, message
, wParam
, lParam
);