ReactOS  0.4.11-dev-946-g431643b
magnifier.c File Reference
#include "magnifier.h"
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winnls.h>
#include <shellapi.h>
#include <windowsx.h>
#include <stdlib.h>
#include <tchar.h>
#include "resource.h"
Include dependency graph for magnifier.c:

Go to the source code of this file.

Macros

#define APPMSG_NOTIFYICON   (WM_APP+1)
 
#define APPMSG_APPBAR   (WM_APP+2)
 
#define MAX_LOADSTRING   100
 
#define TIMER_SPEED   1
 
#define REPAINT_SPEED   100
 
#define PointsAreEqual(pt1, pt2)   (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))
 

Functions

ATOM MyRegisterClass (HINSTANCE hInstance)
 
BOOL InitInstance (HINSTANCE, int)
 
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK AboutProc (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK OptionsProc (HWND, UINT, WPARAM, LPARAM)
 
INT_PTR CALLBACK WarningProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 
void DoAppBarStuff (DWORD mode)
 
void AttachAppBar (INT uEdge)
 
void Refresh ()
 
void GetBestOverlapWithMonitors (LPRECT rect)
 
void Draw (HDC aDc)
 
void HandleNotifyIconMessage (HWND hWnd, WPARAM wParam, LPARAM lParam)
 

Variables

const TCHAR szWindowClass [] = TEXT("MAGNIFIER")
 
HINSTANCE hInst
 
HWND hMainWnd
 
TCHAR szTitle [MAX_LOADSTRING]
 
DWORD lastTicks = 0
 
HWND hDesktopWindow = NULL
 
NOTIFYICONDATA nid
 
HICON notifyIcon
 
HMENU notifyMenu
 
HWND hOptionsDialog
 
BOOL bOptionsDialog = FALSE
 
BOOL bRecreateOffscreenDC = TRUE
 
LONG sourceWidth = 0
 
LONG sourceHeight = 0
 
HDC hdcOffscreen = NULL
 
HBITMAP hbmpOffscreen = NULL
 
HANDLE hbmpOld
 
POINT ptDragOffset
 
INT nearEdge
 
POINT cp
 
POINT pMouse
 
POINT pCaret
 
POINT pFocus
 
HWND pCaretWnd
 
HWND pFocusWnd
 

Macro Definition Documentation

◆ APPMSG_APPBAR

#define APPMSG_APPBAR   (WM_APP+2)

Definition at line 27 of file magnifier.c.

Referenced by DoAppBarStuff(), and WndProc().

◆ APPMSG_NOTIFYICON

#define APPMSG_NOTIFYICON   (WM_APP+1)

Definition at line 26 of file magnifier.c.

Referenced by WndProc().

◆ MAX_LOADSTRING

#define MAX_LOADSTRING   100

Definition at line 35 of file magnifier.c.

Referenced by WinMain().

◆ PointsAreEqual

#define PointsAreEqual (   pt1,
  pt2 
)    (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))

Referenced by WndProc().

◆ REPAINT_SPEED

#define REPAINT_SPEED   100

Definition at line 39 of file magnifier.c.

Referenced by WndProc().

◆ TIMER_SPEED

#define TIMER_SPEED   1

Definition at line 38 of file magnifier.c.

Referenced by WndProc().

Function Documentation

◆ AboutProc()

INT_PTR CALLBACK AboutProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 849 of file magnifier.c.

Referenced by WndProc().

