diff options
Diffstat (limited to 'win32')
| -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 3e8d716ec..d2b9b6f98 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1717,14 +1717,6 @@ Surface *Surface::Allocate(int technology) { #endif } -namespace { - -HWND HwndFromWindowID(WindowID wid) noexcept { - return static_cast<HWND>(wid); -} - -} - Window::~Window() { } @@ -1770,7 +1762,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); @@ -2066,7 +2058,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( @@ -2650,7 +2642,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( @@ -2686,7 +2678,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: { @@ -2832,7 +2824,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 cf357f72d..01e321e4c 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -15,6 +15,14 @@ extern void Platform_Finalise(bool fromDllMain); RECT RectFromPRectangle(PRectangle prc) noexcept; +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 85d7f8fbe..b17cf6510 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -655,7 +655,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) { @@ -1434,7 +1434,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; } @@ -1551,7 +1551,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); @@ -1795,7 +1795,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)); @@ -2178,11 +2178,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) { |
