ReactOS  0.4.13-dev-540-g8f04a09
magnifier.c File Reference
#include "magnifier.h"
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winnls.h>
#include <commctrl.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)
 
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 26 of file magnifier.c.

◆ APPMSG_NOTIFYICON

#define APPMSG_NOTIFYICON   (WM_APP+1)

Definition at line 25 of file magnifier.c.

◆ MAX_LOADSTRING

#define MAX_LOADSTRING   100

Definition at line 34 of file magnifier.c.

◆ PointsAreEqual

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

◆ REPAINT_SPEED

#define REPAINT_SPEED   100

Definition at line 38 of file magnifier.c.

◆ TIMER_SPEED

#define TIMER_SPEED   1

Definition at line 37 of file magnifier.c.

Function Documentation

◆ AboutProc()

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

Definition at line 840 of file magnifier.c.

841 {
843  switch (message)
844  {
845  case WM_INITDIALOG:
846  return (INT_PTR)TRUE;
847 
848  case WM_COMMAND:
849  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
850  {
851  EndDialog(hDlg, LOWORD(wParam));
852  return (INT_PTR)TRUE;
853  }
854  break;
855  }
856 
857  return (INT_PTR)FALSE;
858 }
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

Referenced by WndProc().

◆ AttachAppBar()

void AttachAppBar ( INT  uEdge)

Definition at line 232 of file magnifier.c.

233 {
234  if (AppBarConfig.uEdge == uEdge)
235  return;
236 
237  if (AppBarConfig.uEdge < 0 && uEdge >= 0)
238  {
240  }
241  else if (uEdge < 0 && AppBarConfig.uEdge >= 0)
242  {
245  }
246 
247  if (AppBarConfig.uEdge >= 0)
248  {
250  }
251 
252  if (uEdge >= 0)
253  {
254  AppBarConfig.uEdge = uEdge;
256  }
257  else
258  {
259  RECT rc = AppBarConfig.rcFloating;
260  SetWindowPos(hMainWnd, HWND_TOPMOST, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0);
261  }
262 
263  AppBarConfig.uEdge = uEdge;
264 }
LONG top
Definition: windef.h:292
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:26
#define HWND_TOPMOST
Definition: winuser.h:1194
LONG left
Definition: windef.h:291
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:144
LONG right
Definition: windef.h:293
#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:32
#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:294
#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

Referenced by WndProc().

◆ DoAppBarStuff()

void DoAppBarStuff ( DWORD  mode)

Definition at line 144 of file magnifier.c.

