mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[MAGNIFY] Minor whitespace / formatting fixes; use the new file headers + some code simplifications here and there...
This commit is contained in:
parent
4e91b6d5db
commit
16646fb19c
3 changed files with 190 additions and 215 deletions
|
@ -1,11 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Magnify
|
* PROJECT: ReactOS Magnify
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* FILE: base/applications/magnify/magnifier.c
|
|
||||||
* PURPOSE: Magnification of parts of the screen.
|
* PURPOSE: Magnification of parts of the screen.
|
||||||
* AUTHORS:
|
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
|
||||||
* Marc Piulachs <marc.piulachs@codexchange.net>
|
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
|
||||||
* David Quintana <gigaherz@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: Support AppBar types other than ABE_TOP */
|
/* TODO: Support AppBar types other than ABE_TOP */
|
||||||
|
@ -158,7 +156,7 @@ void DoAppBarStuff(DWORD mode)
|
||||||
RECT rcWorkArea;
|
RECT rcWorkArea;
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
|
||||||
|
|
||||||
if(mode == ABM_NEW)
|
if (mode == ABM_NEW)
|
||||||
{
|
{
|
||||||
SHAppBarMessage(ABM_NEW, &data);
|
SHAppBarMessage(ABM_NEW, &data);
|
||||||
|
|
||||||
|
@ -197,36 +195,35 @@ void DoAppBarStuff(DWORD mode)
|
||||||
|
|
||||||
data.uEdge = AppBarConfig.uEdge;
|
data.uEdge = AppBarConfig.uEdge;
|
||||||
uState = SHAppBarMessage(ABM_QUERYPOS, &data);
|
uState = SHAppBarMessage(ABM_QUERYPOS, &data);
|
||||||
|
|
||||||
uState = SHAppBarMessage(ABM_SETPOS, &data);
|
uState = SHAppBarMessage(ABM_SETPOS, &data);
|
||||||
|
|
||||||
rcw = data.rc.right-data.rc.left;
|
rcw = data.rc.right-data.rc.left;
|
||||||
rch = data.rc.bottom-data.rc.top;
|
rch = data.rc.bottom-data.rc.top;
|
||||||
|
|
||||||
uState = SHAppBarMessage(ABM_GETSTATE, &data);
|
uState = SHAppBarMessage(ABM_GETSTATE, &data);
|
||||||
if(uState & ABS_ALWAYSONTOP)
|
if (uState & ABS_ALWAYSONTOP)
|
||||||
hWndOrder = HWND_TOPMOST;
|
hWndOrder = HWND_TOPMOST;
|
||||||
|
|
||||||
SetWindowPos(hMainWnd, hWndOrder, data.rc.left, data.rc.top, rcw, rch, SWP_SHOWWINDOW|SWP_NOCOPYBITS);
|
SetWindowPos(hMainWnd, hWndOrder, data.rc.left, data.rc.top, rcw, rch, SWP_SHOWWINDOW | SWP_NOCOPYBITS);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(mode == ABM_GETSTATE)
|
else if (mode == ABM_GETSTATE)
|
||||||
{
|
{
|
||||||
HWND hWndOrder = HWND_BOTTOM;
|
HWND hWndOrder = HWND_BOTTOM;
|
||||||
uState = SHAppBarMessage(ABM_GETSTATE, &data);
|
uState = SHAppBarMessage(ABM_GETSTATE, &data);
|
||||||
if(uState & ABS_ALWAYSONTOP)
|
if (uState & ABS_ALWAYSONTOP)
|
||||||
hWndOrder = HWND_TOPMOST;
|
hWndOrder = HWND_TOPMOST;
|
||||||
SetWindowPos(hMainWnd, hWndOrder, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
SetWindowPos(hMainWnd, hWndOrder, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
||||||
}
|
}
|
||||||
else if(mode == ABM_ACTIVATE)
|
else if (mode == ABM_ACTIVATE)
|
||||||
{
|
{
|
||||||
SHAppBarMessage(ABM_ACTIVATE, &data);
|
SHAppBarMessage(ABM_ACTIVATE, &data);
|
||||||
}
|
}
|
||||||
else if(mode == ABM_WINDOWPOSCHANGED)
|
else if (mode == ABM_WINDOWPOSCHANGED)
|
||||||
{
|
{
|
||||||
SHAppBarMessage(ABM_WINDOWPOSCHANGED, &data);
|
SHAppBarMessage(ABM_WINDOWPOSCHANGED, &data);
|
||||||
}
|
}
|
||||||
else if(mode == ABM_REMOVE)
|
else if (mode == ABM_REMOVE)
|
||||||
{
|
{
|
||||||
SHAppBarMessage(ABM_REMOVE, &data);
|
SHAppBarMessage(ABM_REMOVE, &data);
|
||||||
}
|
}
|
||||||
|
@ -237,22 +234,22 @@ void AttachAppBar(INT uEdge)
|
||||||
if (AppBarConfig.uEdge == uEdge)
|
if (AppBarConfig.uEdge == uEdge)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(AppBarConfig.uEdge < 0 && uEdge >= 0)
|
if (AppBarConfig.uEdge < 0 && uEdge >= 0)
|
||||||
{
|
{
|
||||||
SetWindowLongPtr(hMainWnd, GWL_STYLE, GetWindowLongPtr(hMainWnd, GWL_STYLE) & (~WS_CAPTION));
|
SetWindowLongPtr(hMainWnd, GWL_STYLE, GetWindowLongPtr(hMainWnd, GWL_STYLE) & (~WS_CAPTION));
|
||||||
}
|
}
|
||||||
else if(uEdge < 0 && AppBarConfig.uEdge>=0)
|
else if (uEdge < 0 && AppBarConfig.uEdge >= 0)
|
||||||
{
|
{
|
||||||
SetWindowLongPtr(hMainWnd, GWL_STYLE, GetWindowLongPtr(hMainWnd, GWL_STYLE) | WS_CAPTION);
|
SetWindowLongPtr(hMainWnd, GWL_STYLE, GetWindowLongPtr(hMainWnd, GWL_STYLE) | WS_CAPTION);
|
||||||
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
|
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AppBarConfig.uEdge >= 0)
|
if (AppBarConfig.uEdge >= 0)
|
||||||
{
|
{
|
||||||
DoAppBarStuff(ABM_REMOVE);
|
DoAppBarStuff(ABM_REMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uEdge >=0)
|
if (uEdge >= 0)
|
||||||
{
|
{
|
||||||
AppBarConfig.uEdge = uEdge;
|
AppBarConfig.uEdge = uEdge;
|
||||||
DoAppBarStuff(ABM_NEW);
|
DoAppBarStuff(ABM_NEW);
|
||||||
|
@ -279,15 +276,14 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
|
|
||||||
hInst = hInstance; // Store instance handle in our global variable
|
hInst = hInstance; // Store instance handle in our global variable
|
||||||
|
|
||||||
if (AppBarConfig.uEdge<0)
|
if (AppBarConfig.uEdge <0 )
|
||||||
{
|
{
|
||||||
dwStyles |= WS_CAPTION;
|
dwStyles |= WS_CAPTION;
|
||||||
exStyles |= WS_EX_TOPMOST;
|
exStyles |= WS_EX_TOPMOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the Window */
|
/* Create the Window */
|
||||||
hMainWnd = CreateWindowEx(
|
hMainWnd = CreateWindowEx(exStyles,
|
||||||
exStyles,
|
|
||||||
szWindowClass,
|
szWindowClass,
|
||||||
szTitle,
|
szTitle,
|
||||||
dwStyles,
|
dwStyles,
|
||||||
|
@ -299,20 +295,18 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
NULL,
|
NULL,
|
||||||
hInstance,
|
hInstance,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (!hMainWnd)
|
if (!hMainWnd)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_NEW);
|
if (AppBarConfig.uEdge >= 0)
|
||||||
else SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
DoAppBarStuff(ABM_NEW);
|
||||||
|
else
|
||||||
|
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
// In Windows 2003's Magnifier, the "Start Minimized" setting
|
// In Windows 2003's Magnifier, the "Start Minimized" setting
|
||||||
// refers exclusively to the options dialog, not the main window itself.
|
// refers exclusively to the options dialog, not the main window itself.
|
||||||
hOptionsDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOGOPTIONS), hMainWnd, OptionsProc);
|
hOptionsDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOGOPTIONS), hMainWnd, OptionsProc);
|
||||||
if (bStartMinimized)
|
ShowWindow(hOptionsDialog, (bStartMinimized ? SW_HIDE : SW_SHOW));
|
||||||
ShowWindow(hOptionsDialog, SW_HIDE);
|
|
||||||
else
|
|
||||||
ShowWindow(hOptionsDialog, SW_SHOW);
|
|
||||||
|
|
||||||
if (bShowWarning)
|
if (bShowWarning)
|
||||||
DialogBox(hInstance, MAKEINTRESOURCE(IDD_WARNINGDIALOG), hMainWnd, WarningProc);
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_WARNINGDIALOG), hMainWnd, WarningProc);
|
||||||
|
@ -320,7 +314,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Refresh()
|
void Refresh(void)
|
||||||
{
|
{
|
||||||
if (!IsIconic(hMainWnd))
|
if (!IsIconic(hMainWnd))
|
||||||
{
|
{
|
||||||
|
@ -397,7 +391,7 @@ void Draw(HDC aDc)
|
||||||
{
|
{
|
||||||
bRecreateOffscreenDC = FALSE;
|
bRecreateOffscreenDC = FALSE;
|
||||||
|
|
||||||
if(hdcOffscreen)
|
if (hdcOffscreen)
|
||||||
{
|
{
|
||||||
SelectObject(hdcOffscreen, hbmpOld);
|
SelectObject(hdcOffscreen, hbmpOld);
|
||||||
DeleteObject (hbmpOffscreen);
|
DeleteObject (hbmpOffscreen);
|
||||||
|
@ -411,13 +405,12 @@ void Draw(HDC aDc)
|
||||||
hdcOffscreen = CreateCompatibleDC(desktopHdc);
|
hdcOffscreen = CreateCompatibleDC(desktopHdc);
|
||||||
|
|
||||||
/* Create a bitmap compatible with the client area DC */
|
/* Create a bitmap compatible with the client area DC */
|
||||||
hbmpOffscreen = CreateCompatibleBitmap(
|
hbmpOffscreen = CreateCompatibleBitmap(desktopHdc,
|
||||||
desktopHdc,
|
|
||||||
sourceWidth,
|
sourceWidth,
|
||||||
sourceHeight);
|
sourceHeight);
|
||||||
|
|
||||||
/* Select our bitmap in memory DC and save the old one */
|
/* Select our bitmap in memory DC and save the old one */
|
||||||
hbmpOld = SelectObject(hdcOffscreen , hbmpOffscreen);
|
hbmpOld = SelectObject(hdcOffscreen, hbmpOffscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWindowRect(hDesktopWindow, &sourceRect);
|
GetWindowRect(hDesktopWindow, &sourceRect);
|
||||||
|
@ -429,8 +422,7 @@ void Draw(HDC aDc)
|
||||||
GetBestOverlapWithMonitors(&sourceRect);
|
GetBestOverlapWithMonitors(&sourceRect);
|
||||||
|
|
||||||
/* Paint the screen bitmap to our in memory DC */
|
/* Paint the screen bitmap to our in memory DC */
|
||||||
BitBlt(
|
BitBlt(hdcOffscreen,
|
||||||
hdcOffscreen,
|
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
sourceWidth,
|
sourceWidth,
|
||||||
|
@ -447,15 +439,13 @@ void Draw(HDC aDc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the mouse pointer in the right position */
|
/* Draw the mouse pointer in the right position */
|
||||||
DrawIcon(
|
DrawIcon(hdcOffscreen,
|
||||||
hdcOffscreen ,
|
|
||||||
pMouse.x - iinfo.xHotspot - sourceRect.left, // - 10,
|
pMouse.x - iinfo.xHotspot - sourceRect.left, // - 10,
|
||||||
pMouse.y - iinfo.yHotspot - sourceRect.top, // - 10,
|
pMouse.y - iinfo.yHotspot - sourceRect.top, // - 10,
|
||||||
cinfo.hCursor);
|
cinfo.hCursor);
|
||||||
|
|
||||||
/* Blast the stretched image from memory DC to window DC */
|
/* Blast the stretched image from memory DC to window DC */
|
||||||
StretchBlt(
|
StretchBlt(aDc,
|
||||||
aDc,
|
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
AppWidth,
|
AppWidth,
|
||||||
|
@ -485,7 +475,7 @@ void HandleNotifyIconMessage(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
PostMessage(hMainWnd, WM_COMMAND, IDM_OPTIONS, 0);
|
PostMessage(hMainWnd, WM_COMMAND, IDM_OPTIONS, 0);
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
GetCursorPos (&pt);
|
GetCursorPos(&pt);
|
||||||
TrackPopupMenu(notifyMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
|
TrackPopupMenu(notifyMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -525,7 +515,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(guiInfo.hwndActive != hMainWnd)
|
if (guiInfo.hwndActive != hMainWnd)
|
||||||
{
|
{
|
||||||
if (bFollowCaret)
|
if (bFollowCaret)
|
||||||
{
|
{
|
||||||
|
@ -540,7 +530,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
//Update to new position
|
//Update to new position
|
||||||
pCaret = ptCaret;
|
pCaret = ptCaret;
|
||||||
pCaretWnd = guiInfo.hwndCaret;
|
pCaretWnd = guiInfo.hwndCaret;
|
||||||
if(!hasMoved)
|
if (!hasMoved)
|
||||||
{
|
{
|
||||||
ClientToScreen (guiInfo.hwndCaret, (LPPOINT) &ptCaret);
|
ClientToScreen (guiInfo.hwndCaret, (LPPOINT) &ptCaret);
|
||||||
cp = ptCaret;
|
cp = ptCaret;
|
||||||
|
@ -556,7 +546,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (bFollowFocus)
|
if (bFollowFocus)
|
||||||
{
|
{
|
||||||
if(guiInfo.hwndFocus && !guiInfo.hwndCaret)
|
if (guiInfo.hwndFocus && !guiInfo.hwndCaret)
|
||||||
{
|
{
|
||||||
POINT ptFocus;
|
POINT ptFocus;
|
||||||
RECT activeRect;
|
RECT activeRect;
|
||||||
|
@ -566,12 +556,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
ptFocus.x = (activeRect.left + activeRect.right) / 2;
|
ptFocus.x = (activeRect.left + activeRect.right) / 2;
|
||||||
ptFocus.y = (activeRect.top + activeRect.bottom) / 2;
|
ptFocus.y = (activeRect.top + activeRect.bottom) / 2;
|
||||||
|
|
||||||
if((guiInfo.hwndFocus != pFocusWnd) || !PointsAreEqual(pFocus, ptFocus))
|
if ((guiInfo.hwndFocus != pFocusWnd) || !PointsAreEqual(pFocus, ptFocus))
|
||||||
{
|
{
|
||||||
//Update to new position
|
//Update to new position
|
||||||
pFocus = ptFocus;
|
pFocus = ptFocus;
|
||||||
pFocusWnd = guiInfo.hwndFocus;
|
pFocusWnd = guiInfo.hwndFocus;
|
||||||
if(!hasMoved)
|
if (!hasMoved)
|
||||||
{
|
{
|
||||||
cp = ptFocus;
|
cp = ptFocus;
|
||||||
hasMoved = TRUE;
|
hasMoved = TRUE;
|
||||||
|
@ -585,17 +575,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasMoved)
|
if (!hasMoved)
|
||||||
{
|
{
|
||||||
DWORD newTicks = GetTickCount();
|
DWORD newTicks = GetTickCount();
|
||||||
DWORD elapsed = (newTicks - lastTicks);
|
DWORD elapsed = (newTicks - lastTicks);
|
||||||
if(elapsed > REPAINT_SPEED)
|
if (elapsed > REPAINT_SPEED)
|
||||||
{
|
{
|
||||||
hasMoved = TRUE;
|
hasMoved = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasMoved)
|
if (hasMoved)
|
||||||
{
|
{
|
||||||
lastTicks = GetTickCount();
|
lastTicks = GetTickCount();
|
||||||
Refresh();
|
Refresh();
|
||||||
|
@ -611,14 +601,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
switch (wmId)
|
switch (wmId)
|
||||||
{
|
{
|
||||||
case IDM_OPTIONS:
|
case IDM_OPTIONS:
|
||||||
if(bOptionsDialog)
|
ShowWindow(hOptionsDialog, (bOptionsDialog ? SW_HIDE : SW_SHOW));
|
||||||
{
|
|
||||||
ShowWindow(hOptionsDialog, SW_HIDE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ShowWindow(hOptionsDialog, SW_SHOW);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case IDM_ABOUT:
|
case IDM_ABOUT:
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutProc);
|
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutProc);
|
||||||
|
@ -661,8 +644,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
if(GetCapture() == hWnd)
|
if (GetCapture() == hWnd)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
POINT pt;
|
POINT pt;
|
||||||
|
@ -671,7 +655,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
GetCursorPos(&pt);
|
GetCursorPos(&pt);
|
||||||
GetWindowRect(hWnd, &rc);
|
GetWindowRect(hWnd, &rc);
|
||||||
|
|
||||||
if(AppBarConfig.uEdge>=0)
|
if (AppBarConfig.uEdge >= 0)
|
||||||
{
|
{
|
||||||
if (pt.x >= rcWorkArea.left && pt.x <= rcWorkArea.right &&
|
if (pt.x >= rcWorkArea.left && pt.x <= rcWorkArea.right &&
|
||||||
pt.y >= rcWorkArea.top && pt.y <= rcWorkArea.bottom)
|
pt.y >= rcWorkArea.top && pt.y <= rcWorkArea.bottom)
|
||||||
|
@ -691,22 +675,22 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pt.x <= rcWorkArea.left+8 && nearEdge != ABE_LEFT)
|
if (pt.x <= rcWorkArea.left+8 && nearEdge != ABE_LEFT)
|
||||||
{
|
{
|
||||||
AttachAppBar(ABE_LEFT);
|
AttachAppBar(ABE_LEFT);
|
||||||
nearEdge = ABE_LEFT;
|
nearEdge = ABE_LEFT;
|
||||||
}
|
}
|
||||||
else if(pt.y <= rcWorkArea.top+8 && nearEdge != ABE_TOP)
|
else if (pt.y <= rcWorkArea.top+8 && nearEdge != ABE_TOP)
|
||||||
{
|
{
|
||||||
AttachAppBar(ABE_TOP);
|
AttachAppBar(ABE_TOP);
|
||||||
nearEdge = ABE_TOP;
|
nearEdge = ABE_TOP;
|
||||||
}
|
}
|
||||||
else if(pt.x >= rcWorkArea.right-8 && nearEdge != ABE_RIGHT)
|
else if (pt.x >= rcWorkArea.right-8 && nearEdge != ABE_RIGHT)
|
||||||
{
|
{
|
||||||
AttachAppBar(ABE_RIGHT);
|
AttachAppBar(ABE_RIGHT);
|
||||||
nearEdge = ABE_RIGHT;
|
nearEdge = ABE_RIGHT;
|
||||||
}
|
}
|
||||||
else if(pt.y >= rcWorkArea.bottom-8 && nearEdge != ABE_BOTTOM)
|
else if (pt.y >= rcWorkArea.bottom-8 && nearEdge != ABE_BOTTOM)
|
||||||
{
|
{
|
||||||
AttachAppBar(ABE_BOTTOM);
|
AttachAppBar(ABE_BOTTOM);
|
||||||
nearEdge = ABE_BOTTOM;
|
nearEdge = ABE_BOTTOM;
|
||||||
|
@ -725,10 +709,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
if(GetCapture() == hWnd)
|
if (GetCapture() == hWnd)
|
||||||
{
|
{
|
||||||
if (AppBarConfig.uEdge>=0)
|
if (AppBarConfig.uEdge >= 0)
|
||||||
DoAppBarStuff(ABM_GETSTATE);
|
DoAppBarStuff(ABM_GETSTATE);
|
||||||
else
|
else
|
||||||
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
||||||
|
@ -737,7 +722,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_SETPOS);
|
if (AppBarConfig.uEdge >= 0)
|
||||||
|
DoAppBarStuff(ABM_SETPOS);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case WM_DISPLAYCHANGE:
|
case WM_DISPLAYCHANGE:
|
||||||
bRecreateOffscreenDC = TRUE;
|
bRecreateOffscreenDC = TRUE;
|
||||||
|
@ -813,7 +799,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
case ABN_FULLSCREENAPP:
|
case ABN_FULLSCREENAPP:
|
||||||
{
|
{
|
||||||
if(!lParam)
|
if (!lParam)
|
||||||
{
|
{
|
||||||
DoAppBarStuff(ABM_GETSTATE);
|
DoAppBarStuff(ABM_GETSTATE);
|
||||||
break;
|
break;
|
||||||
|
@ -823,10 +809,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ABN_WINDOWARRANGE:
|
case ABN_WINDOWARRANGE:
|
||||||
if(lParam)
|
ShowWindow(hMainWnd, (lParam ? SW_HIDE : SW_SHOW));
|
||||||
ShowWindow(hMainWnd, SW_HIDE);
|
|
||||||
else
|
|
||||||
ShowWindow(hMainWnd, SW_SHOW);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -837,11 +820,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_ACTIVATE);
|
if (AppBarConfig.uEdge >= 0)
|
||||||
|
DoAppBarStuff(ABM_ACTIVATE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_WINDOWPOSCHANGED:
|
case WM_WINDOWPOSCHANGED:
|
||||||
if(AppBarConfig.uEdge>=0) DoAppBarStuff(ABM_WINDOWPOSCHANGED);
|
if (AppBarConfig.uEdge >= 0)
|
||||||
|
DoAppBarStuff(ABM_WINDOWPOSCHANGED);
|
||||||
Refresh();
|
Refresh();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -875,11 +860,9 @@ INT_PTR CALLBACK AboutProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
|
||||||
INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
UNREFERENCED_PARAMETER(lParam);
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_SHOWWINDOW:
|
|
||||||
bOptionsDialog = wParam;
|
|
||||||
break;
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
/* Add the zoom items */
|
/* Add the zoom items */
|
||||||
|
@ -897,26 +880,30 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
|
||||||
SendDlgItemMessage(hDlg, IDC_ZOOM, CB_SETCURSEL, uiZoom - 1, 0);
|
SendDlgItemMessage(hDlg, IDC_ZOOM, CB_SETCURSEL, uiZoom - 1, 0);
|
||||||
|
|
||||||
if (bFollowMouse)
|
if (bFollowMouse)
|
||||||
SendDlgItemMessage(hDlg,IDC_FOLLOWMOUSECHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_FOLLOWMOUSECHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
if (bFollowFocus)
|
if (bFollowFocus)
|
||||||
SendDlgItemMessage(hDlg,IDC_FOLLOWKEYBOARDCHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_FOLLOWKEYBOARDCHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
if (bFollowCaret)
|
if (bFollowCaret)
|
||||||
SendDlgItemMessage(hDlg,IDC_FOLLOWTEXTEDITINGCHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_FOLLOWTEXTEDITINGCHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
if (bInvertColors)
|
if (bInvertColors)
|
||||||
SendDlgItemMessage(hDlg,IDC_INVERTCOLORSCHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_INVERTCOLORSCHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
if (bStartMinimized)
|
if (bStartMinimized)
|
||||||
SendDlgItemMessage(hDlg,IDC_STARTMINIMIZEDCHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_STARTMINIMIZEDCHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
if (bShowMagnifier)
|
if (bShowMagnifier)
|
||||||
SendDlgItemMessage(hDlg,IDC_SHOWMAGNIFIERCHECK,BM_SETCHECK , wParam ,0);
|
SendDlgItemMessage(hDlg,IDC_SHOWMAGNIFIERCHECK,BM_SETCHECK, wParam, 0);
|
||||||
|
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_SHOWWINDOW:
|
||||||
|
bOptionsDialog = wParam;
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
|
@ -927,8 +914,9 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
|
||||||
|
|
||||||
case IDC_BUTTON_HELP:
|
case IDC_BUTTON_HELP:
|
||||||
/* Unimplemented */
|
/* Unimplemented */
|
||||||
MessageBox(hDlg , TEXT("Magnifier help not available yet!") , TEXT("Help") , MB_OK);
|
MessageBox(hDlg, TEXT("Magnifier help not available yet!"), TEXT("Help"), MB_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_ZOOM:
|
case IDC_ZOOM:
|
||||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||||
{
|
{
|
||||||
|
@ -950,6 +938,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_INVERTCOLORSCHECK:
|
case IDC_INVERTCOLORSCHECK:
|
||||||
bInvertColors = IsDlgButtonChecked(hDlg, IDC_INVERTCOLORSCHECK);
|
bInvertColors = IsDlgButtonChecked(hDlg, IDC_INVERTCOLORSCHECK);
|
||||||
Refresh();
|
Refresh();
|
||||||
|
@ -968,10 +957,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
|
||||||
break;
|
break;
|
||||||
case IDC_SHOWMAGNIFIER:
|
case IDC_SHOWMAGNIFIER:
|
||||||
bShowMagnifier = IsDlgButtonChecked(hDlg, IDC_SHOWMAGNIFIERCHECK);
|
bShowMagnifier = IsDlgButtonChecked(hDlg, IDC_SHOWMAGNIFIERCHECK);
|
||||||
if (bShowMagnifier)
|
ShowWindow(hMainWnd, (bShowMagnifier ? SW_SHOW : SW_HIDE));
|
||||||
ShowWindow (hMainWnd , SW_SHOW);
|
|
||||||
else
|
|
||||||
ShowWindow (hMainWnd , SW_HIDE);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* WineCalc (magnifier.h)
|
* PROJECT: ReactOS Magnify
|
||||||
*
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* Copyright 2007 Marc Piulachs
|
* PURPOSE: Magnification of parts of the screen.
|
||||||
*
|
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
|
||||||
* This library is free software; you can redistribute it and/or
|
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MAGNIFIER_H_
|
#ifndef _MAGNIFIER_H_
|
||||||
|
@ -26,7 +14,8 @@
|
||||||
|
|
||||||
extern UINT uiZoom;
|
extern UINT uiZoom;
|
||||||
|
|
||||||
struct _AppBarConfig_t {
|
struct _AppBarConfig_t
|
||||||
|
{
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
INT uEdge;
|
INT uEdge;
|
||||||
DWORD value3;
|
DWORD value3;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Magnify
|
* PROJECT: ReactOS Magnify
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
* FILE: base/applications/magnify/settings.c
|
|
||||||
* PURPOSE: Magnification of parts of the screen.
|
* PURPOSE: Magnification of parts of the screen.
|
||||||
* COPYRIGHT: Copyright 2007 Marc Piulachs <marc.piulachs@codexchange.net>
|
* COPYRIGHT: Copyright 2007-2019 Marc Piulachs <marc.piulachs@codexchange.net>
|
||||||
*
|
* Copyright 2015-2019 David Quintana <gigaherz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "magnifier.h"
|
#include "magnifier.h"
|
||||||
|
@ -24,7 +23,8 @@ BOOL bInvertColors = FALSE;
|
||||||
BOOL bStartMinimized = FALSE;
|
BOOL bStartMinimized = FALSE;
|
||||||
BOOL bShowMagnifier = TRUE;
|
BOOL bShowMagnifier = TRUE;
|
||||||
|
|
||||||
struct _AppBarConfig_t AppBarConfig = {
|
struct _AppBarConfig_t AppBarConfig =
|
||||||
|
{
|
||||||
sizeof(struct _AppBarConfig_t),
|
sizeof(struct _AppBarConfig_t),
|
||||||
-2 /* ABE_TOP */,
|
-2 /* ABE_TOP */,
|
||||||
0, 1, /* unknown */
|
0, 1, /* unknown */
|
||||||
|
@ -32,15 +32,16 @@ struct _AppBarConfig_t AppBarConfig = {
|
||||||
{ 20, 20, 600, 200 }, /* floating window rect */
|
{ 20, 20, 600, 200 }, /* floating window rect */
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoadSettings()
|
void LoadSettings(void)
|
||||||
{
|
{
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
LONG value;
|
LONG value;
|
||||||
ULONG len;
|
ULONG len;
|
||||||
struct _AppBarConfig_t config_temp;
|
struct _AppBarConfig_t config_temp;
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
||||||
{
|
return;
|
||||||
|
|
||||||
len = sizeof(AppBarConfig);
|
len = sizeof(AppBarConfig);
|
||||||
if (RegQueryValueEx(hkey, _T("AppBar"), 0, 0, (BYTE *)&config_temp, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("AppBar"), 0, 0, (BYTE *)&config_temp, &len) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -59,43 +60,43 @@ void LoadSettings()
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bShowWarning = (value == 0 ? FALSE : TRUE);
|
bShowWarning = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bInvertColors = (value == 0 ? FALSE : TRUE);
|
bInvertColors = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bStartMinimized = (value == 0 ? FALSE : TRUE);
|
bStartMinimized = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bFollowMouse = (value == 0 ? FALSE : TRUE);
|
bFollowMouse = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bFollowFocus = (value == 0 ? FALSE : TRUE);
|
bFollowFocus = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bFollowFocus = (value == 0 ? FALSE : TRUE);
|
bFollowFocus = !!value;
|
||||||
|
|
||||||
len = sizeof(value);
|
len = sizeof(value);
|
||||||
if (RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
if (RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len) == ERROR_SUCCESS)
|
||||||
bFollowCaret = (value == 0 ? FALSE : TRUE);
|
bFollowCaret = !!value;
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveSettings()
|
void SaveSettings(void)
|
||||||
{
|
{
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
LONG value;
|
LONG value;
|
||||||
|
|
||||||
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
|
if (RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0, _T(""), 0, KEY_WRITE, NULL, &hkey, NULL) != ERROR_SUCCESS)
|
||||||
{
|
return;
|
||||||
|
|
||||||
RegSetValueEx(hkey, _T("AppBar"), 0, REG_BINARY, (BYTE *)&AppBarConfig, sizeof(AppBarConfig));
|
RegSetValueEx(hkey, _T("AppBar"), 0, REG_BINARY, (BYTE *)&AppBarConfig, sizeof(AppBarConfig));
|
||||||
|
|
||||||
value = uiZoom;
|
value = uiZoom;
|
||||||
|
@ -123,5 +124,4 @@ void SaveSettings()
|
||||||
RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof(value));
|
RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof(value));
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue