I am trying to save a file using GetSaveFileName
and want to have a couple extra popups at the bottom of my save file dialog to allow the user to specify further options. I am trying to follow the MSDN documentation (specifically the Explorer-style customization) on the subject but can't seem to get my custom item to appear. I believe I set up the OPENFILENAME
struct properly as I'm getting calls into my OFNHookProc
. As far as I know it is during the WM_INITDIALOG
message that I should be creating my subcontrols, which is what I'm doing:
HWND settings_popup =
::CreateWindowExW(WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY,
L"COMBOBOX",
L"Settings:",
WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_BORDER | CBS_DROPDOWNLIST,
10,
10,
150,
30,
dialog, // the window parameter from the OFNHookProc
NULL,
::GetModuleHandle(NULL),
NULL);
if (settings_popup)
{
HWND parent = ::GetParent(settings_popup); // for verification
::ShowWindow(settings_popup, SW_SHOW);
::EnableWindow(settings_popup, true);
}
I also return 1 from my OFNHookProc
for the WM_INITDIALOG
message and 0 for everything else.
In all my attempts to get the combobox to show in the dialog, it's not coming up. What am I missing from my code to make the combobox a part of my save file dialog customization?
When calling CreateWindowEx() to create your child window, you need to use GetParent() to get the parent window of the dialog, and then use that HWND as your parent window. Do not use the dialog itself as the parent. In other words:
HWND settings_popup =
::CreateWindowExW(WS_EX_CLIENTEDGE | WS_EX_NOPARENTNOTIFY,
L"COMBOBOX",
L"Settings:",
WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_BORDER | CBS_DROPDOWNLIST,
10,
10,
150,
30,
::GetParent(dialog),
NULL,
::GetModuleHandle(NULL),
NULL);