145 {
146  UINT uState;
147  APPBARDATA data = {0};
148  data.cbSize = sizeof(data);
149  data.hWnd = hMainWnd;
150  data.uCallbackMessage = APPMSG_APPBAR;
151 
152  if (mode == ABM_NEW || mode == ABM_SETPOS)
153  {
154  HWND hWndOrder = HWND_BOTTOM;
155  int rcw, rch;
156  RECT rcWorkArea;
157  SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
158 
159  if (mode == ABM_NEW)
160  {
162 
163  switch(AppBarConfig.uEdge)
164  {
165  case ABE_LEFT:
166  data.rc.top = rcWorkArea.top;
167  data.rc.bottom = rcWorkArea.bottom;
168  data.rc.left = rcWorkArea.left;
169  data.rc.right = data.rc.left + AppBarConfig.appBarSizes.left;
170  break;
171  case ABE_TOP:
172  data.rc.left = rcWorkArea.left;
173  data.rc.right = rcWorkArea.right;
174  data.rc.top = rcWorkArea.top;
175  data.rc.bottom = data.rc.top + AppBarConfig.appBarSizes.top;
176  break;
177  case ABE_RIGHT:
178  data.rc.top = rcWorkArea.top;
179  data.rc.bottom = rcWorkArea.bottom;
180  data.rc.right = rcWorkArea.left;
181  data.rc.left = data.rc.right - AppBarConfig.appBarSizes.right;
182  break;
183  case ABE_BOTTOM:
184  data.rc.left = rcWorkArea.left;
185  data.rc.right = rcWorkArea.right;
186  data.rc.bottom = rcWorkArea.bottom;
187  data.rc.top = data.rc.bottom - AppBarConfig.appBarSizes.bottom;
188  break;
189  }
190  }
191  else
192  {
194  }
195 
196  data.uEdge = AppBarConfig.uEdge;
197  uState = SHAppBarMessage(ABM_QUERYPOS, &data);
198  uState = SHAppBarMessage(ABM_SETPOS, &data);
199 
200  rcw = data.rc.right-data.rc.left;
201  rch = data.rc.bottom-data.rc.top;
202 
203  uState = SHAppBarMessage(ABM_GETSTATE, &data);
204  if (uState & ABS_ALWAYSONTOP)
205  hWndOrder = HWND_TOPMOST;
206 
207  SetWindowPos(hMainWnd, hWndOrder, data.rc.left, data.rc.top, rcw, rch, SWP_SHOWWINDOW | SWP_NOCOPYBITS);
208 
209  }
210  else if (mode == ABM_GETSTATE)
211  {
212  HWND hWndOrder = HWND_BOTTOM;
213  uState = SHAppBarMessage(ABM_GETSTATE, &data);
214  if (uState & ABS_ALWAYSONTOP)
215  hWndOrder = HWND_TOPMOST;
216  SetWindowPos(hMainWnd, hWndOrder, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
217  }
218  else if (mode == ABM_ACTIVATE)
219  {
221  }
222  else if (mode == ABM_WINDOWPOSCHANGED)
223  {
225  }
226  else if (mode == ABM_REMOVE)
227  {
229  }
230 }
#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:292
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:26
#define HWND_TOPMOST
Definition: winuser.h:1194
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define ABE_LEFT
Definition: shellapi.h:17
#define APPMSG_APPBAR
Definition: magnifier.c:26
#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:215
#define ABS_ALWAYSONTOP
Definition: shellapi.h:22
#define HWND_BOTTOM
Definition: winuser.h:1191
#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:32
GLenum mode
Definition: glext.h:6217
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ABE_BOTTOM
Definition: shellapi.h:20
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:68
unsigned int UINT
Definition: ndis.h:50
#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:294
#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

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

◆ Draw()

void Draw ( HDC  aDc)

Definition at line 359 of file magnifier.c.

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 / uiZoom;
402  sourceHeight = AppHeight / uiZoom;
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  sourceWidth,
410  sourceHeight);
411 
412  /* Select our bitmap in memory DC and save the old one */
414  }
415 
416  GetWindowRect(hDesktopWindow, &sourceRect);
417  sourceRect.left = (cp.x) - (sourceWidth /2);
418  sourceRect.top = (cp.y) - (sourceHeight /2);
419  sourceRect.right = sourceRect.left + sourceWidth;
420  sourceRect.bottom = sourceRect.top + sourceHeight;
421 
422  GetBestOverlapWithMonitors(&sourceRect);
423 
424  /* Paint the screen bitmap to our in memory DC */
426  0,
427  0,
428  sourceWidth,
429  sourceHeight,
430  desktopHdc,
431  sourceRect.left,
432  sourceRect.top,
433  rop);
434 
435  if (IntersectRect(&intersectedRect, &sourceRect, &targetRect))
436  {
437  OffsetRect(&intersectedRect, -sourceRect.left, -sourceRect.top);
438  FillRect(hdcOffscreen, &intersectedRect, GetStockObject(DC_BRUSH));
439  }
440 
441  /* Draw the mouse pointer in the right position */
443  pMouse.x - iinfo.xHotspot - sourceRect.left, // - 10,
444  pMouse.y - iinfo.yHotspot - sourceRect.top, // - 10,
445  cinfo.hCursor);
446 
447  /* Blast the stretched image from memory DC to window DC */
448  StretchBlt(aDc,
449  0,
450  0,
451  AppWidth,
452  AppHeight,
453  hdcOffscreen,
454  0,
455  0,
456  sourceWidth,
457  sourceHeight,
459 
460  /* Cleanup */
461  if (iinfo.hbmMask)
462  DeleteObject(iinfo.hbmMask);
463  if (iinfo.hbmColor)
464  DeleteObject(iinfo.hbmColor);
465  ReleaseDC(hDesktopWindow, desktopHdc);
466 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define NOMIRRORBITMAP
Definition: wingdi.h:1359
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
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
LONG sourceWidth
Definition: magnifier.c:50
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:42
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
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:410
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:54
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:324
HBITMAP hbmColor
Definition: winuser.h:3080
BOOL WINAPI GetCursorInfo(_Inout_ PCURSORINFO)
HDC hdcOffscreen
Definition: magnifier.c:52
DWORD xHotspot
Definition: winuser.h:3077
POINT pMouse
Definition: magnifier.c:62
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG sourceHeight
Definition: magnifier.c:51
HBITMAP hbmpOffscreen
Definition: magnifier.c:53
HWND hMainWnd
Definition: magnifier.c:32
BOOL bRecreateOffscreenDC
Definition: magnifier.c:49
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
HCURSOR hCursor
Definition: winuser.h:3663
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
UINT uiZoom
Definition: settings.c:14
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:59
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define SRCCOPY
Definition: wingdi.h:332
BOOL bInvertColors
Definition: settings.c:22

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

◆ GetBestOverlapWithMonitors()

void GetBestOverlapWithMonitors ( LPRECT  rect)

Definition at line 326 of file magnifier.c.

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:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
& rect
Definition: startmenu.cpp:1413
struct _test_info info[]
Definition: SetCursorPos.c:19
#define GetMonitorInfo
Definition: winuser.h:5657
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
LONG bottom
Definition: windef.h:294

Referenced by Draw().

◆ HandleNotifyIconMessage()

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

Definition at line 468 of file magnifier.c.

469 {
470  POINT pt;
471 
472  switch(lParam)
473  {
474  case WM_LBUTTONUP:
476  break;
477  case WM_RBUTTONUP:
478  GetCursorPos(&pt);
479  TrackPopupMenu(notifyMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
480  break;
481  }
482 }
#define IDM_OPTIONS
Definition: resource.h:28
#define pt(x, y)
Definition: drawing.c:79
HWND hWnd
Definition: settings.c:17
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:32
#define WM_COMMAND
Definition: winuser.h:1716
#define WM_LBUTTONUP
Definition: winuser.h:1753
HMENU notifyMenu
Definition: magnifier.c:46
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by WndProc().

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 266 of file magnifier.c.

267 {
268  RECT rc;
271 
272  /* Load settings from registry */
273  LoadSettings();
274 
275  rc = AppBarConfig.rcFloating;
276 
277  hInst = hInstance; // Store instance handle in our global variable
278 
279  if (AppBarConfig.uEdge <0 )
280  {
281  dwStyles |= WS_CAPTION;
282  exStyles |= WS_EX_TOPMOST;
283  }
284 
285  /* Create the Window */
286  hMainWnd = CreateWindowEx(exStyles,
288  szTitle,
289  dwStyles,
290  rc.left,
291  rc.top,
292  rc.right-rc.left,
293  rc.bottom-rc.top,
294  NULL,
295  NULL,
296  hInstance,
297  NULL);
298  if (!hMainWnd)
299  return FALSE;
300 
301  if (AppBarConfig.uEdge >= 0)
303  else
305 
306  // In Windows 2003's Magnifier, the "Start Minimized" setting
307  // refers exclusively to the options dialog, not the main window itself.
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:31
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
HWND hOptionsDialog
Definition: magnifier.c:47
#define IDD_WARNINGDIALOG
Definition: resource.h:15
LONG top
Definition: windef.h:292
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:26
#define WS_SIZEBOX
Definition: pedump.c:642
#define HWND_TOPMOST
Definition: winuser.h:1194
LONG left
Definition: windef.h:291
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:144
#define WS_CLIPCHILDREN
Definition: pedump.c:619
LONG right
Definition: windef.h:293
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define DialogBox
Definition: winuser.h:5627
const TCHAR szWindowClass[]
Definition: magnifier.c:28
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:860
#define ABM_NEW
Definition: shellapi.h:59
unsigned long DWORD
Definition: ntddk_ex.h:95
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
HWND hMainWnd
Definition: magnifier.c:32
#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:968
BOOL bShowWarning
Definition: settings.c:16
LONG bottom
Definition: windef.h:294
#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:23
#define WS_SYSMENU
Definition: pedump.c:629
#define CreateDialog
Definition: winuser.h:5615

Referenced by WinMain().

◆ MyRegisterClass()

ATOM MyRegisterClass ( HINSTANCE  hInstance)

Definition at line 126 of file magnifier.c.

127 {
128  WNDCLASS wc;
129 
130  wc.style = CS_HREDRAW | CS_VREDRAW;
131  wc.lpfnWndProc = WndProc;
132  wc.cbClsExtra = 0;
133  wc.cbWndExtra = 0;
134  wc.hInstance = hInstance;
137  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
138  wc.lpszMenuName = NULL; //MAKEINTRESOURCE(IDC_MAGNIFIER);
140 
141  return RegisterClass(&wc);
142 }
#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:28
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:484
HICON hIcon
Definition: winuser.h:3121

Referenced by WinMain().

◆ OptionsProc()

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

Definition at line 860 of file magnifier.c.

861 {
863 
864  switch (message)
865  {
866  case WM_INITDIALOG:
867  {
868  /* Add the zoom items */
869  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("1"));
870  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("2"));
871  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("3"));
872  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("4"));
873  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("5"));
874  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("6"));
875  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("7"));
876  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("8"));
877  SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("9"));
878 
879  if (uiZoom >= 1 && uiZoom <= 9)
881 
882  if (bFollowMouse)
884 
885  if (bFollowFocus)
887 
888  if (bFollowCaret)
890 
891  if (bInvertColors)
893 
894  if (bStartMinimized)
896 
897  if (bShowMagnifier)
899 
900  return (INT_PTR)TRUE;
901  }
902 
903  case WM_SHOWWINDOW:
905  break;
906 
907  case WM_COMMAND:
908  switch (LOWORD(wParam))
909  {
910  case IDOK:
911  case IDCANCEL:
912  ShowWindow(hDlg, SW_HIDE);
913  return (INT_PTR)TRUE;
914 
915  case IDC_BUTTON_HELP:
916  /* Unimplemented */
917  MessageBox(hDlg, TEXT("Magnifier help not available yet!"), TEXT("Help"), MB_OK);
918  break;
919 
920  case IDC_ZOOM:
921  if (HIWORD(wParam) == CBN_SELCHANGE)
922  {
923  HWND hCombo = GetDlgItem(hDlg,IDC_ZOOM);
924  TCHAR currentZoomValue[2] = TEXT("");
925 
926  /* Get index of current selection and the text of that selection */
927  int currentSelectionIndex = ComboBox_GetCurSel(hCombo);
928  ComboBox_GetLBText(hCombo, currentSelectionIndex, currentZoomValue);
929  uiZoom = (UINT)_ttoi(currentZoomValue);
930  /* The zoom factor cannot be smaller than 1 (and not zero) or greater than 9 */
931  if (uiZoom < 1 || uiZoom > 9)
932  uiZoom = 1;
933 
934  /* Trigger the Draw function to rezoom (which will be set false automatically after rezooming) */
936 
937  /* Update the magnifier UI */
938  Refresh();
939  }
940  break;
941 
944  Refresh();
945  break;
948  break;
951  break;
954  break;
957  break;
958  case IDC_SHOWMAGNIFIER:
961  break;
962  }
963  }
964 
965  return (INT_PTR)FALSE;
966 }
#define IDC_FOLLOWKEYBOARDCHECK
Definition: resource.h:17
BOOL bShowMagnifier
Definition: settings.c:24
#define IDC_ZOOM
Definition: resource.h:16
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#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
BOOL bOptionsDialog
Definition: magnifier.c:48
#define CB_ADDSTRING
Definition: winuser.h:1897
#define IDC_SHOWMAGNIFIER
Definition: resource.h:21
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOW
Definition: winuser.h:769
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
char TCHAR
Definition: xmlstorage.h:189
#define BM_SETCHECK
Definition: winuser.h:1882
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND hMainWnd
Definition: magnifier.c:32
BOOL bRecreateOffscreenDC
Definition: magnifier.c:49
BOOL bFollowMouse
Definition: settings.c:18
#define MessageBox
Definition: winuser.h:5688
#define CB_SETCURSEL
Definition: winuser.h:1922
#define WM_COMMAND
Definition: winuser.h:1716
UINT uiZoom
Definition: settings.c:14
#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:20
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
#define CBN_SELCHANGE
Definition: winuser.h:1940
void Refresh(void)
Definition: magnifier.c:317
#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:23
#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:22
BOOL bFollowFocus
Definition: settings.c:19

