Skip to content

Commit

Permalink
Move redrawDlgItem to StaticDialog
Browse files Browse the repository at this point in the history
add initializers
  • Loading branch information
ozone10 committed Feb 23, 2023
1 parent eca464f commit b2a75c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
28 changes: 20 additions & 8 deletions PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@ void StaticDialog::destroy()
::DestroyWindow(_hSelf);
}

void StaticDialog::redrawDlgItem(const int nIDDlgItem, bool forceUpdate) const
{
RECT rcDlgItem{};
const HWND hDlgItem = ::GetDlgItem(_hSelf, nIDDlgItem);
::GetClientRect(hDlgItem, &rcDlgItem);
::MapWindowPoints(hDlgItem, _hSelf, reinterpret_cast<LPPOINT>(&rcDlgItem), 2);
::InvalidateRect(_hSelf, &rcDlgItem, TRUE);

if (forceUpdate)
::UpdateWindow(hDlgItem);
}

POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const
{
RECT rc;
RECT rc{};
::GetWindowRect(hwnd, &rc);

POINT p;
POINT p{};
if (isLeft)
p.x = rc.left;
else
Expand All @@ -54,9 +66,9 @@ POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const

void StaticDialog::goToCenter()
{
RECT rc;
RECT rc{};
::GetClientRect(_hParent, &rc);
POINT center;
POINT center{};
center.x = rc.left + (rc.right - rc.left)/2;
center.y = rc.top + (rc.bottom - rc.top)/2;
::ClientToScreen(_hParent, &center);
Expand All @@ -73,7 +85,7 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
{
if (enhancedPositioningCheckWhenShowing)
{
RECT testPositionRc, candidateRc;
RECT testPositionRc{}, candidateRc{};

getWindowRect(testPositionRc);

Expand All @@ -89,8 +101,8 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
{
// If the user has switched from a dual monitor to a single monitor since we last
// displayed the dialog, then ensure that it's still visible on the single monitor.
RECT workAreaRect = {};
RECT rc = {};
RECT workAreaRect{};
RECT rc{};
::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0);
::GetWindowRect(_hSelf, &rc);
int newLeft = rc.left;
Expand Down Expand Up @@ -119,7 +131,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const
{
HMONITOR hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONULL);

MONITORINFO mi;
MONITORINFO mi{};
mi.cbSize = sizeof(MONITORINFO);

bool rectPosViewableWithoutChange = false;
Expand Down
6 changes: 4 additions & 2 deletions PowerEditor/src/WinControls/StaticDialog/StaticDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public :
return (_hSelf != NULL);
}

void redrawDlgItem(const int nIDDlgItem, bool forceUpdate = false) const;

void goToCenter();

void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false) const;
Expand All @@ -65,10 +67,10 @@ public :
::SendDlgItemMessage(_hSelf, checkControlID, BM_SETCHECK, checkOrNot ? BST_CHECKED : BST_UNCHECKED, 0);
}

virtual void destroy() override;
void destroy() override;

protected:
RECT _rc = {};
RECT _rc{};
static intptr_t CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;

Expand Down
14 changes: 1 addition & 13 deletions PowerEditor/src/WinControls/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,8 @@ class Window
::UpdateWindow(_hSelf);
}

virtual void redrawDlgItem(const int nIDDlgItem, bool forceUpdate = false) const
{
RECT rcDlgItem{};
const HWND hDlgItem = ::GetDlgItem(_hSelf, nIDDlgItem);
::GetClientRect(hDlgItem, &rcDlgItem);
::MapWindowPoints(hDlgItem, _hSelf, reinterpret_cast<LPPOINT>(&rcDlgItem), 2);
::InvalidateRect(_hSelf, &rcDlgItem, TRUE);

if (forceUpdate)
::UpdateWindow(hDlgItem);
}


virtual void getClientRect(RECT & rc) const
virtual void getClientRect(RECT & rc) const
{
::GetClientRect(_hSelf, &rc);
}
Expand Down

0 comments on commit b2a75c1

Please sign in to comment.