850 {
852  switch (message)
853  {
854  case WM_INITDIALOG:
855  return (INT_PTR)TRUE;
856 
857  case WM_COMMAND:
858  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
859  {
860  EndDialog(hDlg, LOWORD(wParam));
861  return (INT_PTR)TRUE;
862  }
863  break;
864  }
865 
866  return (INT_PTR)FALSE;
867 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
int32_t INT_PTR
Definition: typedefs.h:62
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define WM_COMMAND
Definition: winuser.h:1716
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ AttachAppBar()

void AttachAppBar ( INT  uEdge)

Definition at line 229 of file magnifier.c.

Referenced by WndProc().

230 {
231  if (AppBarConfig.uEdge == uEdge)
232  return;
233 
234  if(AppBarConfig.uEdge < 0 && uEdge >= 0)
235  {
237  }
238  else if(uEdge < 0 && AppBarConfig.uEdge>=0)
239  {
242  }
243 
244  if(AppBarConfig.uEdge >= 0)
245  {
247  }
248 
249  if (uEdge >=0)
250  {
251  AppBarConfig.uEdge = uEdge;
253  }
254  else
255  {
256  RECT rc = AppBarConfig.rcFloating;
257  SetWindowPos(hMainWnd, HWND_TOPMOST, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
258  }
259 
260  AppBarConfig.uEdge = uEdge;
261 }
LONG top
Definition: windef.h:297
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:27
#define HWND_TOPMOST
Definition: winuser.h:1194
LONG left
Definition: windef.h:296
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:140
LONG right
Definition: windef.h:298
#define SetWindowLongPtr
Definition: treelist.c:70
#define WS_CAPTION
Definition: pedump.c:624
#define ABM_NEW
Definition: shellapi.h:59
HWND hMainWnd
Definition: magnifier.c:33
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
#define SWP_NOSIZE
Definition: winuser.h:1230
#define GWL_STYLE
Definition: winuser.h:846
#define ABM_REMOVE
Definition: shellapi.h:60
LONG bottom
Definition: windef.h:299
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define GetWindowLongPtr
Definition: treelist.c:73

◆ DoAppBarStuff()

void DoAppBarStuff ( DWORD  mode)

Definition at line 140 of file magnifier.c.

Referenced by AttachAppBar(), InitInstance(), and WndProc().

141 {
142  UINT uState;
143  APPBARDATA data = {0};
144  data.cbSize = sizeof(data);
145  data.hWnd = hMainWnd;
147 
148  if (mode == ABM_NEW || mode == ABM_SETPOS)
149  {
150  HWND hWndOrder = HWND_BOTTOM;
151  int rcw, rch;
152  RECT rcWorkArea;
153  SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
154 
155  if(mode == ABM_NEW)
156  {
157  SHAppBarMessage(ABM_NEW, &data);
158 
159  switch(AppBarConfig.uEdge)
160  {
161  case ABE_LEFT:
162  data.rc.top = rcWorkArea.top;
163  data.rc.bottom = rcWorkArea.bottom;
164  data.rc.left = rcWorkArea.left;
165  data.rc.right = data.rc.left + AppBarConfig.appBarSizes.left;
166  break;
167  case ABE_TOP:
168  data.rc.left = rcWorkArea.left;
169  data.rc.right = rcWorkArea.right;
170  data.rc.top = rcWorkArea.top;
171  data.rc.bottom = data.rc.top + AppBarConfig.appBarSizes.top;
172  break;
173  case ABE_RIGHT:
174  data.rc.top = rcWorkArea.top;
175  data.rc.bottom = rcWorkArea.bottom;
176  data.rc.right = rcWorkArea.left;
177  data.rc.left = data.rc.right - AppBarConfig.appBarSizes.right;
178  break;
179  case ABE_BOTTOM:
180  data.rc.left = rcWorkArea.left;
181  data.rc.right = rcWorkArea.right;
182  data.rc.bottom = rcWorkArea.bottom;
183  data.rc.top = data.rc.bottom - AppBarConfig.appBarSizes.bottom;
184  break;
185  }
186  }
187  else
188  {
189  GetWindowRect(hMainWnd, &data.rc);
190  }
191 
192  data.uEdge = AppBarConfig.uEdge;
193  uState = SHAppBarMessage(ABM_QUERYPOS, &data);
194 
195  uState = SHAppBarMessage(ABM_SETPOS, &data);
196 
197  rcw = data.rc.right-data.rc.left;
198  rch = data.rc.bottom-data.rc.top;
199 
200  uState = SHAppBarMessage(ABM_GETSTATE, &data);
201  if(uState & ABS_ALWAYSONTOP)
202  hWndOrder = HWND_TOPMOST;
203 
204  SetWindowPos(hMainWnd, hWndOrder, data.rc.left, data.rc.top, rcw, rch, SWP_SHOWWINDOW|SWP_NOCOPYBITS);
205 
206  }
207  else if(mode == ABM_GETSTATE)
208  {
209  HWND hWndOrder = HWND_BOTTOM;
210  uState = SHAppBarMessage(ABM_GETSTATE, &data);
211  if(uState & ABS_ALWAYSONTOP)
212  hWndOrder = HWND_TOPMOST;
213  SetWindowPos(hMainWnd, hWndOrder, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
214  }
215  else if(mode == ABM_ACTIVATE)
216  {
218  }
219  else if(mode == ABM_WINDOWPOSCHANGED)
220  {
222  }
223  else if(mode == ABM_REMOVE)
224  {
225  SHAppBarMessage(ABM_REMOVE, &data);
226  }
227 }
#define ABE_TOP
Definition: shellapi.h:18
#define rch(ap)
Definition: match.c:407
#define SystemParametersInfo
Definition: winuser.h:5724
LONG top
Definition: windef.h:297
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:27
#define HWND_TOPMOST
Definition: winuser.h:1194
UINT uCallbackMessage
Definition: shellapi.h:215
HWND hWnd
Definition: shellapi.h:214
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
#define ABE_LEFT
Definition: shellapi.h:17
#define APPMSG_APPBAR
Definition: magnifier.c:27
#define ABM_ACTIVATE
Definition: shellapi.h:65
#define SWP_NOCOPYBITS
Definition: winuser.h:1228
UINT_PTR WINAPI SHAppBarMessage(DWORD msg, PAPPBARDATA data)
Definition: shell32_main.c:974
#define ABM_GETSTATE
Definition: shellapi.h:63
#define ABE_RIGHT
Definition: shellapi.h:19
DWORD cbSize
Definition: shellapi.h:213
#define ABS_ALWAYSONTOP
Definition: shellapi.h:22
#define HWND_BOTTOM
Definition: winuser.h:1191
unsigned int UINT
Definition: ndis.h:50
#define ABM_NEW
Definition: shellapi.h:59
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HWND hMainWnd
Definition: magnifier.c:33
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:68
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
#define ABM_QUERYPOS
Definition: shellapi.h:61
#define ABM_REMOVE
Definition: shellapi.h:60
LONG bottom
Definition: windef.h:299
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define ABM_SETPOS
Definition: shellapi.h:62
UINT uEdge
Definition: shellapi.h:216

◆ Draw()

void Draw ( HDC  aDc)

Definition at line 359 of file magnifier.c.

Referenced by DECLARE_INTERFACE_(), FolderOptionsViewDlg(), and WndProc().

360 {
361  HDC desktopHdc = NULL;
362 
363  RECT sourceRect, intersectedRect;
364  RECT targetRect, appRect;
365  DWORD rop = SRCCOPY;
366  CURSORINFO cinfo;
367  ICONINFO iinfo;
368 
369  int AppWidth, AppHeight;
370 
371  if (bInvertColors)
372  rop = NOTSRCCOPY;
373 
374  desktopHdc = GetDC(0);
375 
376  GetClientRect(hMainWnd, &appRect);
377  AppWidth = (appRect.right - appRect.left);
378  AppHeight = (appRect.bottom - appRect.top);
379 
380  ZeroMemory(&cinfo, sizeof(cinfo));
381  ZeroMemory(&iinfo, sizeof(iinfo));
382  cinfo.cbSize = sizeof(cinfo);
383  GetCursorInfo(&cinfo);
384  GetIconInfo(cinfo.hCursor, &iinfo);
385 
386  targetRect = appRect;
387  ClientToScreen(hMainWnd, (POINT*)&targetRect.left);
388  ClientToScreen(hMainWnd, (POINT*)&targetRect.right);
389 
391  {
393 
394  if(hdcOffscreen)
395  {
399  }
400 
401  sourceWidth = AppWidth / iZoom;
402  sourceHeight = AppHeight / iZoom;
403 
404  /* Create a memory DC compatible with client area DC */
405  hdcOffscreen = CreateCompatibleDC(desktopHdc);
406 
407  /* Create a bitmap compatible with the client area DC */
409  desktopHdc,
410  sourceWidth,
411  sourceHeight);
412 
413  /* Select our bitmap in memory DC and save the old one */
415  }
416 
417  GetWindowRect(hDesktopWindow, &sourceRect);
418  sourceRect.left = (cp.x) - (sourceWidth /2);
419  sourceRect.top = (cp.y) - (sourceHeight /2);
420  sourceRect.right = sourceRect.left + sourceWidth;
421  sourceRect.bottom = sourceRect.top + sourceHeight;
422 
423  GetBestOverlapWithMonitors(&sourceRect);
424 
425  /* Paint the screen bitmap to our in memory DC */
426  BitBlt(
427  hdcOffscreen,
428  0,
429  0,
430  sourceWidth,
431  sourceHeight,
432  desktopHdc,
433  sourceRect.left,
434  sourceRect.top,
435  rop);
436 
437  if (IntersectRect(&intersectedRect, &sourceRect, &targetRect))
438  {
439  OffsetRect(&intersectedRect, -sourceRect.left, -sourceRect.top);
440  FillRect(hdcOffscreen, &intersectedRect, GetStockObject(DC_BRUSH));
441  }
442 
443  /* Draw the mouse pointer in the right position */
444  DrawIcon(
445  hdcOffscreen ,
446  pMouse.x - iinfo.xHotspot - sourceRect.left, // - 10,
447  pMouse.y - iinfo.yHotspot - sourceRect.top, // - 10,
448  cinfo.hCursor);
449 
450  /* Blast the stretched image from memory DC to window DC */
451  StretchBlt(
452  aDc,
453  0,
454  0,
455  AppWidth,
456  AppHeight,
457  hdcOffscreen,
458  0,
459  0,
460  sourceWidth,
461  sourceHeight,
463 
464  /* Cleanup */
465  if (iinfo.hbmMask)
466  DeleteObject(iinfo.hbmMask);
467  if (iinfo.hbmColor)
468  DeleteObject(iinfo.hbmColor);
469  ReleaseDC(hDesktopWindow, desktopHdc);
470 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define HDC
Definition: msvc.h:22
int iZoom
Definition: settings.c:15
#define NOMIRRORBITMAP
Definition: wingdi.h:1358
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
DWORD yHotspot
Definition: winuser.h:3078
LONG top
Definition: windef.h:297
LONG sourceWidth
Definition: magnifier.c:51
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HWND hDesktopWindow
Definition: magnifier.c:43
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2014
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HANDLE hbmpOld
Definition: magnifier.c:55
HBITMAP hbmMask
Definition: winuser.h:3079
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define NOTSRCCOPY
Definition: wingdi.h:323
HBITMAP hbmColor
Definition: winuser.h:3080
BOOL WINAPI GetCursorInfo(_Inout_ PCURSORINFO)
HDC hdcOffscreen
Definition: magnifier.c:53
DWORD xHotspot
Definition: winuser.h:3077
POINT pMouse
Definition: magnifier.c:63
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG sourceHeight
Definition: magnifier.c:52
HBITMAP hbmpOffscreen
Definition: magnifier.c:54
HWND hMainWnd
Definition: magnifier.c:33
BOOL bRecreateOffscreenDC
Definition: magnifier.c:50
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
HCURSOR hCursor
Definition: winuser.h:3663
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI DrawIcon(_In_ HDC, _In_ int, _In_ int, _In_ HICON)
Definition: cursoricon.c:1987
BOOL WINAPI DeleteDC(_In_ HDC)
void GetBestOverlapWithMonitors(LPRECT rect)
Definition: magnifier.c:326
DWORD cbSize
Definition: winuser.h:3661
POINT cp
Definition: magnifier.c:60
LONG bottom
Definition: windef.h:299
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define SRCCOPY
Definition: wingdi.h:331
BOOL bInvertColors
Definition: settings.c:23

◆ GetBestOverlapWithMonitors()

void GetBestOverlapWithMonitors ( LPRECT  rect)

Definition at line 326 of file magnifier.c.

Referenced by Draw().

327 {
328  int rcLeft, rcTop;
329  int rcWidth, rcHeight;
330  RECT rcMon;
331  HMONITOR hMon = MonitorFromRect(rect, MONITOR_DEFAULTTONEAREST);
333  info.cbSize = sizeof(info);
334 
335  GetMonitorInfo(hMon, &info);
336 
337  rcMon = info.rcMonitor;
338 
339  rcLeft = rect->left;
340  rcTop = rect->top;
341  rcWidth = (rect->right - rect->left);
342  rcHeight = (rect->bottom - rect->top);
343 
344  if (rcLeft < rcMon.left)
345  rcLeft = rcMon.left;
346 
347  if (rcTop < rcMon.top)
348  rcTop = rcMon.top;
349 
350  if (rcLeft > (rcMon.right - rcWidth))
351  rcLeft = (rcMon.right - rcWidth);
352 
353  if (rcTop > (rcMon.bottom - rcHeight))
354  rcTop = (rcMon.bottom - rcHeight);
355 
356  OffsetRect(rect, (rcLeft-rect->left), (rcTop-rect->top));
357 }
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
RECT rcMonitor
Definition: winuser.h:3727
struct _test_info info[]
Definition: SetCursorPos.c:19
#define GetMonitorInfo
Definition: winuser.h:5657
DWORD cbSize
Definition: winuser.h:3726
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
LONG bottom
Definition: windef.h:299

◆ HandleNotifyIconMessage()

void HandleNotifyIconMessage ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 472 of file magnifier.c.

Referenced by WndProc().

473 {
474  POINT pt;
475 
476  switch(lParam)
477  {
478  case WM_LBUTTONUP:
480  break;
481  case WM_RBUTTONUP:
482  GetCursorPos (&pt);
483  TrackPopupMenu(notifyMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
484  break;
485  }
486 }
#define IDM_OPTIONS
Definition: resource.h:28
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
smooth NULL
Definition: ftsmooth.c:416
#define PostMessage
Definition: winuser.h:5698
#define WM_RBUTTONUP
Definition: winuser.h:1756
HWND hMainWnd
Definition: magnifier.c:33
#define WM_COMMAND
Definition: winuser.h:1716
#define WM_LBUTTONUP
Definition: winuser.h:1753
HMENU notifyMenu
Definition: magnifier.c:47
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 263 of file magnifier.c.

Referenced by WinMain().

264 {
265  RECT rc;
268 
269  /* Load settings from registry */
270  LoadSettings();
271 
272  rc = AppBarConfig.rcFloating;
273 
274  hInst = hInstance; // Store instance handle in our global variable
275 
276  if (AppBarConfig.uEdge<0)
277  {
278  dwStyles |= WS_CAPTION;
279  exStyles |= WS_EX_TOPMOST;
280  }
281 
282  /* Create the Window */
284  exStyles,
286  szTitle,
287  dwStyles,
288  rc.left,
289  rc.top,
290  rc.right-rc.left,
291  rc.bottom-rc.top,
292  NULL,
293  NULL,
294  hInstance,
295  NULL);
296 
297  if (!hMainWnd)
298  return FALSE;
299 
300  if (AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_NEW);
302 
303  // In Windows 2003's Magnifier, the "Start Minimized" setting
304  // refers exclusively to the options dialog, not the main window itself.
306  if (bStartMinimized)
308  else
310 
311  if (bShowWarning)
313 
314  return TRUE;
315 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define IDD_DIALOGOPTIONS
Definition: resource.h:14
HINSTANCE hInst
Definition: magnifier.c:32
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
HWND hOptionsDialog
Definition: magnifier.c:48
#define IDD_WARNINGDIALOG
Definition: resource.h:15
LONG top
Definition: windef.h:297
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:27
#define WS_SIZEBOX
Definition: pedump.c:642
#define HWND_TOPMOST
Definition: winuser.h:1194
LONG left
Definition: windef.h:296
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:140
#define WS_CLIPCHILDREN
Definition: pedump.c:619
LONG right
Definition: windef.h:298
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define DialogBox
Definition: winuser.h:5627
const TCHAR szWindowClass[]
Definition: magnifier.c:29
HINSTANCE hInstance
Definition: charmap.c:20
#define WS_EX_CONTROLPARENT
Definition: winuser.h:387
void LoadSettings(void)
Definition: settings.c:53
#define CreateWindowEx
Definition: winuser.h:5621
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOW
Definition: winuser.h:769
#define WS_CAPTION
Definition: pedump.c:624
INT_PTR CALLBACK OptionsProc(HWND, UINT, WPARAM, LPARAM)
Definition: magnifier.c:869
#define ABM_NEW
Definition: shellapi.h:59
unsigned long DWORD
Definition: ntddk_ex.h:95
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
HWND hMainWnd
Definition: magnifier.c:33
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define SWP_NOSIZE
Definition: winuser.h:1230
#define WS_POPUP
Definition: pedump.c:616
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
INT_PTR CALLBACK WarningProc(HWND, UINT, WPARAM, LPARAM)
Definition: magnifier.c:971
BOOL bShowWarning
Definition: settings.c:17
LONG bottom
Definition: windef.h:299
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL bStartMinimized
Definition: settings.c:24
#define WS_SYSMENU
Definition: pedump.c:629
#define CreateDialog
Definition: winuser.h:5615

◆ MyRegisterClass()

ATOM MyRegisterClass ( HINSTANCE  hInstance)

Definition at line 122 of file magnifier.c.

Referenced by WinMain().

123 {
124  WNDCLASS wc;
125 
126  wc.style = CS_HREDRAW | CS_VREDRAW;
127  wc.lpfnWndProc = WndProc;
128  wc.cbClsExtra = 0;
129  wc.cbWndExtra = 0;
130  wc.hInstance = hInstance;
131  wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
133  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
134  wc.lpszMenuName = NULL; //MAKEINTRESOURCE(IDC_MAGNIFIER);
136 
137  return RegisterClass(&wc);
138 }
#define IDI_ICON
Definition: resource.h:5
#define MAKEINTRESOURCE
Definition: winuser.h:591
int cbClsExtra
Definition: winuser.h:3118
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3124
HBRUSH hbrBackground
Definition: winuser.h:3123
#define COLOR_WINDOW
Definition: winuser.h:908
int cbWndExtra
Definition: winuser.h:3119
const TCHAR szWindowClass[]
Definition: magnifier.c:29
HINSTANCE hInstance
Definition: charmap.c:20
HCURSOR hCursor
Definition: winuser.h:3122
smooth NULL
Definition: ftsmooth.c:416
#define CS_VREDRAW
Definition: winuser.h:653
LPCSTR lpszClassName
Definition: winuser.h:3125
#define LoadCursor
Definition: winuser.h:5678
UINT style
Definition: winuser.h:3116
HINSTANCE hInstance
Definition: winuser.h:3120
WNDPROC lpfnWndProc
Definition: winuser.h:3117
#define IDC_ARROW
Definition: winuser.h:682
#define RegisterClass
Definition: winuser.h:5702
#define LoadIcon
Definition: winuser.h:5679
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
Definition: magnifier.c:488
HICON hIcon
Definition: winuser.h:3121

◆ OptionsProc()

INT_PTR CALLBACK OptionsProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 869 of file magnifier.c.

Referenced by InitInstance().

870 {
872  switch (message)
873  {
874  case WM_SHOWWINDOW:
876  break;
877  case WM_INITDIALOG:
878  {
879  // Add the zoom items...
880  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("1"));
881  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("2"));
882  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("3"));
883  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("4"));
884  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("5"));
885  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("6"));
886  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("7"));
887  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("8"));
888 
890 
891  if (bFollowMouse)
893 
894  if (bFollowFocus)
896 
897  if (bFollowCaret)
899 
900  if (bInvertColors)
902 
903  if (bStartMinimized)
905 
906  if (bShowMagnifier)
908 
909  return (INT_PTR)TRUE;
910  }
911 
912  case WM_COMMAND:
913  switch (LOWORD(wParam))
914  {
915  case IDOK:
916  case IDCANCEL:
917  ShowWindow(hDlg, SW_HIDE);
918  return (INT_PTR)TRUE;
919 
920  case IDC_BUTTON_HELP:
921  /* Unimplemented */
922  MessageBox(hDlg , TEXT("Magnifier help not available yet!") , TEXT("Help") , MB_OK);
923  break;
924  case IDC_ZOOM:
925  if (HIWORD(wParam) == CBN_SELCHANGE)
926  {
927  HWND hCombo = GetDlgItem(hDlg,IDC_ZOOM);
928  LPCTSTR currentZoomValue = TEXT("");
929 
930  /* Get index of current selection and the text of that selection */
931  int currentSelectionIndex = ComboBox_GetCurSel(hCombo);
932  ComboBox_GetLBText(hCombo, currentSelectionIndex, currentZoomValue);
933  iZoom = _ttoi(currentZoomValue);
934 
935  /* Trigger the Draw function to rezoom (which will be set false automatically after rezooming) */
937 
938  /* Update the magnifier UI */
939  Refresh();
940  }
941  break;
944  Refresh();
945  break;
948  break;
951  break;
954  break;
957  break;
958  case IDC_SHOWMAGNIFIER:
960  if (bShowMagnifier)
962  else
964  break;
965  }
966  }
967 
968  return (INT_PTR)FALSE;
969 }
#define IDC_FOLLOWKEYBOARDCHECK
Definition: resource.h:17
int iZoom
Definition: settings.c:15
BOOL bShowMagnifier
Definition: settings.c:25
#define IDC_ZOOM
Definition: resource.h:16
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IDOK
Definition: winuser.h:824
#define IDC_FOLLOWTEXTEDITINGCHECK
Definition: resource.h:18
#define ComboBox_GetLBText(hwndCtl, index, lpszBuffer)
Definition: windowsx.h:31
#define IDC_SHOWMAGNIFIERCHECK
Definition: resource.h:22
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define SW_HIDE
Definition: winuser.h:762
#define WM_SHOWWINDOW
Definition: winuser.h:1610
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:24
#define SendDlgItemMessage
Definition: winuser.h:5708
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:62
WPARAM wParam
Definition: combotst.c:138
#define IDC_STARTMINIMIZEDCHECK
Definition: resource.h:20
LONG_PTR LPARAM
Definition: windef.h:208
BOOL bOptionsDialog
Definition: magnifier.c:49
#define CB_ADDSTRING
Definition: winuser.h:1897
#define IDC_SHOWMAGNIFIER
Definition: resource.h:21
#define SW_SHOW
Definition: winuser.h:769
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define BM_SETCHECK
Definition: winuser.h:1882
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hMainWnd
Definition: magnifier.c:33
BOOL bRecreateOffscreenDC
Definition: magnifier.c:50
BOOL bFollowMouse
Definition: settings.c:19
#define MessageBox
Definition: winuser.h:5688
#define CB_SETCURSEL
Definition: winuser.h:1922
#define WM_COMMAND
Definition: winuser.h:1716
#define TEXT(s)
Definition: k32.h:26
#define IDC_BUTTON_HELP
Definition: resource.h:17
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
BOOL bFollowCaret
Definition: settings.c:21
#define MB_OK
Definition: winuser.h:784
#define CBN_SELCHANGE
Definition: winuser.h:1940
#define IDC_FOLLOWMOUSECHECK
Definition: resource.h:23
#define HIWORD(l)
Definition: typedefs.h:246
#define IDCANCEL
Definition: winuser.h:825
BOOL bStartMinimized
Definition: settings.c:24
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define IDC_INVERTCOLORSCHECK
Definition: resource.h:19
BOOL bInvertColors
Definition: settings.c:23
BOOL bFollowFocus
Definition: settings.c:20
void Refresh()
Definition: magnifier.c:317

