Skip to content

Commit

Permalink
Fix dialogs out of screen problem
Browse files Browse the repository at this point in the history
Reposition dialogs if they are outside screen.

Fix #11240, fix #14913, close  #15083
  • Loading branch information
ozone10 authored and donho committed May 10, 2024
1 parent be94533 commit f6d304f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
{
RECT rc = getViewablePositionRect(nppGUI._findWindowPos);
::SetWindowPos(_hSelf, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, swpFlags);
if ((swpFlags & SWP_SHOWWINDOW) == SWP_SHOWWINDOW)
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions PowerEditor/src/ScintillaComponent/GoToLineDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public :
{
updateLinesNumbers();
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
else
{
Expand Down
9 changes: 6 additions & 3 deletions PowerEditor/src/ScintillaComponent/columnEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ void ColumnEditorDlg::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEd

void ColumnEditorDlg::display(bool toShow) const
{
Window::display(toShow);
if (toShow)
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
Window::display(toShow);
if (toShow)
{
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
}

intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/WinControls/DocumentMap/documentMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#define DM_PANELTITLE TEXT("Document Map")

#define DOCUMENTMAP_SCROLL (WM_USER + 1)
#define DOCUMENTMAP_MOUSECLICKED (WM_USER + 2)
#define DOCUMENTMAP_SCROLL (WM_USER + 4) // DM_SETDEFID uses WM_USER + 1
#define DOCUMENTMAP_MOUSECLICKED (WM_USER + 5) // DM_REPOSITION uses WM_USER + 2
#define DOCUMENTMAP_MOUSEWHEEL (WM_USER + 3)

const TCHAR VIEWZONE_DOCUMENTMAP[64] = TEXT("Document map");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public :

void display(bool toShow = true) const override {
Window::display(toShow);
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
};

protected :
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/WinControls/Preference/preference_rc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define PREFERENCE_RC_H
//#define PREF_MSG_ISCHECKED_GENERALPAGE (WM_USER + 1) // wParam:checkbox/radiobutton ID in General page. lParam is type of "bool *" to get result
#define PREF_MSG_SETGUITOOLICONSSET (WM_USER + 2)
#define PREF_MSG_SETGUITOOLICONSSET (WM_USER + 4) // DM_REPOSITION uses WM_USER + 2
#define PREF_MSG_SETGUITABBARICONS (WM_USER + 3)

#define IDD_PREFERENCE_BOX 6000
Expand Down
7 changes: 5 additions & 2 deletions PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void StaticDialog::goToCenter(UINT swpFlags)
int y = center.y - (_rc.bottom - _rc.top)/2;

::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, swpFlags);
if (((swpFlags & SWP_NOMOVE) != SWP_NOMOVE) && ((swpFlags & SWP_SHOWWINDOW) == SWP_SHOWWINDOW))
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}

void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing) const
Expand Down Expand Up @@ -135,8 +137,9 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
newTop = workAreaRect.top;

if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk
// Remember that MoveWindow wants width/height.
::MoveWindow(_hSelf, newLeft, newTop, rc.right - rc.left, rc.bottom - rc.top, TRUE);
::SetWindowPos(_hSelf, nullptr, newLeft, newTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
else
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
}

Expand Down
1 change: 1 addition & 0 deletions PowerEditor/src/WinControls/shortcut/RunMacroDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public :
// So reload the macro list (issue #4526)
initMacroList();
::ShowWindow(_hSelf, SW_SHOW);
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
};

Expand Down

0 comments on commit f6d304f

Please sign in to comment.