0

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.

  • Your width and height (40?) parameters in the resource script snippet look a bit strange. Also, can you explain why you are using `WS_CHILD` (rather than `WS_POPUP`) and making your dialog a chid of some other dialog? – Adrian Mole May 26 '21 at 15:29
  • @adr The `WS_CHILD` window style is required when using [explorer-style custom templates](https://learn.microsoft.com/en-us/windows/win32/dlgbox/open-and-save-as-dialog-boxes#explorer-style-custom-templates). – IInspectable May 26 '21 at 15:55
  • @IInspectable Aha - haven't actually used that technique myself. – Adrian Mole May 26 '21 at 15:58
  • Have you tried declaring a dummy static control with ID `stc32` to act as an origin marker. I recall having run into similar issues, and I believe to have fixed it using the `stc32` control or playing around with the dialog size. Too long ago to remember the details... – IInspectable May 26 '21 at 16:16
  • How do you add the stc32? When I try to add and reposition it the whole dialog controls move with it. It adds a padding on top and left of it as a reference to the whole dialog controls – fidel espanto May 27 '21 at 01:42

1 Answers1

0

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.

YangXiaoPo-MSFT
  • 1,589
  • 1
  • 4
  • 22