diff --git a/src/Helpers.c b/src/Helpers.c index 862887a46..4bb8de5b1 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -608,6 +608,7 @@ void CenterDlgInParent(HWND hDlg) SetWindowPos(hDlg,NULL,max(xMin,min(xMax,x)),max(yMin,min(yMax,y)),0,0,SWP_NOZORDER|SWP_NOSIZE); + //SnapToDefaultButton(hDlg); } @@ -672,6 +673,41 @@ void SetDlgPos(HWND hDlg,int xDlg,int yDlg) } +/* + + ... only if we are working with nonstandard dialog boxes ... + +//============================================================================= +// +// SnapToDefaultButton() +// +// Why doesn't the "Automatically move pointer to the default button in a dialog box" +// work for nonstandard dialog boxes, and how do I add it to my own nonstandard dialog boxes? +// https://blogs.msdn.microsoft.com/oldnewthing/20130826-00/?p=3413/ +// +void SnapToDefaultButton(HWND hwndBox) +{ + BOOL bSnapToDefButton = FALSE; + if (SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &bSnapToDefButton, 0) && bSnapToDefButton) { + // get child window at the top of the Z order. + // for all our MessageBoxs it's the OK or YES button or NULL. + HWND btn = GetWindow(hwndBox, GW_CHILD); + if (btn != NULL) { + WCHAR className[32] = L""; + GetClassName(btn, className, COUNTOF(className)); + if (lstrcmpi(className, L"Button") == 0) { + RECT rect; + int x, y; + GetWindowRect(btn, &rect); + x = rect.left + (rect.right - rect.left) / 2; + y = rect.top + (rect.bottom - rect.top) / 2; + SetCursorPos(x, y); + } + } + } +} +*/ + //============================================================================= // diff --git a/src/Helpers.h b/src/Helpers.h index 005e61951..240b6af9f 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -125,6 +125,7 @@ void SetWindowTransparentMode(HWND,BOOL); void CenterDlgInParent(HWND); void GetDlgPos(HWND,LPINT,LPINT); void SetDlgPos(HWND,int,int); +//void SnapToDefaultButton(HWND); void ResizeDlg_Init(HWND,int,int,int); void ResizeDlg_Destroy(HWND,int*,int*); void ResizeDlg_Size(HWND,LPARAM,int*,int*);