diff options
-rw-r--r-- | win32/PlatWin.cxx | 18 | ||||
-rw-r--r-- | win32/PlatWin.h | 8 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 12 |
3 files changed, 19 insertions, 19 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 4c9291fd1..c9f296a90 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -2122,14 +2122,6 @@ Surface *Surface::Allocate(int technology) { #endif } -namespace { - -HWND HwndFromWindowID(WindowID wid) noexcept { - return static_cast<HWND>(wid); -} - -} - Window::~Window() { } @@ -2175,7 +2167,7 @@ void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { const LONG style = ::GetWindowLong(HwndFromWindowID(wid), GWL_STYLE); if (style & WS_POPUP) { POINT ptOther = {0, 0}; - ::ClientToScreen(HwndFromWindowID(relativeTo->GetID()), &ptOther); + ::ClientToScreen(HwndFromWindow(*relativeTo), &ptOther); rc.Move(static_cast<XYPOSITION>(ptOther.x), static_cast<XYPOSITION>(ptOther.y)); const RECT rcMonitor = RectFromPRectangle(rc); @@ -2471,7 +2463,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei lineHeight = lineHeight_; unicodeMode = unicodeMode_; technology = technology_; - HWND hwndParent = HwndFromWindowID(parent->GetID()); + HWND hwndParent = HwndFromWindow(*parent); HINSTANCE hinstanceParent = GetWindowInstance(hwndParent); // Window created as popup so not clipped within parent client area wid = ::CreateWindowEx( @@ -3055,7 +3047,7 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { case WM_CREATE: { - HINSTANCE hinstanceParent = GetWindowInstance(HwndFromWindowID(parent->GetID())); + HINSTANCE hinstanceParent = GetWindowInstance(HwndFromWindow(*parent)); // Note that LBS_NOINTEGRALHEIGHT is specified to fix cosmetic issue when resizing the list // but has useful side effect of speeding up list population significantly lb = ::CreateWindowEx( @@ -3091,7 +3083,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam case WM_COMMAND: // This is not actually needed now - the registered double click action is used // directly to action a choice from the list. - ::SendMessage(HwndFromWindowID(parent->GetID()), iMessage, wParam, lParam); + ::SendMessage(HwndFromWindow(*parent), iMessage, wParam, lParam); break; case WM_MEASUREITEM: { @@ -3237,7 +3229,7 @@ void Menu::Destroy() { void Menu::Show(Point pt, Window &w) { ::TrackPopupMenu(static_cast<HMENU>(mid), TPM_RIGHTBUTTON, static_cast<int>(pt.x - 4), static_cast<int>(pt.y), 0, - HwndFromWindowID(w.GetID()), nullptr); + HwndFromWindow(w), nullptr); Destroy(); } diff --git a/win32/PlatWin.h b/win32/PlatWin.h index 62b87fa3c..6fb8ff5f1 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -19,6 +19,14 @@ constexpr RECT RectFromPRectangle(PRectangle prc) noexcept { return rc; } +constexpr HWND HwndFromWindowID(WindowID wid) noexcept { + return static_cast<HWND>(wid); +} + +inline HWND HwndFromWindow(const Window &w) noexcept { + return HwndFromWindowID(w.GetID()); +} + #if defined(USE_D2D) extern bool LoadD2D(); extern ID2D1Factory *pD2DFactory; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index f95b89ab7..232352224 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -659,7 +659,7 @@ void ScintillaWin::DropRenderTarget() { #endif HWND ScintillaWin::MainHWND() const noexcept { - return static_cast<HWND>(wMain.GetID()); + return HwndFromWindow(wMain); } bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) { @@ -1444,7 +1444,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l } // if autocomplete list active then send mousewheel message to it if (ac.Active()) { - HWND hWnd = static_cast<HWND>(ac.lb->GetID()); + HWND hWnd = HwndFromWindow(*(ac.lb)); ::SendMessage(hWnd, iMessage, wParam, lParam); break; } @@ -1561,7 +1561,7 @@ sptr_t ScintillaWin::FocusMessage(unsigned int iMessage, uptr_t wParam, sptr_t) case WM_KILLFOCUS: { HWND wOther = reinterpret_cast<HWND>(wParam); HWND wThis = MainHWND(); - const HWND wCT = static_cast<HWND>(ct.wCallTip.GetID()); + const HWND wCT = HwndFromWindow(ct.wCallTip); if (!wParam || !(::IsChild(wThis, wOther) || (wOther == wCT))) { SetFocusState(false); @@ -1818,7 +1818,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam switch (iMessage) { case WM_CREATE: - ctrlID = ::GetDlgCtrlID(static_cast<HWND>(wMain.GetID())); + ctrlID = ::GetDlgCtrlID(HwndFromWindow(wMain)); // Get Intellimouse scroll line parameters GetIntelliMouseParameters(); ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt)); @@ -2202,11 +2202,11 @@ void ScintillaWin::NotifyFocus(bool focus) { } void ScintillaWin::SetCtrlID(int identifier) { - ::SetWindowID(static_cast<HWND>(wMain.GetID()), identifier); + ::SetWindowID(HwndFromWindow(wMain), identifier); } int ScintillaWin::GetCtrlID() { - return ::GetDlgCtrlID(static_cast<HWND>(wMain.GetID())); + return ::GetDlgCtrlID(HwndFromWindow(wMain)); } void ScintillaWin::NotifyParent(SCNotification scn) { |