◆ Refresh()

void Refresh ( )

Definition at line 317 of file magnifier.c.

Referenced by DECLARE_INTERFACE_(), CShellBrowser::GetWindowProc(), OptionsProc(), and WndProc().

318 {
319  if (!IsIconic(hMainWnd))
320  {
321  /* Invalidate the client area forcing a WM_PAINT message */
323  }
324 }
#define TRUE
Definition: types.h:120
BOOL WINAPI IsIconic(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
HWND hMainWnd
Definition: magnifier.c:33

◆ WarningProc()

INT_PTR CALLBACK WarningProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 971 of file magnifier.c.

Referenced by InitInstance().

972 {
974 
975  switch (message)
976  {
977  case WM_INITDIALOG:
978  return (INT_PTR)TRUE;
979 
980  case WM_COMMAND:
981  switch (LOWORD(wParam))
982  {
985  break;
986  }
987  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
988  {
989  EndDialog(hDlg, LOWORD(wParam));
990  return (INT_PTR)TRUE;
991  }
992  break;
993  }
994 
995  return (INT_PTR)FALSE;
996 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDC_SHOWWARNINGCHECK
Definition: resource.h:25
int32_t INT_PTR
Definition: typedefs.h:62
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
BOOL bShowWarning
Definition: settings.c:17
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 76 of file magnifier.c.

77 {
78  MSG msg;
79  HACCEL hAccelTable;
80 
81  UNREFERENCED_PARAMETER(hPrevInstance);
82  UNREFERENCED_PARAMETER(lpCmdLine);
83 
84  switch (GetUserDefaultUILanguage())
85  {
88  break;
89 
90  default:
91  break;
92  }
93 
94  /* Initialize global strings */
96  MyRegisterClass(hInstance);
97 
98  /* Perform application initialization */
99  if (!InitInstance(hInstance, nCmdShow))
100  return FALSE;
101 
102  hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MAGNIFIER));
103 
104  /* Main message loop */
105  while (GetMessage(&msg, NULL, 0, 0))
106  {
107  if (!TranslateAccelerator(hMainWnd, hAccelTable, &msg))
108  {
109  TranslateMessage(&msg);
110  DispatchMessage(&msg);
111  }
112  }
113 
114 
118 
119  return (int) msg.wParam;
120 }
#define TranslateAccelerator
Definition: winuser.h:5726
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:561
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define LAYOUT_RTL
Definition: wingdi.h:1352
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define IDC_MAGNIFIER
Definition: resource.h:12
BOOL InitInstance(HINSTANCE, int)
Definition: magnifier.c:263
#define LANG_HEBREW
Definition: nls.h:67
#define LoadAccelerators
Definition: winuser.h:5676
HANDLE hbmpOld
Definition: magnifier.c:55
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
HDC hdcOffscreen
Definition: magnifier.c:53
ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: magnifier.c:122
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
HBITMAP hbmpOffscreen
Definition: magnifier.c:54
HWND hMainWnd
Definition: magnifier.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
#define IDS_APP_TITLE
Definition: resource.h:10
#define GetMessage
Definition: winuser.h:5656
#define msg(x)
Definition: auth_time.c:54
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LoadString
Definition: winuser.h:5685
#define MAX_LOADSTRING
Definition: magnifier.c:35

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 488 of file magnifier.c.