Referenced by InitInstance().

◆ Refresh()

void Refresh ( void  )

Definition at line 317 of file magnifier.c.

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:32

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

◆ WarningProc()

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

Definition at line 968 of file magnifier.c.

969 {
971 
972  switch (message)
973  {
974  case WM_INITDIALOG:
975  return (INT_PTR)TRUE;
976 
977  case WM_COMMAND:
978  switch (LOWORD(wParam))
979  {
982  break;
983  }
984  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
985  {
986  EndDialog(hDlg, LOWORD(wParam));
987  return (INT_PTR)TRUE;
988  }
989  break;
990  }
991 
992  return (INT_PTR)FALSE;
993 }
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:16
#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

Referenced by InitInstance().

◆ WinMain()

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

Definition at line 75 of file magnifier.c.

76 {
77  MSG msg;
78  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 */
97 
98  /* Perform application initialization */
99  if (!InitInstance(hInstance, nCmdShow))
100  return FALSE;
101 
103 
104  /* Main message loop */
105  while (GetMessage(&msg, NULL, 0, 0))
106  {
107  if (!TranslateAccelerator(hMainWnd, hAccelTable, &msg))
108  {
111  }
112  }
113 
114  /* Load the common controls */
115  iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
117  InitCommonControlsEx(&iccex);
118 
122 
123  return (int) msg.wParam;
124 }
#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:806
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define LAYOUT_RTL
Definition: wingdi.h:1353
#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:266
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define LANG_HEBREW
Definition: nls.h:67
#define LoadAccelerators
Definition: winuser.h:5676
HINSTANCE hInstance
Definition: charmap.c:20
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
HANDLE hbmpOld
Definition: magnifier.c:54
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
HDC hdcOffscreen
Definition: magnifier.c:52
ATOM MyRegisterClass(HINSTANCE hInstance)
Definition: magnifier.c:126
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
HBITMAP hbmpOffscreen
Definition: magnifier.c:53
HWND hMainWnd
Definition: magnifier.c:32
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
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 ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define LoadString
Definition: winuser.h:5685
#define MAX_LOADSTRING
Definition: magnifier.c:34

