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"
24 #define APPMSG_NOTIFYICON (WM_APP+1)
25 #define APPMSG_APPBAR (WM_APP+2)
27 const TCHAR szWindowClass
[] = TEXT("MAGNIFIER");
29 /* Global Variables */
33 #define MAX_LOADSTRING 100
34 TCHAR szTitle
[MAX_LOADSTRING
];
37 #define REPAINT_SPEED 100
41 HWND hDesktopWindow
= NULL
;
47 BOOL bOptionsDialog
= FALSE
;
48 BOOL bRecreateOffscreenDC
= TRUE
;
50 LONG sourceHeight
= 0;
51 HDC hdcOffscreen
= NULL
;
52 HBITMAP hbmpOffscreen
= NULL
;
57 /* Current magnified area */
67 ATOM
MyRegisterClass(HINSTANCE hInstance
);
68 BOOL
InitInstance(HINSTANCE
, int);
69 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
70 INT_PTR CALLBACK
AboutProc(HWND
, UINT
, WPARAM
, LPARAM
);
71 INT_PTR CALLBACK
OptionsProc(HWND
, UINT
, WPARAM
, LPARAM
);
72 INT_PTR CALLBACK
WarningProc(HWND
, UINT
, WPARAM
, LPARAM
);
74 int WINAPI
WinMain( HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPSTR lpCmdLine
, int nCmdShow
)
79 UNREFERENCED_PARAMETER(hPrevInstance
);
80 UNREFERENCED_PARAMETER(lpCmdLine
);
82 switch (GetUserDefaultUILanguage())
84 case MAKELANGID(LANG_HEBREW
, SUBLANG_DEFAULT
):
85 SetProcessDefaultLayout(LAYOUT_RTL
);
92 /* Initialize global strings */
93 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
94 MyRegisterClass(hInstance
);
96 /* Perform application initialization */
97 if (!InitInstance(hInstance
, nCmdShow
))
100 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDC_MAGNIFIER
));
102 /* Main message loop */
103 while (GetMessage(&msg
, NULL
, 0, 0))
105 if (!TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
))
107 TranslateMessage(&msg
);
108 DispatchMessage(&msg
);
113 SelectObject(hdcOffscreen
, hbmpOld
);
114 DeleteObject (hbmpOffscreen
);
115 DeleteDC(hdcOffscreen
);
117 return (int) msg
.wParam
;
120 ATOM
MyRegisterClass(HINSTANCE hInstance
)
124 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
125 wc
.lpfnWndProc
= WndProc
;
128 wc
.hInstance
= hInstance
;
129 wc
.hIcon
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_ICON
));
130 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
131 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
132 wc
.lpszMenuName
= NULL
; //MAKEINTRESOURCE(IDC_MAGNIFIER);
133 wc
.lpszClassName
= szWindowClass
;
135 return RegisterClass(&wc
);
138 void DoAppBarStuff(DWORD mode
)
141 APPBARDATA data
= {0};
142 data
.cbSize
= sizeof(data
);
143 data
.hWnd
= hMainWnd
;
144 data
.uCallbackMessage
= APPMSG_APPBAR
;
146 if (mode
== ABM_NEW
|| mode
== ABM_SETPOS
)
148 HWND hWndOrder
= HWND_BOTTOM
;
151 SystemParametersInfo(SPI_GETWORKAREA
, 0, &rcWorkArea
, 0);
155 SHAppBarMessage(ABM_NEW
, &data
);
157 switch(AppBarConfig
.uEdge
)
160 data
.rc
.top
= rcWorkArea
.top
;
161 data
.rc
.bottom
= rcWorkArea
.bottom
;
162 data
.rc
.left
= rcWorkArea
.left
;
163 data
.rc
.right
= data
.rc
.left
+ AppBarConfig
.appBarSizes
.left
;
166 data
.rc
.left
= rcWorkArea
.left
;
167 data
.rc
.right
= rcWorkArea
.right
;
168 data
.rc
.top
= rcWorkArea
.top
;
169 data
.rc
.bottom
= data
.rc
.top
+ AppBarConfig
.appBarSizes
.top
;
172 data
.rc
.top
= rcWorkArea
.top
;
173 data
.rc
.bottom
= rcWorkArea
.bottom
;
174 data
.rc
.right
= rcWorkArea
.left
;
175 data
.rc
.left
= data
.rc
.right
- AppBarConfig
.appBarSizes
.right
;
178 data
.rc
.left
= rcWorkArea
.left
;
179 data
.rc
.right
= rcWorkArea
.right
;
180 data
.rc
.bottom
= rcWorkArea
.bottom
;
181 data
.rc
.top
= data
.rc
.bottom
- AppBarConfig
.appBarSizes
.bottom
;
187 GetWindowRect(hMainWnd
, &data
.rc
);
190 data
.uEdge
= AppBarConfig
.uEdge
;
191 uState
= SHAppBarMessage(ABM_QUERYPOS
, &data
);
193 uState
= SHAppBarMessage(ABM_SETPOS
, &data
);
195 rcw
= data
.rc
.right
-data
.rc
.left
;
196 rch
= data
.rc
.bottom
-data
.rc
.top
;
198 uState
= SHAppBarMessage(ABM_GETSTATE
, &data
);
199 if(uState
& ABS_ALWAYSONTOP
)
200 hWndOrder
= HWND_TOPMOST
;
202 SetWindowPos(hMainWnd
, hWndOrder
, data
.rc
.left
, data
.rc
.top
, rcw
, rch
, SWP_SHOWWINDOW
|SWP_NOCOPYBITS
);
205 else if(mode
== ABM_GETSTATE
)
207 HWND hWndOrder
= HWND_BOTTOM
;
208 uState
= SHAppBarMessage(ABM_GETSTATE
, &data
);
209 if(uState
& ABS_ALWAYSONTOP
)
210 hWndOrder
= HWND_TOPMOST
;
211 SetWindowPos(hMainWnd
, hWndOrder
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
213 else if(mode
== ABM_ACTIVATE
)
215 SHAppBarMessage(ABM_ACTIVATE
, &data
);
217 else if(mode
== ABM_WINDOWPOSCHANGED
)
219 SHAppBarMessage(ABM_WINDOWPOSCHANGED
, &data
);
221 else if(mode
== ABM_REMOVE
)
223 SHAppBarMessage(ABM_REMOVE
, &data
);
227 void AttachAppBar(INT uEdge
)
229 if (AppBarConfig
.uEdge
== uEdge
)
232 if(AppBarConfig
.uEdge
< 0 && uEdge
>= 0)
234 SetWindowLongPtr(hMainWnd
, GWL_STYLE
, GetWindowLongPtr(hMainWnd
, GWL_STYLE
) & (~WS_CAPTION
));
236 else if(uEdge
< 0 && AppBarConfig
.uEdge
>=0)
238 SetWindowLongPtr(hMainWnd
, GWL_STYLE
, GetWindowLongPtr(hMainWnd
, GWL_STYLE
) | WS_CAPTION
);
239 SetWindowPos(hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_FRAMECHANGED
);
242 if(AppBarConfig
.uEdge
>= 0)
244 DoAppBarStuff(ABM_REMOVE
);
249 AppBarConfig
.uEdge
= uEdge
;
250 DoAppBarStuff(ABM_NEW
);
254 RECT rc
= AppBarConfig
.rcFloating
;
255 SetWindowPos(hMainWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
, 0);
258 AppBarConfig
.uEdge
= uEdge
;
261 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
264 DWORD exStyles
= WS_EX_TOOLWINDOW
| WS_EX_CONTROLPARENT
;
265 DWORD dwStyles
= WS_SIZEBOX
| WS_SYSMENU
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
| WS_POPUP
;
267 /* Load settings from registry */
270 rc
= AppBarConfig
.rcFloating
;
272 hInst
= hInstance
; // Store instance handle in our global variable
274 if (AppBarConfig
.uEdge
<0)
276 dwStyles
|= WS_CAPTION
;
277 exStyles
|= WS_EX_TOPMOST
;
280 /* Create the Window */
281 hMainWnd
= CreateWindowEx(
298 if (AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_NEW
);
299 else SetWindowPos(hMainWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
301 // In Windows 2003's Magnifier, the "Start Minimized" setting
302 // refers exclusively to the options dialog, not the main window itself.
303 hOptionsDialog
= CreateDialog(hInstance
, MAKEINTRESOURCE(IDD_DIALOGOPTIONS
), hMainWnd
, OptionsProc
);
305 ShowWindow(hOptionsDialog
, SW_HIDE
);
307 ShowWindow(hOptionsDialog
, SW_SHOW
);
310 DialogBox(hInstance
, MAKEINTRESOURCE(IDD_WARNINGDIALOG
), hMainWnd
, WarningProc
);
317 if (!IsIconic(hMainWnd
))
319 /* Invalidate the client area forcing a WM_PAINT message */
320 InvalidateRgn(hMainWnd
, NULL
, TRUE
);
324 void GetBestOverlapWithMonitors(LPRECT rect
)
327 int rcWidth
, rcHeight
;
329 HMONITOR hMon
= MonitorFromRect(rect
, MONITOR_DEFAULTTONEAREST
);
331 info
.cbSize
= sizeof(info
);
333 GetMonitorInfo(hMon
, &info
);
335 rcMon
= info
.rcMonitor
;
339 rcWidth
= (rect
->right
- rect
->left
);
340 rcHeight
= (rect
->bottom
- rect
->top
);
342 if (rcLeft
< rcMon
.left
)
345 if (rcTop
< rcMon
.top
)
348 if (rcLeft
> (rcMon
.right
- rcWidth
))
349 rcLeft
= (rcMon
.right
- rcWidth
);
351 if (rcTop
> (rcMon
.bottom
- rcHeight
))
352 rcTop
= (rcMon
.bottom
- rcHeight
);
354 OffsetRect(rect
, (rcLeft
-rect
->left
), (rcTop
-rect
->top
));
359 HDC desktopHdc
= NULL
;
361 RECT sourceRect
, intersectedRect
;
362 RECT targetRect
, appRect
;
367 int AppWidth
, AppHeight
;
372 desktopHdc
= GetDC(0);
374 GetClientRect(hMainWnd
, &appRect
);
375 AppWidth
= (appRect
.right
- appRect
.left
);
376 AppHeight
= (appRect
.bottom
- appRect
.top
);
378 ZeroMemory(&cinfo
, sizeof(cinfo
));
379 ZeroMemory(&iinfo
, sizeof(iinfo
));
380 cinfo
.cbSize
= sizeof(cinfo
);
381 GetCursorInfo(&cinfo
);
382 GetIconInfo(cinfo
.hCursor
, &iinfo
);
384 targetRect
= appRect
;
385 ClientToScreen(hMainWnd
, (POINT
*)&targetRect
.left
);
386 ClientToScreen(hMainWnd
, (POINT
*)&targetRect
.right
);
388 if (bRecreateOffscreenDC
|| !hdcOffscreen
)
390 bRecreateOffscreenDC
= FALSE
;
394 SelectObject(hdcOffscreen
, hbmpOld
);
395 DeleteObject (hbmpOffscreen
);
396 DeleteDC(hdcOffscreen
);
399 sourceWidth
= AppWidth
/ iZoom
;
400 sourceHeight
= AppHeight
/ iZoom
;
402 /* Create a memory DC compatible with client area DC */
403 hdcOffscreen
= CreateCompatibleDC(desktopHdc
);
405 /* Create a bitmap compatible with the client area DC */
406 hbmpOffscreen
= CreateCompatibleBitmap(
411 /* Select our bitmap in memory DC and save the old one */
412 hbmpOld
= SelectObject(hdcOffscreen
, hbmpOffscreen
);
415 GetWindowRect(hDesktopWindow
, &sourceRect
);
416 sourceRect
.left
= (cp
.x
) - (sourceWidth
/2);
417 sourceRect
.top
= (cp
.y
) - (sourceHeight
/2);
418 sourceRect
.right
= sourceRect
.left
+ sourceWidth
;
419 sourceRect
.bottom
= sourceRect
.top
+ sourceHeight
;
421 GetBestOverlapWithMonitors(&sourceRect
);
423 /* Paint the screen bitmap to our in memory DC */
435 if (IntersectRect(&intersectedRect
, &sourceRect
, &targetRect
))
437 OffsetRect(&intersectedRect
, -sourceRect
.left
, -sourceRect
.top
);
438 FillRect(hdcOffscreen
, &intersectedRect
, GetStockObject(DC_BRUSH
));
441 /* Draw the mouse pointer in the right position */
444 pMouse
.x
- iinfo
.xHotspot
- sourceRect
.left
, // - 10,
445 pMouse
.y
- iinfo
.yHotspot
- sourceRect
.top
, // - 10,
448 /* Blast the stretched image from memory DC to window DC */
460 SRCCOPY
| NOMIRRORBITMAP
);
464 DeleteObject(iinfo
.hbmMask
);
466 DeleteObject(iinfo
.hbmColor
);
467 ReleaseDC(hDesktopWindow
, desktopHdc
);
470 void HandleNotifyIconMessage(HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
477 PostMessage(hMainWnd
, WM_COMMAND
, IDM_OPTIONS
, 0);
481 TrackPopupMenu(notifyMenu
, 0, pt
.x
, pt
.y
, 0, hWnd
, NULL
);
486 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
494 BOOL hasMoved
= FALSE
;
496 GUITHREADINFO guiInfo
;
497 guiInfo
.cbSize
= sizeof(guiInfo
);
499 GetGUIThreadInfo(0, &guiInfo
);
505 //Get current mouse position
506 GetCursorPos (&pNewMouse
);
508 #define PointsAreEqual(pt1, pt2) (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))
510 //If mouse has moved ...
511 if (!PointsAreEqual(pMouse
, pNewMouse
))
513 //Update to new position
520 if(guiInfo
.hwndActive
!= hMainWnd
)
524 if (guiInfo
.hwndCaret
)
527 ptCaret
.x
= (guiInfo
.rcCaret
.left
+ guiInfo
.rcCaret
.right
) / 2;
528 ptCaret
.y
= (guiInfo
.rcCaret
.top
+ guiInfo
.rcCaret
.bottom
) / 2;
530 if ((pCaretWnd
!= guiInfo
.hwndCaret
) || !PointsAreEqual(pCaret
, ptCaret
))
532 //Update to new position
534 pCaretWnd
= guiInfo
.hwndCaret
;
537 ClientToScreen (guiInfo
.hwndCaret
, (LPPOINT
) &ptCaret
);
551 if(guiInfo
.hwndFocus
&& !guiInfo
.hwndCaret
)
556 //Get current control focus
557 GetWindowRect(guiInfo
.hwndFocus
, &activeRect
);
558 ptFocus
.x
= (activeRect
.left
+ activeRect
.right
) / 2;
559 ptFocus
.y
= (activeRect
.top
+ activeRect
.bottom
) / 2;
561 if((guiInfo
.hwndFocus
!= pFocusWnd
) || !PointsAreEqual(pFocus
, ptFocus
))
563 //Update to new position
565 pFocusWnd
= guiInfo
.hwndFocus
;
582 DWORD newTicks
= GetTickCount();
583 DWORD elapsed
= (newTicks
- lastTicks
);
584 if(elapsed
> REPAINT_SPEED
)
592 lastTicks
= GetTickCount();
601 wmId
= LOWORD(wParam
);
602 /* Parse the menu selections */
608 ShowWindow(hOptionsDialog
, SW_HIDE
);
612 ShowWindow(hOptionsDialog
, SW_SHOW
);
616 DialogBox(hInst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hWnd
, AboutProc
);
622 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
629 PAINTSTRUCT PaintStruct
;
631 dc
= BeginPaint(hWnd
, &PaintStruct
);
633 EndPaint(hWnd
, &PaintStruct
);
638 TrackPopupMenu(notifyMenu
, 0, GET_X_LPARAM(lParam
), GET_Y_LPARAM(lParam
), 0, hWnd
, NULL
);
648 GetWindowRect(hWnd
, &rc
);
649 ptDragOffset
.x
= pt
.x
- rc
.left
;
650 ptDragOffset
.y
= pt
.y
- rc
.top
;
652 nearEdge
= AppBarConfig
.uEdge
;
657 if(GetCapture() == hWnd
)
662 SystemParametersInfo(SPI_GETWORKAREA
, 0, &rcWorkArea
, 0);
664 GetWindowRect(hWnd
, &rc
);
666 if(AppBarConfig
.uEdge
>=0)
668 if (pt
.x
>= rcWorkArea
.left
&& pt
.x
<= rcWorkArea
.right
&&
669 pt
.y
>= rcWorkArea
.top
&& pt
.y
<= rcWorkArea
.bottom
)
674 GetWindowRect(hWnd
, &rc
);
675 ptDragOffset
.x
= (rc
.right
-rc
.left
)/2;
678 rc
.left
= pt
.x
- ptDragOffset
.x
;
679 rc
.top
= pt
.y
- ptDragOffset
.y
;
681 SetWindowPos(hWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, 0, 0, SWP_NOSIZE
);
686 if(pt
.x
<= rcWorkArea
.left
+8 && nearEdge
!= ABE_LEFT
)
688 AttachAppBar(ABE_LEFT
);
691 else if(pt
.y
<= rcWorkArea
.top
+8 && nearEdge
!= ABE_TOP
)
693 AttachAppBar(ABE_TOP
);
696 else if(pt
.x
>= rcWorkArea
.right
-8 && nearEdge
!= ABE_RIGHT
)
698 AttachAppBar(ABE_RIGHT
);
699 nearEdge
= ABE_RIGHT
;
701 else if(pt
.y
>= rcWorkArea
.bottom
-8 && nearEdge
!= ABE_BOTTOM
)
703 AttachAppBar(ABE_BOTTOM
);
704 nearEdge
= ABE_BOTTOM
;
708 rc
.left
= pt
.x
- ptDragOffset
.x
;
709 rc
.top
= pt
.y
- ptDragOffset
.y
;
711 SetWindowPos(hWnd
, HWND_TOPMOST
, rc
.left
, rc
.top
, 0, 0, SWP_NOSIZE
);
721 if(GetCapture() == hWnd
)
723 if (AppBarConfig
.uEdge
>=0)
724 DoAppBarStuff(ABM_GETSTATE
);
726 SetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
731 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_SETPOS
);
733 case WM_DISPLAYCHANGE
:
734 bRecreateOffscreenDC
= TRUE
;
739 // handle WM_ERASEBKGND by simply returning non-zero because we did all the drawing in WM_PAINT.
743 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_REMOVE
);
745 /* Save settings to registry */
750 /* Cleanup notification icon */
751 ZeroMemory(&nid
, sizeof(nid
));
752 nid
.cbSize
= sizeof(nid
);
753 nid
.uFlags
= NIF_MESSAGE
;
755 nid
.uCallbackMessage
= APPMSG_NOTIFYICON
;
756 Shell_NotifyIcon(NIM_DELETE
, &nid
);
758 DestroyIcon(notifyIcon
);
760 DestroyWindow(hOptionsDialog
);
767 /* Get the desktop window */
768 hDesktopWindow
= GetDesktopWindow();
771 SetTimer (hWnd
, 1, TIMER_SPEED
, NULL
);
773 /* Notification icon */
774 notifyIcon
= (HICON
)LoadImage(hInst
, MAKEINTRESOURCE(IDI_ICON
), IMAGE_ICON
, 16, 16, 0);
776 ZeroMemory(&nid
, sizeof(nid
));
777 nid
.cbSize
= sizeof(nid
);
778 nid
.uFlags
= NIF_ICON
| NIF_MESSAGE
;
780 nid
.uCallbackMessage
= APPMSG_NOTIFYICON
;
781 nid
.hIcon
= notifyIcon
;
782 Shell_NotifyIcon(NIM_ADD
, &nid
);
784 tempMenu
= LoadMenu(hInst
, MAKEINTRESOURCE(IDC_MAGNIFIER
));
785 notifyMenu
= GetSubMenu(tempMenu
, 0);
786 RemoveMenu(tempMenu
, 0, MF_BYPOSITION
);
787 DestroyMenu(tempMenu
);
795 case ABN_STATECHANGE
:
796 DoAppBarStuff(ABM_GETSTATE
);
799 DoAppBarStuff(ABM_SETPOS
);
801 case ABN_FULLSCREENAPP
:
805 DoAppBarStuff(ABM_GETSTATE
);
809 SetWindowPos(hMainWnd
, HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
812 case ABN_WINDOWARRANGE
:
814 ShowWindow(hMainWnd
, SW_HIDE
);
816 ShowWindow(hMainWnd
, SW_SHOW
);
821 case APPMSG_NOTIFYICON
:
822 HandleNotifyIconMessage(hWnd
, wParam
, lParam
);
826 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_ACTIVATE
);
829 case WM_WINDOWPOSCHANGED
:
830 if(AppBarConfig
.uEdge
>=0) DoAppBarStuff(ABM_WINDOWPOSCHANGED
);
838 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
841 INT_PTR CALLBACK
AboutProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
843 UNREFERENCED_PARAMETER(lParam
);
847 return (INT_PTR
)TRUE
;
850 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
852 EndDialog(hDlg
, LOWORD(wParam
));
853 return (INT_PTR
)TRUE
;
858 return (INT_PTR
)FALSE
;
861 INT_PTR CALLBACK
OptionsProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
863 UNREFERENCED_PARAMETER(lParam
);
867 bOptionsDialog
= wParam
;
871 // Add the zoom items...
872 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("1"));
873 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("2"));
874 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("3"));
875 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("4"));
876 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("5"));
877 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("6"));
878 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("7"));
879 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_ADDSTRING
, 0, (LPARAM
)("8"));
881 SendDlgItemMessage(hDlg
, IDC_ZOOM
, CB_SETCURSEL
, iZoom
- 1, 0);
884 SendDlgItemMessage(hDlg
,IDC_FOLLOWMOUSECHECK
,BM_SETCHECK
, wParam
,0);
887 SendDlgItemMessage(hDlg
,IDC_FOLLOWKEYBOARDCHECK
,BM_SETCHECK
, wParam
,0);
890 SendDlgItemMessage(hDlg
,IDC_FOLLOWTEXTEDITINGCHECK
,BM_SETCHECK
, wParam
,0);
893 SendDlgItemMessage(hDlg
,IDC_INVERTCOLORSCHECK
,BM_SETCHECK
, wParam
,0);
896 SendDlgItemMessage(hDlg
,IDC_STARTMINIMIZEDCHECK
,BM_SETCHECK
, wParam
,0);
899 SendDlgItemMessage(hDlg
,IDC_SHOWMAGNIFIERCHECK
,BM_SETCHECK
, wParam
,0);
901 return (INT_PTR
)TRUE
;
905 switch (LOWORD(wParam
))
909 ShowWindow(hDlg
, SW_HIDE
);
910 return (INT_PTR
)TRUE
;
912 case IDC_BUTTON_HELP
:
914 MessageBox(hDlg
, TEXT("Magnifier help not available yet!") , TEXT("Help") , MB_OK
);
917 if (HIWORD(wParam
) == CBN_SELCHANGE
)
919 HWND hCombo
= GetDlgItem(hDlg
,IDC_ZOOM
);
921 /* Get index of current selection and the text of that selection */
922 iZoom
= SendMessage( hCombo
, CB_GETCURSEL
, (WPARAM
) wParam
, (LPARAM
) lParam
) + 1;
924 /* Update the magnifier UI */
928 case IDC_INVERTCOLORSCHECK
:
929 bInvertColors
= IsDlgButtonChecked(hDlg
, IDC_INVERTCOLORSCHECK
);
932 case IDC_FOLLOWMOUSECHECK
:
933 bFollowMouse
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWMOUSECHECK
);
935 case IDC_FOLLOWKEYBOARDCHECK
:
936 bFollowFocus
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWKEYBOARDCHECK
);
938 case IDC_FOLLOWTEXTEDITINGCHECK
:
939 bFollowCaret
= IsDlgButtonChecked(hDlg
, IDC_FOLLOWTEXTEDITINGCHECK
);
941 case IDC_STARTMINIMIZEDCHECK
:
942 bStartMinimized
= IsDlgButtonChecked(hDlg
, IDC_STARTMINIMIZEDCHECK
);
944 case IDC_SHOWMAGNIFIER
:
945 bShowMagnifier
= IsDlgButtonChecked(hDlg
, IDC_SHOWMAGNIFIERCHECK
);
947 ShowWindow (hMainWnd
, SW_SHOW
);
949 ShowWindow (hMainWnd
, SW_HIDE
);
954 return (INT_PTR
)FALSE
;
957 INT_PTR CALLBACK
WarningProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
959 UNREFERENCED_PARAMETER(lParam
);
964 return (INT_PTR
)TRUE
;
967 switch (LOWORD(wParam
))
969 case IDC_SHOWWARNINGCHECK
:
970 bShowWarning
= !IsDlgButtonChecked(hDlg
, IDC_SHOWWARNINGCHECK
);
973 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
975 EndDialog(hDlg
, LOWORD(wParam
));
976 return (INT_PTR
)TRUE
;
981 return (INT_PTR
)FALSE
;