Referenced by MyRegisterClass().

489 {
490  int wmId;
491 
492  switch (message)
493  {
494  case WM_TIMER:
495  {
496  BOOL hasMoved = FALSE;
497 
498  GUITHREADINFO guiInfo;
499  guiInfo.cbSize = sizeof(guiInfo);
500 
501  GetGUIThreadInfo(0, &guiInfo);
502 
503  if (bFollowMouse)
504  {
505  POINT pNewMouse;
506 
507  //Get current mouse position
508  GetCursorPos (&pNewMouse);
509 
510 #define PointsAreEqual(pt1, pt2) (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))
511 
512  //If mouse has moved ...
513  if (!PointsAreEqual(pMouse, pNewMouse))
514  {
515  //Update to new position
516  pMouse = pNewMouse;
517  cp = pNewMouse;
518  hasMoved = TRUE;
519  }
520  }
521 
522  if(guiInfo.hwndActive != hMainWnd)
523  {
524  if (bFollowCaret)
525  {
526  if (guiInfo.hwndCaret)
527  {
528  POINT ptCaret;
529  ptCaret.x = (guiInfo.rcCaret.left + guiInfo.rcCaret.right) / 2;
530  ptCaret.y = (guiInfo.rcCaret.top + guiInfo.rcCaret.bottom) / 2;
531 
532  if ((pCaretWnd != guiInfo.hwndCaret) || !PointsAreEqual(pCaret, ptCaret))
533  {
534  //Update to new position
535  pCaret = ptCaret;
536  pCaretWnd = guiInfo.hwndCaret;
537  if(!hasMoved)
538  {
539  ClientToScreen (guiInfo.hwndCaret, (LPPOINT) &ptCaret);
540  cp = ptCaret;
541  hasMoved = TRUE;
542  }
543  }
544  }
545  else
546  {
547  pCaretWnd = NULL;
548  }
549  }
550 
551  if (bFollowFocus)
552  {
553  if(guiInfo.hwndFocus && !guiInfo.hwndCaret)
554  {
555  POINT ptFocus;
556  RECT activeRect;
557 
558  //Get current control focus
559  GetWindowRect(guiInfo.hwndFocus, &activeRect);
560  ptFocus.x = (activeRect.left + activeRect.right) / 2;
561  ptFocus.y = (activeRect.top + activeRect.bottom) / 2;
562 
563  if((guiInfo.hwndFocus != pFocusWnd) || !PointsAreEqual(pFocus, ptFocus))
564  {
565  //Update to new position
566  pFocus = ptFocus;
567  pFocusWnd = guiInfo.hwndFocus;
568  if(!hasMoved)
569  {
570  cp = ptFocus;
571  hasMoved = TRUE;
572  }
573  }
574  }
575  else
576  {
577  pFocusWnd = NULL;
578  }
579  }
580  }
581 
582  if(!hasMoved)
583  {
584  DWORD newTicks = GetTickCount();
585  DWORD elapsed = (newTicks - lastTicks);
586  if(elapsed > REPAINT_SPEED)
587  {
588  hasMoved = TRUE;
589  }
590  }
591 
592  if(hasMoved)
593  {
595  Refresh();
596  }
597 
598  return 0;
599  }
600 
601  case WM_COMMAND:
602  {
603  wmId = LOWORD(wParam);
604  /* Parse the menu selections */
605  switch (wmId)
606  {
607  case IDM_OPTIONS:
608  if(bOptionsDialog)
609  {
611  }
612  else
613  {
615  }
616  break;
617  case IDM_ABOUT:
619  break;
620  case IDM_EXIT:
621  DestroyWindow(hWnd);
622  break;
623  default:
624  return DefWindowProc(hWnd, message, wParam, lParam);
625  }
626  return 0;
627  }
628 
629  case WM_PAINT:
630  {
631  PAINTSTRUCT PaintStruct;
632  HDC dc;
633  dc = BeginPaint(hWnd, &PaintStruct);
634  Draw(dc);
635  EndPaint(hWnd, &PaintStruct);
636  return 0;
637  }
638 
639  case WM_CONTEXTMENU:
641  return 0;
642 
643  case WM_LBUTTONDOWN:
644  {
645  RECT rc;
646  POINT pt;
647  SetCapture(hWnd);
648 
649  GetCursorPos(&pt);
650  GetWindowRect(hWnd, &rc);
651  ptDragOffset.x = pt.x - rc.left;
652  ptDragOffset.y = pt.y - rc.top;
653 
654  nearEdge = AppBarConfig.uEdge;
655 
656  break;
657  }
658  case WM_MOUSEMOVE:
659  if(GetCapture() == hWnd)
660  {
661  RECT rc;
662  POINT pt;
663  RECT rcWorkArea;
664  SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
665  GetCursorPos(&pt);
666  GetWindowRect(hWnd, &rc);
667 
668  if(AppBarConfig.uEdge>=0)
669  {
670  if (pt.x >= rcWorkArea.left && pt.x <= rcWorkArea.right &&
671  pt.y >= rcWorkArea.top && pt.y <= rcWorkArea.bottom)
672  {
673  AttachAppBar(-2);
674 
675  // Fixup offset
676  GetWindowRect(hWnd, &rc);
677  ptDragOffset.x = (rc.right-rc.left)/2;
678  ptDragOffset.y = 2;
679 
680  rc.left = pt.x - ptDragOffset.x;
681  rc.top = pt.y - ptDragOffset.y;
682 
683  SetWindowPos(hWnd, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
684  }
685  }
686  else
687  {
688  if(pt.x <= rcWorkArea.left+8 && nearEdge != ABE_LEFT)
689  {
691  nearEdge = ABE_LEFT;
692  }
693  else if(pt.y <= rcWorkArea.top+8 && nearEdge != ABE_TOP)
694  {
696  nearEdge = ABE_TOP;
697  }
698  else if(pt.x >= rcWorkArea.right-8 && nearEdge != ABE_RIGHT)
699  {
702  }
703  else if(pt.y >= rcWorkArea.bottom-8 && nearEdge != ABE_BOTTOM)
704  {
707  }
708  else
709  {
710  rc.left = pt.x - ptDragOffset.x;
711  rc.top = pt.y - ptDragOffset.y;
712 
713  SetWindowPos(hWnd, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
714  nearEdge = -1;
715  }
716  }
717 
718  pMouse = pt;
719  Refresh();
720  }
721  break;
722  case WM_LBUTTONUP:
723  if(GetCapture() == hWnd)
724  {
725  if (AppBarConfig.uEdge>=0)
727  else
728  SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
729  ReleaseCapture();
730  }
731  break;
732 
733  case WM_SIZE:
734  if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_SETPOS);
735  /* fallthrough */
736  case WM_DISPLAYCHANGE:
738  Refresh();
739  break;
740 
741  case WM_ERASEBKGND:
742  // handle WM_ERASEBKGND by simply returning non-zero because we did all the drawing in WM_PAINT.
743  return 0;
744 
745  case WM_DESTROY:
746  {
747  if (AppBarConfig.uEdge >= 0)
749 
750  KillTimer(hWnd, 1);
751 
752  /* Save settings to registry */
753  SaveSettings();
754 
755  /* Cleanup notification icon */
756  ZeroMemory(&nid, sizeof(nid));
757  nid.cbSize = sizeof(nid);
759  nid.hWnd = hWnd;
763 
765 
766  PostQuitMessage(0);
767  return 0;
768  }
769 
770  case WM_CREATE:
771  {
772  HMENU tempMenu;
773 
774  /* Get the desktop window */
776 
777  /* Set the timer */
778  SetTimer(hWnd, 1, TIMER_SPEED, NULL);
779 
780  /* Notification icon */
782 
783  ZeroMemory(&nid, sizeof(nid));
784  nid.cbSize = sizeof(nid);
786  nid.hWnd = hWnd;
788  nid.hIcon = notifyIcon;
790 
792  notifyMenu = GetSubMenu(tempMenu, 0);
793  RemoveMenu(tempMenu, 0, MF_BYPOSITION);
794  DestroyMenu(tempMenu);
795  return 0;
796  }
797 
798  case APPMSG_APPBAR:
799  {
800  switch (wParam)
801  {
802  case ABN_STATECHANGE:
804  break;
805  case ABN_POSCHANGED:
807  break;
808  case ABN_FULLSCREENAPP:
809  {
810  if(!lParam)
811  {
813  break;
814  }
815 
817  break;
818  }
819  case ABN_WINDOWARRANGE:
820  if(lParam)
822  else
824  break;
825  }
826  return 0;
827  }
828 
829  case APPMSG_NOTIFYICON:
831  return 0;
832 
833  case WM_ACTIVATE:
835  break;
836 
837  case WM_WINDOWPOSCHANGED:
839  Refresh();
840  break;
841 
842  default:
843  break;
844  }
845 
846  return DefWindowProc(hWnd, message, wParam, lParam);
847 }
#define IDM_OPTIONS
Definition: resource.h:28
#define HDC
Definition: msvc.h:22
#define IDI_ICON
Definition: resource.h:5
HINSTANCE hInst
Definition: magnifier.c:32
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ABE_TOP
Definition: shellapi.h:18
#define NIF_MESSAGE
Definition: shellapi.h:102
INT_PTR CALLBACK AboutProc(HWND, UINT, WPARAM, LPARAM)
Definition: magnifier.c:849
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define IMAGE_ICON
Definition: winuser.h:212
long y
Definition: polytest.cpp:48
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define ABN_WINDOWARRANGE
Definition: shellapi.h:72
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define IDM_ABOUT
Definition: resource.h:29
HWND pCaretWnd
Definition: magnifier.c:66
long x
Definition: polytest.cpp:48
void AttachAppBar(INT uEdge)
Definition: magnifier.c:229
NOTIFYICONDATA nid
Definition: magnifier.c:45
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
DWORD cbSize
Definition: winable.h:70
HWND hOptionsDialog
Definition: magnifier.c:48
void Draw(HDC aDc)
Definition: magnifier.c:359
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define SystemParametersInfo
Definition: winuser.h:5724
LONG top
Definition: windef.h:297
#define REPAINT_SPEED
Definition: magnifier.c:39
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:27
#define ZeroMemory
Definition: winbase.h:1635
#define HWND_TOPMOST
Definition: winuser.h:1194
#define HWND_TOP
Definition: winuser.h:1193
HWND hwndActive
Definition: winable.h:72
#define IDC_MAGNIFIER
Definition: resource.h:12
HDC dc
Definition: cylfrac.c:34
HWND hDesktopWindow
Definition: magnifier.c:43
LONG left
Definition: windef.h:296
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:140
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:298
#define ABE_LEFT
Definition: shellapi.h:17
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define APPMSG_APPBAR
Definition: magnifier.c:27
HWND hwndCaret
Definition: winable.h:77
#define ABM_ACTIVATE
Definition: shellapi.h:65
void SaveSettings(void)
Definition: settings.c:113
#define DialogBox
Definition: winuser.h:5627
#define IDD_ABOUTBOX
Definition: resource.h:8
#define MF_BYPOSITION
Definition: winuser.h:203
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define ABM_GETSTATE
Definition: shellapi.h:63
BOOL bOptionsDialog
Definition: magnifier.c:49
HWND WINAPI GetCapture(void)
Definition: message.c:2855
HWND hwndFocus
Definition: winable.h:73
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
#define ABE_RIGHT
Definition: shellapi.h:19
#define GET_X_LPARAM(lp)
Definition: precomp.h:67
#define SW_SHOW
Definition: winuser.h:769
#define NIF_ICON
Definition: shellapi.h:103
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define HWND_BOTTOM
Definition: winuser.h:1191
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1718
POINT pMouse
Definition: magnifier.c:63
INT nearEdge
Definition: magnifier.c:57
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NIM_DELETE
Definition: shellapi.h:93
#define WM_PAINT
Definition: winuser.h:1602
HICON notifyIcon
Definition: magnifier.c:46
#define PointsAreEqual(pt1, pt2)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HWND hMainWnd
Definition: magnifier.c:33
BOOL bRecreateOffscreenDC
Definition: magnifier.c:50
POINT pFocus
Definition: magnifier.c:65
BOOL bFollowMouse
Definition: settings.c:19
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
#define TIMER_SPEED
Definition: magnifier.c:38
#define ABN_FULLSCREENAPP
Definition: shellapi.h:71
BOOL WINAPI DestroyMenu(_In_ HMENU)
UINT uCallbackMessage
Definition: shellapi.h:227
#define ABN_POSCHANGED
Definition: shellapi.h:70
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ABE_BOTTOM
Definition: shellapi.h:20
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WM_ACTIVATE
Definition: winuser.h:1594
#define LoadMenu
Definition: winuser.h:5683
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_LBUTTONUP
Definition: winuser.h:1753
BOOL bFollowCaret
Definition: settings.c:21
HWND pFocusWnd
Definition: magnifier.c:67
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:68
POINT pCaret
Definition: magnifier.c:64
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define IDM_EXIT
Definition: resource.h:27
POINT ptDragOffset
Definition: magnifier.c:56
#define GET_Y_LPARAM(lp)
Definition: precomp.h:68
#define NIM_ADD
Definition: shellapi.h:91
DWORD lastTicks
Definition: magnifier.c:41
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2864
POINT cp
Definition: magnifier.c:60
#define Shell_NotifyIcon
Definition: shellapi.h:677
#define APPMSG_NOTIFYICON
Definition: magnifier.c:26
#define WM_CREATE
Definition: winuser.h:1590
#define ABM_REMOVE
Definition: shellapi.h:60
void HandleNotifyIconMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: magnifier.c:472
LONG bottom
Definition: windef.h:299
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define LoadImage
Definition: winuser.h:5681
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define ABM_SETPOS
Definition: shellapi.h:62
#define ABN_STATECHANGE
Definition: shellapi.h:69
HMENU notifyMenu
Definition: magnifier.c:47
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL bFollowFocus
Definition: settings.c:20
void Refresh()
Definition: magnifier.c:317
BOOL WINAPI GetGUIThreadInfo(DWORD, LPGUITHREADINFO)
Definition: ntwrapper.h:398

Variable Documentation

◆ bOptionsDialog

BOOL bOptionsDialog = FALSE

Definition at line 49 of file magnifier.c.

Referenced by OptionsProc(), and WndProc().

◆ bRecreateOffscreenDC

BOOL bRecreateOffscreenDC = TRUE

Definition at line 50 of file magnifier.c.

Referenced by Draw(), OptionsProc(), and WndProc().

◆ cp

POINT cp

Definition at line 60 of file magnifier.c.

Referenced by __GetDefaultCP(), __intGetACP(), __intGetOCP(), __subformat(), __TranslateToSystem(), _bdf_add_comment(), _get_next_token(), _Locale_common_default(), _math_horner_bezier_surf(), _TIFFCheckRealloc(), add_file(), add_param(), AddrStrToAddr(), AddrToAddrStr(), advise_prop_notif(), analyse_from_scratch(), AtlAdvise(), AtlUnadvise(), bind_script_to_text(), BookmarkCompletionFunction(), BreadthFirstCmp(), cache_spot(), call_event_handlers(), call_property_onchanged(), Chdirs(), check_enc(), checkInkNamesString(), cnv_unicode(), CommandCompletionFunction(), CommandSubSearchCmp(), CompletionFunction(), ComputeLNames(), ComputeRNames(), ConnectionPointContainer_FindConnectionPoint(), create_event_sink(), DECLAREContigPutFunc(), DECLARESepPutFunc(), DecodeDirectoryURL(), DefaultBookmarkName(), detach_plugin_host(), do_advise(), DoCommand(), DrawTextExA(), EDIT_BuildLineDefs_ML(), EnumConnections_Next(), ExpandTilde(), FD31_StripEditControl(), FGets(), FilenameExtensionIndicatesASCII(), fill_reobject_struct(), FindSubStrI(), fnIMLangFontLink2_GetStrCodePages(), fnIMultiLanguage3_GetCodePageDescription(), fnIMultiLanguage3_GetCodePageInfo(), fnIMultiLanguage3_ValidateCodePageEx(), fnIMultiLanguage_GetCodePageInfo(), FONT_mbtowc(), for(), fpAcc(), fpDiff(), ftGdiGetTextCharsetInfo(), FTPChdir3(), FTPDecodeURL(), FTPFtw(), FTPFtwL2(), FTPGetFiles3(), FTPLocalRecursiveFileList2(), FTPMkdir2(), FTPPutOneF(), FTPQueryFeatures(), FTPRemoteGlob(), FTPRemoteRecursiveFileList(), get_cp(), get_input_codepage(), GetBookmark(), GetCurrencyFormatA(), GetFamilyCodePage(), GetHomeDir(), getline(), GetNumberFormatA(), GetOurHostName(), GetPwByName(), getreply(), GetResponse(), GetScreenColumns(), GetStartSpoolDate(), GetStringTypeA(), GetTabbedTextExtentA(), GetUsrName(), gl_do_tab_completion(), gl_getpass(), gl_init(), gl_local_filename_completion_proc(), gl_set_home_dir(), gl_text(), Global_Chr(), HaveCommandNameOnly(), HelpCmd(), horAcc8(), horDiff8(), inet_addr(), inet_aton(), init_output_buffer(), InitOurDirectory(), InitUserInfo(), interpret(), ipaddr_aton(), iso9660_file_length(), Load_CP2Unicode_Table(), LoadFirewallPrefs(), Ls(), LsCacheAdd(), main(), map_wparam_char_WtoA(), MatchRegExp(), mdelete(), ME_CharFromPointContext(), ME_StreamInText(), memrchr(), MFDRV_ExtTextOut(), mget(), MkDirs(), LocaleTest::moneypunct_by_name(), mput(), MultisetTest::mset3(), MsgiUnicodeToAnsiMessage(), MSVCRT__create_locale(), MSVCRT_locale_to_LCID(), MyInetAddr(), NLS_GetDateTimeFormatA(), notify_webbrowser_close(), nsIOService_NewURI(), OpenTrace(), parse_ncp(), parse_rr(), parse_xa(), ParseV4Address(), Passive(), PathCat(), png_access_version_number(), PrefOptCompletionFunction(), PrintStartupBanner(), PushBackTrackState(), pvd_write(), ReadColorTbl(), Readline(), register_cp(), ReInitResponse(), remglob(), RemoteCompletionFunction(), RemoteDirCompletionFunction(), RemoteFileCompletionFunction(), RemoteGlobCollapse(), request_send(), reset(), RTFDestroyAttrs(), Scramble(), SError(), ServiceNameToPortNumber(), setnmap(), setpeer(), ShellCmd(), split_params(), StrDup(), strntokc(), StrRemoveTrailingSlashes(), strtokc(), TabbedTextOutA(), test__ismbclx(), test_CodePageToScriptID(), test_ConnectionPoint(), test_dbcs_wm_char(), test_empty_document(), test_iframe_connections(), test_IMLangConvertCharset(), test_IWinHttpRequest(), test_Load(), test_mbbtombc(), test_mbcjisjms(), test_mbcjmsjis(), test_swab(), test_threadcp(), test_unicode_wm_char(), TIFFClientOpen(), TIFFPrintDirectory(), TIFFReverseBits(), TIFFSwabArrayOfDouble(), TIFFSwabArrayOfFloat(), TIFFSwabArrayOfLong(), TIFFSwabArrayOfLong8(), TIFFSwabArrayOfShort(), TIFFSwabArrayOfTriples(), TIFFSwabDouble(), TIFFSwabFloat(), TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), token(), Traverse(), UnDosLine(), unfold_header(), UnLslR(), UnLslRLine(), UnMlsT(), unquote_string(), unregister_cp(), update_threadlocinfo_category(), vers_write(), Vt100VisibleStrlen(), win_iconv(), WINHELP_FindLink(), WINHELP_SetupText(), winhttp_request_put_Option(), WinMain(), write_nls_files(), WriteDefaultFirewallPrefs(), xdr_char(), xdr_opaque(), xdr_u_char(), and Mapdesc::xformMat().