◆ WndProc()

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

Definition at line 484 of file magnifier.c.

485 {
486  int wmId;
487 
488  switch (message)
489  {
490  case WM_TIMER:
491  {
492  BOOL hasMoved = FALSE;
493 
494  GUITHREADINFO guiInfo;
495  guiInfo.cbSize = sizeof(guiInfo);
496 
497  GetGUIThreadInfo(0, &guiInfo);
498 
499  if (bFollowMouse)
500  {
501  POINT pNewMouse;
502 
503  //Get current mouse position
504  GetCursorPos (&pNewMouse);
505 
506 #define PointsAreEqual(pt1, pt2) (((pt1).x == (pt2).x) && ((pt1).y == (pt2).y))
507 
508  //If mouse has moved ...
509  if (!PointsAreEqual(pMouse, pNewMouse))
510  {
511  //Update to new position
512  pMouse = pNewMouse;
513  cp = pNewMouse;
514  hasMoved = TRUE;
515  }
516  }
517 
518  if (guiInfo.hwndActive != hMainWnd)
519  {
520  if (bFollowCaret)
521  {
522  if (guiInfo.hwndCaret)
523  {
524  POINT ptCaret;
525  ptCaret.x = (guiInfo.rcCaret.left + guiInfo.rcCaret.right) / 2;
526  ptCaret.y = (guiInfo.rcCaret.top + guiInfo.rcCaret.bottom) / 2;
527 
528  if ((pCaretWnd != guiInfo.hwndCaret) || !PointsAreEqual(pCaret, ptCaret))
529  {
530  //Update to new position
531  pCaret = ptCaret;
532  pCaretWnd = guiInfo.hwndCaret;
533  if (!hasMoved)
534  {
535  ClientToScreen (guiInfo.hwndCaret, (LPPOINT) &ptCaret);
536  cp = ptCaret;
537  hasMoved = TRUE;
538  }
539  }
540  }
541  else
542  {
543  pCaretWnd = NULL;
544  }
545  }
546 
547  if (bFollowFocus)
548  {
549  if (guiInfo.hwndFocus && !guiInfo.hwndCaret)
550  {
551  POINT ptFocus;
552  RECT activeRect;
553 
554  //Get current control focus
555  GetWindowRect(guiInfo.hwndFocus, &activeRect);
556  ptFocus.x = (activeRect.left + activeRect.right) / 2;
557  ptFocus.y = (activeRect.top + activeRect.bottom) / 2;
558 
559  if ((guiInfo.hwndFocus != pFocusWnd) || !PointsAreEqual(pFocus, ptFocus))
560  {
561  //Update to new position
562  pFocus = ptFocus;
563  pFocusWnd = guiInfo.hwndFocus;
564  if (!hasMoved)
565  {
566  cp = ptFocus;
567  hasMoved = TRUE;
568  }
569  }
570  }
571  else
572  {
573  pFocusWnd = NULL;
574  }
575  }
576  }
577 
578  if (!hasMoved)
579  {
580  DWORD newTicks = GetTickCount();
581  DWORD elapsed = (newTicks - lastTicks);
582  if (elapsed > REPAINT_SPEED)
583  {
584  hasMoved = TRUE;
585  }
586  }
587 
588  if (hasMoved)
589  {
591  Refresh();
592  }
593 
594  return 0;
595  }
596 
597  case WM_COMMAND:
598  {
599  wmId = LOWORD(wParam);
600  /* Parse the menu selections */
601  switch (wmId)
602  {
603  case IDM_OPTIONS:
605  break;
606  case IDM_ABOUT:
608  break;
609  case IDM_EXIT:
611  break;
612  default:
614  }
615  return 0;
616  }
617 
618  case WM_PAINT:
619  {
620  PAINTSTRUCT PaintStruct;
621  HDC dc;
622  dc = BeginPaint(hWnd, &PaintStruct);
623  Draw(dc);
624  EndPaint(hWnd, &PaintStruct);
625  return 0;
626  }
627 
628  case WM_CONTEXTMENU:
630  return 0;
631 
632  case WM_LBUTTONDOWN:
633  {
634  RECT rc;
635  POINT pt;
636  SetCapture(hWnd);
637 
638  GetCursorPos(&pt);
639  GetWindowRect(hWnd, &rc);
640  ptDragOffset.x = pt.x - rc.left;
641  ptDragOffset.y = pt.y - rc.top;
642 
643  nearEdge = AppBarConfig.uEdge;
644 
645  break;
646  }
647 
648  case WM_MOUSEMOVE:
649  if (GetCapture() == hWnd)
650  {
651  RECT rc;
652  POINT pt;
653  RECT rcWorkArea;
654  SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
655  GetCursorPos(&pt);
656  GetWindowRect(hWnd, &rc);
657 
658  if (AppBarConfig.uEdge >= 0)
659  {
660  if (pt.x >= rcWorkArea.left && pt.x <= rcWorkArea.right &&
661  pt.y >= rcWorkArea.top && pt.y <= rcWorkArea.bottom)
662  {
663  AttachAppBar(-2);
664 
665  // Fixup offset
666  GetWindowRect(hWnd, &rc);
667  ptDragOffset.x = (rc.right-rc.left)/2;
668  ptDragOffset.y = 2;
669 
670  rc.left = pt.x - ptDragOffset.x;
671  rc.top = pt.y - ptDragOffset.y;
672 
673  SetWindowPos(hWnd, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
674  }
675  }
676  else
677  {
678  if (pt.x <= rcWorkArea.left+8 && nearEdge != ABE_LEFT)
679  {
681  nearEdge = ABE_LEFT;
682  }
683  else if (pt.y <= rcWorkArea.top+8 && nearEdge != ABE_TOP)
684  {
686  nearEdge = ABE_TOP;
687  }
688  else if (pt.x >= rcWorkArea.right-8 && nearEdge != ABE_RIGHT)
689  {
692  }
693  else if (pt.y >= rcWorkArea.bottom-8 && nearEdge != ABE_BOTTOM)
694  {
697  }
698  else
699  {
700  rc.left = pt.x - ptDragOffset.x;
701  rc.top = pt.y - ptDragOffset.y;
702 
703  SetWindowPos(hWnd, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
704  nearEdge = -1;
705  }
706  }
707 
708  pMouse = pt;
709  Refresh();
710  }
711  break;
712 
713  case WM_LBUTTONUP:
714  if (GetCapture() == hWnd)
715  {
716  if (AppBarConfig.uEdge >= 0)
718  else
720  ReleaseCapture();
721  }
722  break;
723 
724  case WM_SIZE:
725  if (AppBarConfig.uEdge >= 0)
727  /* fallthrough */
728  case WM_DISPLAYCHANGE:
730  Refresh();
731  break;
732 
733  case WM_ERASEBKGND:
734  // handle WM_ERASEBKGND by simply returning non-zero because we did all the drawing in WM_PAINT.
735  return 0;
736 
737  case WM_DESTROY:
738  {
739  if (AppBarConfig.uEdge >= 0)
741 
742  KillTimer(hWnd, 1);
743 
744  /* Save settings to registry */
745  SaveSettings();
746 
747  /* Cleanup notification icon */
748  ZeroMemory(&nid, sizeof(nid));
749  nid.cbSize = sizeof(nid);
751  nid.hWnd = hWnd;
755 
757 
758  PostQuitMessage(0);
759  return 0;
760  }
761 
762  case WM_CREATE:
763  {
764  HMENU tempMenu;
765 
766  /* Get the desktop window */
768 
769  /* Set the timer */
771 
772  /* Notification icon */
774 
775  ZeroMemory(&nid, sizeof(nid));
776  nid.cbSize = sizeof(nid);
778  nid.hWnd = hWnd;
780  nid.hIcon = notifyIcon;
782 
784  notifyMenu = GetSubMenu(tempMenu, 0);
785  RemoveMenu(tempMenu, 0, MF_BYPOSITION);
786  DestroyMenu(tempMenu);
787  return 0;
788  }
789 
790  case APPMSG_APPBAR:
791  {
792  switch (wParam)
793  {
794  case ABN_STATECHANGE:
796  break;
797  case ABN_POSCHANGED:
799  break;
800  case ABN_FULLSCREENAPP:
801  {
802  if (!lParam)
803  {
805  break;
806  }
807 
809  break;
810  }
811  case ABN_WINDOWARRANGE:
813  break;
814  }
815  return 0;
816  }
817 
818  case APPMSG_NOTIFYICON:
820  return 0;
821 
822  case WM_ACTIVATE:
823  if (AppBarConfig.uEdge >= 0)
825  break;
826 
827  case WM_WINDOWPOSCHANGED:
828  if (AppBarConfig.uEdge >= 0)
830  Refresh();
831  break;
832 
833  default:
834  break;
835  }
836 
838 }
#define IDM_OPTIONS
Definition: resource.h:28
#define IDI_ICON
Definition: resource.h:5
HINSTANCE hInst
Definition: magnifier.c:31
#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:840
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:65
long x
Definition: polytest.cpp:48
void AttachAppBar(INT uEdge)
Definition: magnifier.c:232
NOTIFYICONDATA nid
Definition: magnifier.c:44
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:47
static HDC
Definition: imagelist.c:92
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:292
#define REPAINT_SPEED
Definition: magnifier.c:38
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
struct _AppBarConfig_t AppBarConfig
Definition: settings.c:26
#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:42
LONG left
Definition: windef.h:291
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
void DoAppBarStuff(DWORD mode)
Definition: magnifier.c:144
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:293
#define ABE_LEFT
Definition: shellapi.h:17
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define APPMSG_APPBAR
Definition: magnifier.c:26
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#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:48
HWND WINAPI GetCapture(void)
Definition: message.c:2879
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 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
#define WM_SIZE
Definition: winuser.h:1593
#define WM_TIMER
Definition: winuser.h:1718
POINT pMouse
Definition: magnifier.c:62
INT nearEdge
Definition: magnifier.c:56
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:45
#define PointsAreEqual(pt1, pt2)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HWND hMainWnd
Definition: magnifier.c:32
BOOL bRecreateOffscreenDC
Definition: magnifier.c:49
POINT pFocus
Definition: magnifier.c:64
BOOL bFollowMouse
Definition: settings.c:18
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1716
#define TIMER_SPEED
Definition: magnifier.c:37
#define ABN_FULLSCREENAPP
Definition: shellapi.h:71
BOOL WINAPI DestroyMenu(_In_ HMENU)
UINT uCallbackMessage
Definition: shellapi.h:229
#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:20
HWND pFocusWnd
Definition: magnifier.c:66
#define ABM_WINDOWPOSCHANGED
Definition: shellapi.h:68
POINT pCaret
Definition: magnifier.c:63
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define IDM_EXIT
Definition: resource.h:27
POINT ptDragOffset
Definition: magnifier.c:55
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define NIM_ADD
Definition: shellapi.h:91
DWORD lastTicks
Definition: magnifier.c:40
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
POINT cp
Definition: magnifier.c:59
#define Shell_NotifyIcon
Definition: shellapi.h:687
#define APPMSG_NOTIFYICON
Definition: magnifier.c:25
#define WM_CREATE
Definition: winuser.h:1590
void Refresh(void)
Definition: magnifier.c:317
#define ABM_REMOVE
Definition: shellapi.h:60
void HandleNotifyIconMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
Definition: magnifier.c:468
LONG bottom
Definition: windef.h:294
#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:46
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:19
BOOL WINAPI GetGUIThreadInfo(DWORD, LPGUITHREADINFO)
Definition: ntwrapper.h:398

Referenced by MyRegisterClass().

Variable Documentation

◆ bOptionsDialog

BOOL bOptionsDialog = FALSE

Definition at line 48 of file magnifier.c.

Referenced by OptionsProc(), and WndProc().

◆ bRecreateOffscreenDC

BOOL bRecreateOffscreenDC = TRUE

Definition at line 49 of file magnifier.c.

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

◆ cp

POINT cp

Definition at line 59 of file magnifier.c.

Referenced by __GetDefaultCP(), __GetLCIDFromName(), __GetLocaleInfoUsingACP(), __GetLocaleName(), __intGetACP(), __intGetOCP(), __subformat(), __TranslateToSystem(), _bdf_add_comment(), _get_next_token(), _Locale_common_default(), _setmbcp(), _setmbcp_l(), _TIFFCheckRealloc(), _TIFFprintAscii(), _TIFFprintAsciiBounded(), _TIFFsetNString(), _TIFFsetString(), add_file(), add_param(), AddrStrToAddr(), AddrToAddrStr(), adns_inet_aton(), advise_prop_notif(), 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(), ConnectionPoint_Create(), ConnectionPoint_Init(), ConnectionPointContainer_FindConnectionPoint(), create_event_sink(), DECLAREContigPutFunc(), DECLARESepPutFunc(), DecodeDirectoryURL(), DefaultBookmarkName(), detach_plugin_host(), do_advise(), DoCommand(), Draw(), 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(), fnIMultiLanguage_GetFamilyCodePage(), fnIMultiLanguage_GetNumberOfCodePageInfo(), FONT_mbtowc(), for(), fpAcc(), fpDiff(), ftGdiGetTextCharsetInfo(), FTPChdir3(), FTPDecodeURL(), FTPFtw(), FTPFtwL2(), FTPGetFiles3(), FTPLocalRecursiveFileList2(), FTPMkdir2(), FTPPutOneF(), FTPQueryFeatures(), FTPRemoteGlob(), get_code_page(), get_cp(), get_encoding_from_codepage(), get_input_codepage(), GetBookmark(), GetCalendarInfoA(), 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(), horner_bezier_curve(), horner_bezier_surf(), HTMLDocument_on_advise(), inet_addr(), inet_aton(), init_output_buffer(), InitOurDirectory(), InitUserInfo(), interpret(), ipaddr_addr(), ipaddr_aton(), iso9660_file_length(), ITextDocument2Old_fnGetPreferredFont(), Load_CP2Unicode_Table(), LoadFirewallPrefs(), Ls(), LsCacheAdd(), LsMonthNameToNum(), main(), map_wparam_char_WtoA(), MatchRegExp(), mdelete(), ME_CharFromPointContext(), ME_StreamInText(), memrchr(), MFDRV_ExtTextOut(), mget(), MkDirs(), mlang_getcodepageinfo(), mlang_getcsetinfo_from_cp(), 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(), PrefOptCompletionFunction(), PrintStartupBanner(), PropertyStorage_StoreNameWithId(), PushBackTrackState(), pvd_write(), ReadColorTbl(), reader_more(), readerinput_switchencoding(), Readline(), register_cp(), remglob(), RemoteCompletionFunction(), RemoteDirCompletionFunction(), RemoteFileCompletionFunction(), RemoteGlobCollapse(), request_send(), RichEditOleCallback_QueryInsertObject(), RTFDestroyAttrs(), scan_dir(), SError(), ServiceNameToPortNumber(), setnmap(), setpeer(), ShellCmd(), simple_strtol(), simple_strtoul(), split_params(), StrDup(), strntokc(), StrRemoveTrailingSlashes(), strtokc(), subdirs(), TabbedTextOutA(), test__ismbclx(), test_CodePageToScriptID(), test_ConnectionPoint(), test_cp_table(), test_dbcs_wm_char(), test_empty_document(), test_iframe_connections(), test_IMLangConvertCharset(), test_IWinHttpRequest(), test_Load(), test_mbbtombc(), test_mbcjisjms(), test_mbcjmsjis(), 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_doc_cp_events(), update_threadlocinfo_category(), vers_write(), Vt100VisibleStrlen(), win_iconv(), WINHELP_FindLink(), WINHELP_SetupText(), winhttp_request_put_Option(), WinMain(), WndProc(), write_nls_files(), WriteDefaultFirewallPrefs(), xdr_char(), xdr_opaque(), xdr_u_char(), Mapdesc::xformCulling(), Mapdesc::xformMat(), and ZSTD_getCParams().

◆ hbmpOffscreen

HBITMAP hbmpOffscreen = NULL

Definition at line 53 of file magnifier.c.

Referenced by Draw(), and WinMain().

◆ hbmpOld

◆ hdcOffscreen

HDC hdcOffscreen = NULL

Definition at line 52 of file magnifier.c.

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

◆ hDesktopWindow

HWND hDesktopWindow = NULL

Definition at line 42 of file magnifier.c.

Referenced by Draw(), and WndProc().

◆ hInst

HINSTANCE hInst

Definition at line 31 of file magnifier.c.

Referenced by InitInstance(), and WndProc().

◆ hMainWnd

HWND hMainWnd

Definition at line 32 of file magnifier.c.

Referenced by _tWinMain(), AffinityDialogWndProc(), ApplicationPage_OnSwitchTo(), ApplicationPage_OnView(), ApplicationPageShowContextMenu1(), ApplicationPageShowContextMenu2(), ApplicationPageUpdate(), ApplicationPageWndProc(), AttachAppBar(), close_preview(), create_main_test_wnd(), CreateMainWindow(), dialog_print(), dialog_print_to_file(), dialog_printsetup(), DoAppBarStuff(), DoSetPriority(), CDownloadManager::DownloadDlgProc(), Draw(), EnumWindowsProc(), FrameOnSize(), get_ruler_wnd(), HandleNotifyIconMessage(), HSplitterWindowProc(), ImageView_CreateWindow(), init_preview(), InitInstance(), CDownloadManager::LaunchDownloadDialog(), MACRO_About(), MainWindow_OnSize(), MainWindow_WndProc(), MessageBox_LoadString(), OnAbout(), OptionsProc(), PerformancePage_OnViewCPUHistoryOneGraphAll(), PerformancePage_OnViewCPUHistoryOneGraphPerCPU(), PerformancePage_OnViewShowKernelTimes(), preview_bar_show(), preview_proc(), print_quick(), ProcessPage_OnDebug(), ProcessPage_OnDebugChannels(), ProcessPage_OnEndProcess(), ProcessPage_OnEndProcessTree(), ProcessPage_OnSetAffinity(), ProcessPage_OnViewSelectColumns(), ProcessPageShowContextMenu(), Refresh(), registry_read_filelist(), registry_set_filelist(), registry_set_options(), RemoveAppFromRegistry(), ShowAboutDialog(), ShowPopupMenu(), StartProcess(), target_device(), TaskManager_OnFileNew(), TaskManager_OnOptionsAlwaysOnTop(), TaskManager_OnOptionsHideWhenMinimized(), TaskManager_OnOptionsMinimizeOnUse(), TaskManager_OnOptionsShow16BitTasks(), test_GetScrollBarInfo(), CDownloadManager::ThreadFunc(), toggle_num_pages(), TrayIcon_ShellAddTrayIcon(), TrayIcon_ShellRemoveTrayIcon(), TrayIcon_ShellUpdateTrayIcon(), update_preview(), update_preview_buttons(), update_preview_statusbar(), VSplitterWindowProc(), WinMain(), WndProc(), and wWinMain().

◆ hOptionsDialog

HWND hOptionsDialog

Definition at line 47 of file magnifier.c.

Referenced by InitInstance(), and WndProc().

◆ lastTicks

DWORD lastTicks = 0

Definition at line 40 of file magnifier.c.

Referenced by WndProc().

◆ nearEdge

INT nearEdge

Definition at line 56 of file magnifier.c.

Referenced by WndProc().

◆ nid

◆ notifyIcon

HICON notifyIcon

Definition at line 45 of file magnifier.c.

Referenced by WndProc().

◆ notifyMenu

HMENU notifyMenu

Definition at line 46 of file magnifier.c.

Referenced by HandleNotifyIconMessage(), and WndProc().

◆ pCaret

POINT pCaret

Definition at line 63 of file magnifier.c.

Referenced by WndProc().

◆ pCaretWnd

HWND pCaretWnd

Definition at line 65 of file magnifier.c.

Referenced by WndProc().

◆ pFocus

POINT pFocus

Definition at line 64 of file magnifier.c.

Referenced by WndProc().

◆ pFocusWnd

HWND pFocusWnd

Definition at line 66 of file magnifier.c.

Referenced by WndProc().

◆ pMouse

POINT pMouse

Definition at line 62 of file magnifier.c.

Referenced by Draw(), test_acquire(), test_set_coop(), and WndProc().

◆ ptDragOffset

POINT ptDragOffset

Definition at line 55 of file magnifier.c.

Referenced by WndProc().

◆ sourceHeight

LONG sourceHeight = 0

Definition at line 51 of file magnifier.c.

Referenced by Draw().

◆ sourceWidth

LONG sourceWidth = 0

Definition at line 50 of file magnifier.c.

Referenced by Draw().

◆ szTitle

◆ szWindowClass

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