https://git.reactos.org/?p=reactos.git;a=commitdiff;h=99a9e7e49384c586e9b04…
commit 99a9e7e49384c586e9b0408dc0d7816f2abf0cda
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Feb 15 19:21:55 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Feb 15 19:21:55 2021 +0900
[SHIMGVW] Refactoring (#3461)
- Make the calls of CallWindowProc and DefWindowProc Wide (Unicode).
- Delete needless type casts.
- Add const to function arguments.
- Improve ImageView_LoadSettings function.
- Insert OFN_EXPLORER flag.
---
dll/win32/shimgvw/shimgvw.c | 47 ++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/dll/win32/shimgvw/shimgvw.c b/dll/win32/shimgvw/shimgvw.c
index 40723c2883f..a70ef51cc41 100644
--- a/dll/win32/shimgvw/shimgvw.c
+++ b/dll/win32/shimgvw/shimgvw.c
@@ -337,7 +337,7 @@ static void ResetZoom(void)
}
}
-static void pLoadImage(LPWSTR szOpenFileName)
+static void pLoadImage(LPCWSTR szOpenFileName)
{
/* check file presence */
if (GetFileAttributesW(szOpenFileName) == 0xFFFFFFFF)
@@ -420,7 +420,7 @@ static void pSaveImageAs(HWND hwnd)
sfn.lpstrFile = szSaveFileName;
sfn.lpstrFilter = szFilterMask;
sfn.nMaxFile = MAX_PATH;
- sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+ sfn.Flags = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
c = szFilterMask;
@@ -798,24 +798,21 @@ ImageView_DrawImage(HWND hwnd)
}
static BOOL
-ImageView_LoadSettings()
+ImageView_LoadSettings(VOID)
{
HKEY hKey;
DWORD dwSize;
+ LONG nError;
- if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\ReactOS\\shimgvw"), 0,
KEY_READ, &hKey) == ERROR_SUCCESS)
- {
- dwSize = sizeof(SHIMGVW_SETTINGS);
- if (RegQueryValueEx(hKey, _T("Settings"), NULL, NULL,
(LPBYTE)&shiSettings, &dwSize) == ERROR_SUCCESS)
- {
- RegCloseKey(hKey);
- return TRUE;
- }
+ nError = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\shimgvw", 0,
KEY_READ, &hKey);
+ if (nError)
+ return FALSE;
- RegCloseKey(hKey);
- }
+ dwSize = sizeof(shiSettings);
+ nError = RegQueryValueExW(hKey, L"Settings", NULL, NULL,
(LPBYTE)&shiSettings, &dwSize);
+ RegCloseKey(hKey);
- return FALSE;
+ return !nError;
}
static VOID
@@ -845,13 +842,11 @@ ImageView_SaveSettings(HWND hwnd)
static BOOL
ImageView_CreateToolBar(HWND hwnd)
{
- int n;
-
hToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | CCS_BOTTOM |
TBSTYLE_TOOLTIPS,
0, 0, 0, 0, hwnd,
0, hInstance, NULL);
- if(hToolBar != NULL)
+ if (hToolBar != NULL)
{
HIMAGELIST hImageList;
@@ -864,7 +859,7 @@ ImageView_CreateToolBar(HWND hwnd)
hImageList = ImageList_Create(TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, ILC_MASK |
ILC_COLOR24, 1, 1);
if (hImageList == NULL) return FALSE;
- for (n = 0; n < _countof(BtnConfig); n++)
+ for (INT n = 0; n < _countof(BtnConfig); n++)
{
ImageList_AddMasked(hImageList, LoadImageW(hInstance,
MAKEINTRESOURCEW(BtnConfig[n].idb), IMAGE_BITMAP,
TB_IMAGE_WIDTH, TB_IMAGE_HEIGHT, LR_DEFAULTCOLOR),
RGB(255, 255, 255));
@@ -914,7 +909,7 @@ ImageView_DispWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM
lParam)
break;
}
}
- return CallWindowProc(PrevProc, hwnd, Message, wParam, lParam);
+ return CallWindowProcW(PrevProc, hwnd, Message, wParam, lParam);
}
static VOID
@@ -1085,11 +1080,11 @@ ImageView_WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM
lParam)
}
}
- return DefWindowProc(hwnd, Message, wParam, lParam);
+ return DefWindowProcW(hwnd, Message, wParam, lParam);
}
LONG WINAPI
-ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
+ImageView_CreateWindow(HWND hwnd, LPCWSTR szFileName)
{
struct GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
@@ -1132,7 +1127,7 @@ ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
if (!RegisterClassW(&WndClass)) return -1;
- LoadStringW(hInstance, IDS_APPTITLE, szBuf, sizeof(szBuf) / sizeof(TCHAR));
+ LoadStringW(hInstance, IDS_APPTITLE, szBuf, ARRAYSIZE(szBuf));
hMainWnd = CreateWindowExW(0, L"shimgvw_window", szBuf,
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CAPTION,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -1188,13 +1183,13 @@ ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName)
VOID WINAPI
ImageView_FullscreenW(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
{
- ImageView_CreateWindow(hwnd, (LPWSTR)path);
+ ImageView_CreateWindow(hwnd, path);
}
VOID WINAPI
ImageView_Fullscreen(HWND hwnd, HINSTANCE hInst, LPCWSTR path, int nShow)
{
- ImageView_CreateWindow(hwnd, (LPWSTR)path);
+ ImageView_CreateWindow(hwnd, path);
}
VOID WINAPI
@@ -1202,9 +1197,9 @@ ImageView_FullscreenA(HWND hwnd, HINSTANCE hInst, LPCSTR path, int
nShow)
{
WCHAR szFile[MAX_PATH];
- if (MultiByteToWideChar(CP_ACP, 0, (char*)path, strlen((char*)path)+1, szFile,
MAX_PATH))
+ if (MultiByteToWideChar(CP_ACP, 0, path, -1, szFile, ARRAYSIZE(szFile)))
{
- ImageView_CreateWindow(hwnd, (LPWSTR)szFile);
+ ImageView_CreateWindow(hwnd, szFile);
}
}