◆ hbmpOffscreen

HBITMAP hbmpOffscreen = NULL

Definition at line 54 of file magnifier.c.

Referenced by Draw(), and WinMain().

◆ hbmpOld

◆ hdcOffscreen

HDC hdcOffscreen = NULL

Definition at line 53 of file magnifier.c.

Referenced by Draw(), test_mf_conversions(), and WinMain().

◆ hDesktopWindow

HWND hDesktopWindow = NULL

Definition at line 43 of file magnifier.c.

◆ hInst

HINSTANCE hInst

Definition at line 32 of file magnifier.c.

◆ hMainWnd

◆ hOptionsDialog

HWND hOptionsDialog

Definition at line 48 of file magnifier.c.

◆ lastTicks

DWORD lastTicks = 0

Definition at line 41 of file magnifier.c.

Referenced by WndProc().

◆ nearEdge

INT nearEdge

Definition at line 57 of file magnifier.c.

Referenced by WndProc().

◆ nid

◆ notifyIcon

HICON notifyIcon

Definition at line 46 of file magnifier.c.

Referenced by WndProc().

◆ notifyMenu

HMENU notifyMenu

Definition at line 47 of file magnifier.c.

Referenced by HandleNotifyIconMessage(), and WndProc().

◆ pCaret

POINT pCaret

Definition at line 64 of file magnifier.c.

◆ pCaretWnd

HWND pCaretWnd

Definition at line 66 of file magnifier.c.

◆ pFocus

POINT pFocus

Definition at line 65 of file magnifier.c.

◆ pFocusWnd

HWND pFocusWnd

Definition at line 67 of file magnifier.c.

◆ pMouse

POINT pMouse

Definition at line 63 of file magnifier.c.

Referenced by test_acquire(), and test_set_coop().

◆ ptDragOffset

POINT ptDragOffset

Definition at line 56 of file magnifier.c.

◆ sourceHeight

LONG sourceHeight = 0

Definition at line 52 of file magnifier.c.

Referenced by Draw().

◆ sourceWidth

LONG sourceWidth = 0

Definition at line 51 of file magnifier.c.

Referenced by Draw().

◆ szTitle

◆ szWindowClass

const TCHAR szWindowClass[] = TEXT("MAGNIFIER")