2 * PROJECT: ReactOS Magnify
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/magnify/magnifier.c
5 * PURPOSE: Magnification of parts of the screen.
7 * Marc Piulachs <marc.piulachs@codexchange.net>
8 * David Quintana <gigaherz@gmail.com>
11 /* TODO: Support AppBar types other than ABE_TOP */
13 #include "magnifier.h"
27 #define APPMSG_NOTIFYICON (WM_APP+1)
28 #define APPMSG_APPBAR (WM_APP+2)
30 const TCHAR szWindowClass
[] = TEXT("MAGNIFIER");
32 /* Global Variables */
36 #define MAX_LOADSTRING 100
37 TCHAR szTitle
[MAX_LOADSTRING
];
40 #define REPAINT_SPEED 100
44 HWND hDesktopWindow
= NULL
;
50 BOOL bOptionsDialog
= FALSE
;
51 BOOL bRecreateOffscreenDC
= TRUE
;
53 LONG sourceHeight
= 0;
54 HDC hdcOffscreen
= NULL
;
55 HBITMAP hbmpOffscreen
= NULL
;
60 /* Current magnified area */
70 ATOM
MyRegisterClass(HINSTANCE hInstance
);
71 BOOL
InitInstance(HINSTANCE
, int);
72 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
73 INT_PTR CALLBACK
AboutProc(HWND
, UINT
, WPARAM
, LPARAM
);
74 INT_PTR CALLBACK
OptionsProc(HWND
, UINT
, WPARAM
, LPARAM
);
75 INT_PTR CALLBACK
WarningProc(HWND
, UINT
, WPARAM
, LPARAM
);
77 int WINAPI
WinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPSTR lpCmdLine
, int nCmdShow
)
81 INITCOMMONCONTROLSEX iccex
;
83 UNREFERENCED_PARAMETER(hPrevInstance
);
84 UNREFERENCED_PARAMETER(lpCmdLine
);
86 switch (GetUserDefaultUILanguage())
88 case MAKELANGID(LANG_HEBREW
, SUBLANG_DEFAULT
):
89 SetProcessDefaultLayout(LAYOUT_RTL
);
96 /* Initialize global strings */
97 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
98 MyRegisterClass(hInstance
);
100 /* Perform application initialization */
101 if (!InitInstance(hInstance
, nCmdShow
))
104 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDC_MAGNIFIER
));
106 /* Main message loop */
107 while (GetMessage(&msg
, NULL
, 0, 0))
109 if (!TranslateAccelerator(hMainWnd
, hAccelTable
, &msg
))
111 TranslateMessage(&msg
);
112 DispatchMessage(&msg
);
116 /* Load the common controls */
117 iccex
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
118 iccex
.dwICC
= ICC_STANDARD_CLASSES
| ICC_WIN95_CLASSES
;
119 InitCommonControlsEx(&iccex
);
121 SelectObject(hdcOffscreen
, hbmpOld
);
122 DeleteObject (hbmpOffscreen
);
123 DeleteDC(hdcOffscreen
);
125 return (int) msg
.wParam
;
128 ATOM
MyRegisterClass(HINSTANCE hInstance
)
132 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
133 wc
.lpfnWndProc
= WndProc
;
136 wc
.hInstance
= hInstance
;
137 wc
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_ICON
));
138 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
139 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
140 wc
.lpszMenuName
= NULL
; //MAKEINTRESOURCE(IDC_MAGNIFIER);
141 wc
.lpszClassName
= szWindowClass
;
143 return RegisterClass(&wc
);
146 void DoAppBarStuff(DWORD mode
)
149 APPBARDATA data
= {0};
150 data
.cbSize
= sizeof(data
);
151 data
.hWnd
= hMainWnd
;
152 data
.uCallbackMessage
= APPMSG_APPBAR
;
154 if (mode
== ABM_NEW
|| mode
== ABM_SETPOS
)
156 HWND hWndOrder
= HWND_BOTTOM
;
159 SystemParametersInfo(SPI_GETWORKAREA
, 0, &rcWorkArea
, 0);
163 SHAppBarMessage(ABM_NEW
, &data
);
165 switch(AppBarConfig
.uEdge
)
168 data
.rc
.top
= rcWorkArea
.top
;
169 data
.rc
.bottom
= rcWorkArea
.bottom
;
170 data
.rc
.left
= rcWorkArea
.left
;
171 data
.rc
.right
= data
.rc
.left
+ AppBarConfig
.appBarSizes
.left
;
174 data
.rc
.left
= rcWorkArea
.left
;
175 data
.rc
.right
= rcWorkArea
.right
;
176 data
.rc
.top
= rcWorkArea
.top
;
177 data
.rc
.bottom
= data
.rc
.top
+ AppBarConfig
.appBarSizes
.top
;
180 data
.rc
.top
= rcWorkArea
.top
;
181 data
.rc
.bottom
= rcWorkArea
.bottom
;
182 data
.rc
.right
= rcWorkArea
.left
;
183 data
.rc
.left
= data
.rc
.right
- AppBarConfig
.appBarSizes
.right
;
186 data
.rc
.left
= rcWorkArea
.left
;
187 data
.rc
.right
= rcWorkArea
.right
;
188 data
.rc
.bottom
= rcWorkArea
.bottom
;
189 data
.rc
.top
= data
.rc
.bottom
- AppBarConfig
.appBarSizes
.bottom
;
195 GetWindowRect(hMainWnd
, &data
.rc
);
198 data
.uEdge
= AppBarConfig
.uEdge
;
199 uState
= SHAppBarMessage(ABM_QUERYPOS
, &data
);
201 uState
= SHAppBarMessage(ABM_SETPOS
, &data
);
203 rcw
= data
.rc
.right
-data
.rc
.left
;
204 rch
= data
.rc
.bottom
-data
.rc
.top
;
206 uState
= SHAppBarMessage(ABM_GETSTATE
, &data
);
207 if(uState
& ABS_ALWAYSONTOP
)
208 hWndOrder
= HWND_TOPMOST
;
210 SetWindowPos(hMainWnd
, hWndOrder
, data
.rc
.left
, data
.rc
.top
, rcw
, rch
, SWP_SHOWWINDOW
|SWP_NOCOPYBITS
);
213 else if(mode
== ABM_GETSTATE
)
215 HWND hWndOrder
= HWND_BOTTOM
;
216 uState
= SHAppBarMessage(ABM_GETSTATE
, &data
);
217 if(uState
& ABS_ALWAYSONTOP
)
218 hWndOrder
= HWND_TOPMOST
;
219 SetWindowPos(hMainWnd
, hWndOrder
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
221 else if(mode
== ABM_ACTIVATE
)
223 SHAppBarMessage(ABM_ACTIVATE
, &data
);
225 else if(mode
== ABM_WINDOWPOSCHANGED
)
227 SHAppBarMessage(ABM_WINDOWPOSCHANGED
, &data
);
229 else if(mode
== ABM_REMOVE
)
231 SHAppBarMessage(ABM_REMOVE
, &data
);
235 void AttachAppBar(INT uEdge
)
237 if (AppBarConfig
.uEdge
== uEdge
)
240 if(AppBarConfig
.uEdge
< 0 && uEdge
>= 0)
242 SetWindowLongPtr(hMainWnd
, GWL_STYLE
, GetWindowLongPtr(hMainWnd
, GWL_STYLE
) & (~WS_CAPTION
));
244 else if(uEdge
< 0 && AppBarConfig
.uEdge
>=0)
246 SetWindowLongPtr(hMainWnd
, GWL_STYLE
, GetWindowLongPtr(hMainWnd
, GWL_STYLE
) | WS_CAPTION
);
247 SetWindowPos(hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_FRAMECHANGED
);
250 if(AppBarConfig
.uEdge
>= 0)
252 DoAppBarStuff(ABM_REMOVE
);
257 AppBarConfig
.uEdge
= uEdge
;
258 DoAppBarStuff(ABM_NEW
);
262 RECT rc
= AppBarConfig
.rcFloating
;
263 SetWindowPos(hMainWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
, 0);
266 AppBarConfig
.uEdge
= uEdge
;
269 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
272 DWORD exStyles
= WS_EX_TOOLWINDOW
| WS_EX_CONTROLPARENT
;
273 DWORD dwStyles
= WS_SIZEBOX
| WS_SYSMENU
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
| WS_POPUP
;
275 /* Load settings from registry */
278 rc
= AppBarConfig
.rcFloating
;
280 hInst
= hInstance
; // Store instance handle in our global variable
282 if (AppBarConfig
.uEdge
<0)
284 dwStyles
|= WS_CAPTION
;
285 exStyles
|= WS_EX_TOPMOST
;
288 /* Create the Window */
289 hMainWnd
= CreateWindowEx(
306 if (AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_NEW
);
307 else SetWindowPos(hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
309 // In Windows 2003's Magnifier, the "Start Minimized" setting
310 // refers exclusively to the options dialog, not the main window itself.
311 hOptionsDialog
= CreateDialog(hInstance
, MAKEINTRESOURCE(IDD_DIALOGOPTIONS
), hMainWnd
, OptionsProc
);
313 ShowWindow(hOptionsDialog
, SW_HIDE
);
315 ShowWindow(hOptionsDialog
, SW_SHOW
);
318 DialogBox(hInstance
, MAKEINTRESOURCE(IDD_WARNINGDIALOG
), hMainWnd
, WarningProc
);
325 if (!IsIconic(hMainWnd
))
327 /* Invalidate the client area forcing a WM_PAINT message */
328 InvalidateRgn(hMainWnd
, NULL
, TRUE
);
332 void GetBestOverlapWithMonitors(LPRECT rect
)
335 int rcWidth
, rcHeight
;
337 HMONITOR hMon
= MonitorFromRect(rect
, MONITOR_DEFAULTTONEAREST
);
339 info
.cbSize
= sizeof(info
);
341 GetMonitorInfo(hMon
, &info
);
343 rcMon
= info
.rcMonitor
;
347 rcWidth
= (rect
->right
- rect
->left
);
348 rcHeight
= (rect
->bottom
- rect
->top
);
350 if (rcLeft
< rcMon
.left
)
353 if (rcTop
< rcMon
.top
)
356 if (rcLeft
> (rcMon
.right
- rcWidth
))
357 rcLeft
= (rcMon
.right
- rcWidth
);
359 if (rcTop
> (rcMon
.bottom
- rcHeight
))
360 rcTop
= (rcMon
.bottom
- rcHeight
);
362 OffsetRect(rect
, (rcLeft
-rect
->left
), (rcTop
-rect
->top
));
367 HDC desktopHdc
= NULL
;
369 RECT sourceRect
, intersectedRect
;
370 RECT targetRect
, appRect
;
375 int AppWidth
, AppHeight
;
380 desktopHdc
= GetDC(0);
382 GetClientRect(hMainWnd
, &appRect
);
383 AppWidth
= (appRect
.right
- appRect
.left
);
384 AppHeight
= (appRect
.bottom
- appRect
.top
);
386 ZeroMemory(&cinfo
, sizeof(cinfo
));
387 ZeroMemory(&iinfo
, sizeof(iinfo
));
388 cinfo
.cbSize
= sizeof(cinfo
);
389 GetCursorInfo(&cinfo
);
390 GetIconInfo(cinfo
.hCursor
, &iinfo
);
392 targetRect
= appRect
;
393 ClientToScreen(hMainWnd
, (POINT
*)&targetRect
.left
);
394 ClientToScreen(hMainWnd
, (POINT
*)&targetRect
.right
);
396 if (bRecreateOffscreenDC
|| !hdcOffscreen
)
398 bRecreateOffscreenDC
= FALSE
;
402 SelectObject(hdcOffscreen
, hbmpOld
);
403 DeleteObject (hbmpOffscreen
);
404 DeleteDC(hdcOffscreen
);
407 sourceWidth
= AppWidth
/ uiZoom
;
408 sourceHeight
= AppHeight
/ uiZoom
;
410 /* Create a memory DC compatible with client area DC */
411 hdcOffscreen
= CreateCompatibleDC(desktopHdc
);
413 /* Create a bitmap compatible with the client area DC */
414 hbmpOffscreen
= CreateCompatibleBitmap(
419 /* Select our bitmap in memory DC and save the old one */
420 hbmpOld
= SelectObject(hdcOffscreen
, hbmpOffscreen
);
423 GetWindowRect(hDesktopWindow
, &sourceRect
);
424 sourceRect
.left
= (cp
.x
) - (sourceWidth
/2);
425 sourceRect
.top
= (cp
.y
) - (sourceHeight
/2);
426 sourceRect
.right
= sourceRect
.left
+ sourceWidth
;
427 sourceRect
.bottom
= sourceRect
.top
+ sourceHeight
;
429 GetBestOverlapWithMonitors(&sourceRect
);
431 /* Paint the screen bitmap to our in memory DC */
443 if (IntersectRect(&intersectedRect
, &sourceRect
, &targetRect
))
445 OffsetRect(&intersectedRect
, -sourceRect
.left
, -sourceRect
.top
);
446 FillRect(hdcOffscreen
, &intersectedRect
, GetStockObject(DC_BRUSH
));
449 /* Draw the mouse pointer in the right position */
452 pMouse
.x
- iinfo
.xHotspot
- sourceRect
.left
, // - 10,
453 pMouse
.y
- iinfo
.yHotspot
- sourceRect
.top
, // - 10,
456 /* Blast the stretched image from memory DC to window DC */
468 SRCCOPY
| NOMIRRORBITMAP
);
472 DeleteObject(iinfo
.hbmMask
);
474 DeleteObject(iinfo
.hbmColor
);
475 ReleaseDC(hDesktopWindow
, desktopHdc
);
478 void HandleNotifyIconMessage(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
485 PostMessage(hMainWnd
, WM_COMMAND
, IDM_OPTIONS
, 0);
489 TrackPopupMenu(notifyMenu
, 0, pt
.x
, pt
.y
, 0, hWnd
, NULL
);
494 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
502 BOOL hasMoved
= FALSE
;
504 GUITHREADINFO guiInfo
;
505 guiInfo
.cbSize
= sizeof(guiInfo
);
507 GetGUIThreadInfo(0, &guiInfo
);
513 //Get current mouse position
514 GetCursorPos (&pNewMouse
);
516 #define PointsAreEqual(pt1, pt2) (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))
518 //If mouse has moved ...
519 if (!PointsAreEqual(pMouse
, pNewMouse
))
521 //Update to new position
528 if(guiInfo
.hwndActive
!= hMainWnd
)
532 if (guiInfo
.hwndCaret
)
535 ptCaret
.x
= (guiInfo
.rcCaret
.left
+ guiInfo
.rcCaret
.right
) / 2;
536 ptCaret
.y
= (guiInfo
.rcCaret
.top
+ guiInfo
.rcCaret
.bottom
) / 2;
538 if ((pCaretWnd
!= guiInfo
.hwndCaret
) || !PointsAreEqual(pCaret
, ptCaret
))
540 //Update to new position
542 pCaretWnd
= guiInfo
.hwndCaret
;
545 ClientToScreen (guiInfo
.hwndCaret
, (LPPOINT
) &ptCaret
);
559 if(guiInfo
.hwndFocus
&& !guiInfo
.hwndCaret
)
564 //Get current control focus
565 GetWindowRect(guiInfo
.hwndFocus
, &activeRect
);
566 ptFocus
.x
= (activeRect
.left
+ activeRect
.right
) / 2;
567 ptFocus
.y
= (activeRect
.top
+ activeRect
.bottom
) / 2;
569 if((guiInfo
.hwndFocus
!= pFocusWnd
) || !PointsAreEqual(pFocus
, ptFocus
))
571 //Update to new position
573 pFocusWnd
= guiInfo
.hwndFocus
;
590 DWORD newTicks
= GetTickCount();
591 DWORD elapsed
= (newTicks
- lastTicks
);
592 if(elapsed
> REPAINT_SPEED
)
600 lastTicks
= GetTickCount();
609 wmId
= LOWORD(wParam
);
610 /* Parse the menu selections */
616 ShowWindow(hOptionsDialog
, SW_HIDE
);
620 ShowWindow(hOptionsDialog
, SW_SHOW
);
624 DialogBox(hInst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hWnd
, AboutProc
);
630 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
637 PAINTSTRUCT PaintStruct
;
639 dc
= BeginPaint(hWnd
, &PaintStruct
);
641 EndPaint(hWnd
, &PaintStruct
);
646 TrackPopupMenu(notifyMenu
, 0, GET_X_LPARAM(lParam
), GET_Y_LPARAM(lParam
), 0, hWnd
, NULL
);
656 GetWindowRect(hWnd
, &rc
);
657 ptDragOffset
.x
= pt
.x
- rc
.left
;
658 ptDragOffset
.y
= pt
.y
- rc
.top
;
660 nearEdge
= AppBarConfig
.uEdge
;
665 if(GetCapture() == hWnd
)
670 SystemParametersInfo(SPI_GETWORKAREA
, 0, &rcWorkArea
, 0);
672 GetWindowRect(hWnd
, &rc
);
674 if(AppBarConfig
.uEdge
>=0)
676 if (pt
.x
>= rcWorkArea
.left
&& pt
.x
<= rcWorkArea
.right
&&
677 pt
.y
>= rcWorkArea
.top
&& pt
.y
<= rcWorkArea
.bottom
)
682 GetWindowRect(hWnd
, &rc
);
683 ptDragOffset
.x
= (rc
.right
-rc
.left
)/2;
686 rc
.left
= pt
.x
- ptDragOffset
.x
;
687 rc
.top
= pt
.y
- ptDragOffset
.y
;
689 SetWindowPos(hWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, 0, 0, SWP_NOSIZE
);
694 if(pt
.x
<= rcWorkArea
.left
+8 && nearEdge
!= ABE_LEFT
)
696 AttachAppBar(ABE_LEFT
);
699 else if(pt
.y
<= rcWorkArea
.top
+8 && nearEdge
!= ABE_TOP
)
701 AttachAppBar(ABE_TOP
);
704 else if(pt
.x
>= rcWorkArea
.right
-8 && nearEdge
!= ABE_RIGHT
)
706 AttachAppBar(ABE_RIGHT
);
707 nearEdge
= ABE_RIGHT
;
709 else if(pt
.y
>= rcWorkArea
.bottom
-8 && nearEdge
!= ABE_BOTTOM
)
711 AttachAppBar(ABE_BOTTOM
);
712 nearEdge
= ABE_BOTTOM
;
716 rc
.left
= pt
.x
- ptDragOffset
.x
;
717 rc
.top
= pt
.y
- ptDragOffset
.y
;
719 SetWindowPos(hWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, 0, 0, SWP_NOSIZE
);
729 if(GetCapture() == hWnd
)
731 if (AppBarConfig
.uEdge
>=0)
732 DoAppBarStuff(ABM_GETSTATE
);
734 SetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
740 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_SETPOS
);
742 case WM_DISPLAYCHANGE
:
743 bRecreateOffscreenDC
= TRUE
;
748 // handle WM_ERASEBKGND by simply returning non-zero because we did all the drawing in WM_PAINT.
753 if (AppBarConfig
.uEdge
>= 0)
754 DoAppBarStuff(ABM_REMOVE
);
758 /* Save settings to registry */
761 /* Cleanup notification icon */
762 ZeroMemory(&nid
, sizeof(nid
));
763 nid
.cbSize
= sizeof(nid
);
764 nid
.uFlags
= NIF_MESSAGE
;
766 nid
.uCallbackMessage
= APPMSG_NOTIFYICON
;
767 Shell_NotifyIcon(NIM_DELETE
, &nid
);
768 DestroyIcon(notifyIcon
);
770 DestroyWindow(hOptionsDialog
);
780 /* Get the desktop window */
781 hDesktopWindow
= GetDesktopWindow();
784 SetTimer(hWnd
, 1, TIMER_SPEED
, NULL
);
786 /* Notification icon */
787 notifyIcon
= (HICON
)LoadImage(hInst
, MAKEINTRESOURCE(IDI_ICON
), IMAGE_ICON
, 16, 16, 0);
789 ZeroMemory(&nid
, sizeof(nid
));
790 nid
.cbSize
= sizeof(nid
);
791 nid
.uFlags
= NIF_ICON
| NIF_MESSAGE
;
793 nid
.uCallbackMessage
= APPMSG_NOTIFYICON
;
794 nid
.hIcon
= notifyIcon
;
795 Shell_NotifyIcon(NIM_ADD
, &nid
);
797 tempMenu
= LoadMenu(hInst
, MAKEINTRESOURCE(IDC_MAGNIFIER
));
798 notifyMenu
= GetSubMenu(tempMenu
, 0);
799 RemoveMenu(tempMenu
, 0, MF_BYPOSITION
);
800 DestroyMenu(tempMenu
);
808 case ABN_STATECHANGE
:
809 DoAppBarStuff(ABM_GETSTATE
);
812 DoAppBarStuff(ABM_SETPOS
);
814 case ABN_FULLSCREENAPP
:
818 DoAppBarStuff(ABM_GETSTATE
);
822 SetWindowPos(hMainWnd
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
825 case ABN_WINDOWARRANGE
:
827 ShowWindow(hMainWnd
, SW_HIDE
);
829 ShowWindow(hMainWnd
, SW_SHOW
);
835 case APPMSG_NOTIFYICON
:
836 HandleNotifyIconMessage(hWnd
, wParam
, lParam
);
840 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_ACTIVATE
);
843 case WM_WINDOWPOSCHANGED
:
844 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_WINDOWPOSCHANGED
);
852 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
855 INT_PTR CALLBACK
AboutProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
857 UNREFERENCED_PARAMETER(lParam
);
861 return (INT_PTR
)TRUE
;
864 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
866 EndDialog(hDlg
, LOWORD(wParam
));
867 return (INT_PTR
)TRUE
;
872 return (INT_PTR
)FALSE
;
875 INT_PTR CALLBACK
OptionsProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
877 UNREFERENCED_PARAMETER(lParam
);
881 bOptionsDialog
= wParam
;
885 /* Add the zoom items */
886 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("1"));
887 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("2"));
888 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("3"));
889 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("4"));
890 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("5"));
891 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("6"));
892 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("7"));
893 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("8"));
894 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("9"));
896 if (uiZoom
>= 1 && uiZoom
<= 9)
897 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_SETCURSEL
, uiZoom
- 1, 0);
900 SendDlgItemMessage(hDlg
,IDC_FOLLOWMOUSECHECK
,BM_SETCHECK
, wParam
,0);
903 SendDlgItemMessage(hDlg
,IDC_FOLLOWKEYBOARDCHECK
,BM_SETCHECK
, wParam
,0);
906 SendDlgItemMessage(hDlg
,IDC_FOLLOWTEXTEDITINGCHECK
,BM_SETCHECK
, wParam
,0);
909 SendDlgItemMessage(hDlg
,IDC_INVERTCOLORSCHECK
,BM_SETCHECK
, wParam
,0);
912 SendDlgItemMessage(hDlg
,IDC_STARTMINIMIZEDCHECK
,BM_SETCHECK
, wParam
,0);
915 SendDlgItemMessage(hDlg
,IDC_SHOWMAGNIFIERCHECK
,BM_SETCHECK
, wParam
,0);
917 return (INT_PTR
)TRUE
;
921 switch (LOWORD(wParam
))
925 ShowWindow(hDlg
, SW_HIDE
);
926 return (INT_PTR
)TRUE
;
928 case IDC_BUTTON_HELP
:
930 MessageBox(hDlg
, TEXT("Magnifier help not available yet!") , TEXT("Help") , MB_OK
);
933 if (HIWORD(wParam
) == CBN_SELCHANGE
)
935 HWND hCombo
= GetDlgItem(hDlg
,IDC_ZOOM
);
936 TCHAR currentZoomValue
[2] = TEXT("");
938 /* Get index of current selection and the text of that selection */
939 int currentSelectionIndex
= ComboBox_GetCurSel(hCombo
);
940 ComboBox_GetLBText(hCombo
, currentSelectionIndex
, currentZoomValue
);
941 uiZoom
= (UINT
)_ttoi(currentZoomValue
);
942 /* The zoom factor cannot be smaller than 1 (and not zero) or greater than 9 */
943 if (uiZoom
< 1 || uiZoom
> 9)
946 /* Trigger the Draw function to rezoom (which will be set false automatically after rezooming) */
947 bRecreateOffscreenDC
= TRUE
;
949 /* Update the magnifier UI */
953 case IDC_INVERTCOLORSCHECK
:
954 bInvertColors
= IsDlgButtonChecked(hDlg
, IDC_INVERTCOLORSCHECK
);
957 case IDC_FOLLOWMOUSECHECK
:
958 bFollowMouse
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWMOUSECHECK
);
960 case IDC_FOLLOWKEYBOARDCHECK
:
961 bFollowFocus
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWKEYBOARDCHECK
);
963 case IDC_FOLLOWTEXTEDITINGCHECK
:
964 bFollowCaret
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWTEXTEDITINGCHECK
);
966 case IDC_STARTMINIMIZEDCHECK
:
967 bStartMinimized
= IsDlgButtonChecked(hDlg
, IDC_STARTMINIMIZEDCHECK
);
969 case IDC_SHOWMAGNIFIER
:
970 bShowMagnifier
= IsDlgButtonChecked(hDlg
, IDC_SHOWMAGNIFIERCHECK
);
972 ShowWindow (hMainWnd
, SW_SHOW
);
974 ShowWindow (hMainWnd
, SW_HIDE
);
979 return (INT_PTR
)FALSE
;
982 INT_PTR CALLBACK
WarningProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
984 UNREFERENCED_PARAMETER(lParam
);
989 return (INT_PTR
)TRUE
;
992 switch (LOWORD(wParam
))
994 case IDC_SHOWWARNINGCHECK
:
995 bShowWarning
= !IsDlgButtonChecked(hDlg
, IDC_SHOWWARNINGCHECK
);
998 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
1000 EndDialog(hDlg
, LOWORD(wParam
));
1001 return (INT_PTR
)TRUE
;
1006 return (INT_PTR
)FALSE
;