From 75bfcddbdcc76b66c3d99f5b556038a13ce8e4cf Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 1 Feb 2023 13:10:25 +0000 Subject: [PATCH] Use SetWindowLongPtrW() when setting WndProc Using the SetWindowLongPtrA() variant means that a Unicode to ASCII shim is inserted around the installed WndProc, which is not what we want. (Specfically, this flattens the PropSheet caption to an 8-bit encoding as it passes through the WndProc as a WM_SETTEXT message, which is not reversible for non-latin scripts) Future work: Rewrite this using SetWindowSubclass() instead, which sidesteps all these issues. --- proppage.cc | 2 +- propsheet.cc | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/proppage.cc b/proppage.cc index 46357172..1be3eeda 100644 --- a/proppage.cc +++ b/proppage.cc @@ -98,7 +98,7 @@ PropertyPage::FirstDialogProcReflector (HWND hwnd, UINT message, This = (PropertyPage *) (((LPPROPSHEETPAGEW) lParam)->lParam); SetWindowLongPtr (hwnd, DWLP_USER, (LONG_PTR) This); - SetWindowLongPtr (hwnd, DWLP_DLGPROC, (LONG_PTR) DialogProcReflector); + SetWindowLongPtrW (hwnd, DWLP_DLGPROC, (LONG_PTR) DialogProcReflector); This->SetHWND (hwnd); return This->DialogProc (message, wParam, lParam); diff --git a/propsheet.cc b/propsheet.cc index c36a9756..a2dca458 100644 --- a/propsheet.cc +++ b/propsheet.cc @@ -267,10 +267,15 @@ PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam) Hook into the window proc. We need to catch some messages for resizing. */ - PropSheetData::Instance().oldWndProc = - (WNDPROC)GetWindowLongPtr (hwndDlg, GWLP_WNDPROC); - SetWindowLongPtr (hwndDlg, GWLP_WNDPROC, - (LONG_PTR)&PropSheetWndProc); + PropSheetData::Instance().oldWndProc = (WNDPROC)GetWindowLongPtrW (hwndDlg, GWLP_WNDPROC); + SetWindowLongPtrW (hwndDlg, GWLP_WNDPROC, (LONG_PTR)&PropSheetWndProc); + /* + Store the PropSheet HWND in the Chooser, for use in resizing + + (XXX: this is just silly: The PropSheet HWND is the parent of the + PropPage HWND, so chooser has access to that HWND as GetParent() + anyhow... ) + */ ChooserPage::SetHwndDialog (hwndDlg); } return TRUE; -- 2.43.5