Explorer-type custom dialog is maximized on the first open in the application

131 Views Asked by At

I have customized an explorer type browse dialog and added some controls. Upon opening the dialog, even though I have specified the width and height on the template resource, it is showing in maximized state.

Maximized dialog image

I have tried to override this behavior by using the SetWindowPos, MoveWindow and ShowWindow API but none of them seems to resize the dialog.

Here are the specific codes, called during dialog initialization:

HWND hTrueDlg = GetParent(hwndDlg);
::SetWindowPos(hTrueDlg, HWND_TOP, iXPx, iYPx, iWinWidthPx, iWinHeightPx, SWP_SHOWWINDOW);
::ShowWindow(hTrueDlg, SW_RESTORE);

This is the resource file:

    WPOPENDLGCUSTOM DIALOG  0, 0, 600, 40
    STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION

// I have also tried this 
    STYLE (DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION) & ~WS_MAXIMIZE

When I double click the title bar, it is "Restored" and for the next time I open the dialog, it is displaying the correct size. The problem is only on the first open. When a user don't know this work around, it might cause some problems.

1

There are 1 best solutions below

2
On

The explorer-style dialog box read size value from one registry hive first opening and record and read size value to one registry hive that could be Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\CIDSizeMRU later.