[MAGNIFY] Minor whitespace / formatting fixes; use the new file headers + some code simplifications here and there...

This commit is contained in:
Hermès Bélusca-Maïto 2019-06-15 19:09:28 +02:00
parent 4e91b6d5db
commit 16646fb19c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 190 additions and 215 deletions

View file

@ -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 */
@ -197,7 +195,6 @@ 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;
@ -286,8 +283,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
} }
/* 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))
{ {
@ -411,8 +405,7 @@ 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);
@ -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,
@ -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,6 +644,7 @@ 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)
{ {
@ -725,6 +709,7 @@ 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)
{ {
@ -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;
@ -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 */
@ -917,6 +900,10 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
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))
{ {
@ -929,6 +916,7 @@ INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
/* 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;
} }
} }

View file

@ -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;

View file

@ -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;
@ -124,4 +125,3 @@ void SaveSettings()
RegCloseKey(hkey); RegCloseKey(hkey);
} }
}