Controlling folder combo in an Open Dialog in Win32

Is there a way to control folder combo box ('Look in:')
from a hook function of an Open Dialog under Win32?
I need to select folder depending on a value in a
file-filter combo.
magnezkoAsked:
Who is Participating?
 
NickRepinConnect With a Mentor Commented:
1. You should obtain the dialog item id for the 'folder' combobox.
This can be done by opening COMDLG32.DLL with any resource editor. You can also refer to DLGS.H .
cmb2 == 0x471 == 'Look in' combobox
edt1 == 0x480 =='File name' combobox
1 == 'Open' pushbutton

2. In response to CDN_TYPECHANGE, select appropriate
folder. I am not sure you can do this by changing lpstrInitialDir.
But you can simulate user input in 'File name' field and pressing 'Open'. Eg, we need to change current dir to 'c:\temp'.

// Prevent redrawing
SendDlgItemMessage(hdlg,edt1,WM_SETREDRAW,FALSE);
SendDlgItemMessage(hdlg,1,WM_SETREDRAW,FALSE);
// Changing text in 'File name'. Here you can save previous text
SendDlgItemMessage(hdlg,edt1,WM_SETTEXT,0,"c:\\temp"
// Emulating pressing 'Open'
SendDlgItemMessage(hdlg,1,BM_CLICK);
// Now dialog should change current folder to 'c:\temp'
// Here you can restore previous text in 'File name'

// Allow redrawing
SendDlgItemMessage(hdlg,edt1,WM_SETREDRAW,TRUE);
SendDlgItemMessage(hdlg,1,WM_SETREDRAW,TRUE);

// Also here you can update edt1 or/and 'Open' pushbutton
// (although it is not necessary in this case) by using InvalidateRect() and UpdateWindow().

0
 
AVaulinCommented:
You must handle WM_NOTIFY CDN_TYPECHANGE message, detect which folder selected, change it how you want and send WM_NOTIFY CDN_FOLDERCHANGE.
0
 
magnezkoAuthor Commented:
I do handle CDN_TYPECHANGE and when handling this notification
message I want to change folder (directory) in folder combo
from my code, not from user interface.
This cannot be done by sending notification CDN_FOLDERCHANGE
which is used to notify me about change in that combo.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
AVaulinCommented:
Try change m_pofnTemp->lpstrInitialDir and call Update function.
0
 
magnezkoAuthor Commented:
Which "Update function" ???

I'm working solely with WIN32 API, no class libraries,
such as MFC or OWL ...


0
 
AVaulinCommented:
I didn't say that you don't use any library. So can you show how do you create dialog and handle CDN_TYPECHANGE message.
0
 
magnezkoAuthor Commented:
EXCELENT! THANK YOU!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.