Fix dialogs out of screen problem

Reposition dialogs if they are outside screen.

Fix #11240, fix #14913, close  #15083
pull/15125/head
ozone10 2024-05-02 18:47:40 +02:00 committed by Don Ho
parent be94533576
commit f6d304f943
8 changed files with 19 additions and 8 deletions

View File

@ -339,6 +339,8 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent, bool t
{ {
RECT rc = getViewablePositionRect(nppGUI._findWindowPos); RECT rc = getViewablePositionRect(nppGUI._findWindowPos);
::SetWindowPos(_hSelf, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, swpFlags); ::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 else
{ {

View File

@ -43,6 +43,7 @@ public :
{ {
updateLinesNumbers(); updateLinesNumbers();
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT)); ::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
} }
else else
{ {

View File

@ -31,9 +31,12 @@ void ColumnEditorDlg::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEd
void ColumnEditorDlg::display(bool toShow) const void ColumnEditorDlg::display(bool toShow) const
{ {
Window::display(toShow); Window::display(toShow);
if (toShow) if (toShow)
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT)); {
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}
} }
intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)

View File

@ -22,8 +22,8 @@
#define DM_PANELTITLE TEXT("Document Map") #define DM_PANELTITLE TEXT("Document Map")
#define DOCUMENTMAP_SCROLL (WM_USER + 1) #define DOCUMENTMAP_SCROLL (WM_USER + 4) // DM_SETDEFID uses WM_USER + 1
#define DOCUMENTMAP_MOUSECLICKED (WM_USER + 2) #define DOCUMENTMAP_MOUSECLICKED (WM_USER + 5) // DM_REPOSITION uses WM_USER + 2
#define DOCUMENTMAP_MOUSEWHEEL (WM_USER + 3) #define DOCUMENTMAP_MOUSEWHEEL (WM_USER + 3)
const TCHAR VIEWZONE_DOCUMENTMAP[64] = TEXT("Document map"); const TCHAR VIEWZONE_DOCUMENTMAP[64] = TEXT("Document map");

View File

@ -40,6 +40,7 @@ public :
void display(bool toShow = true) const override { void display(bool toShow = true) const override {
Window::display(toShow); Window::display(toShow);
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
}; };
protected : protected :

View File

@ -18,7 +18,7 @@
#define PREFERENCE_RC_H #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_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 PREF_MSG_SETGUITABBARICONS (WM_USER + 3)
#define IDD_PREFERENCE_BOX 6000 #define IDD_PREFERENCE_BOX 6000

View File

@ -93,6 +93,8 @@ void StaticDialog::goToCenter(UINT swpFlags)
int y = center.y - (_rc.bottom - _rc.top)/2; int y = center.y - (_rc.bottom - _rc.top)/2;
::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, swpFlags); ::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 void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing) const
@ -135,8 +137,9 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing
newTop = workAreaRect.top; newTop = workAreaRect.top;
if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk
// Remember that MoveWindow wants width/height. ::SetWindowPos(_hSelf, nullptr, newLeft, newTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
::MoveWindow(_hSelf, newLeft, newTop, rc.right - rc.left, rc.bottom - rc.top, TRUE); else
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
} }
} }

View File

@ -36,6 +36,7 @@ public :
// So reload the macro list (issue #4526) // So reload the macro list (issue #4526)
initMacroList(); initMacroList();
::ShowWindow(_hSelf, SW_SHOW); ::ShowWindow(_hSelf, SW_SHOW);
::SendMessageW(_hSelf, DM_REPOSITION, 0, 0);
} }
}; };