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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You must handle WM_NOTIFY CDN_TYPECHANGE message, detect which folder selected, change it how you want and send WM_NOTIFY CDN_FOLDERCHANGE.
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.
Try change m_pofnTemp->lpstrInitialDir and call Update function.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

magnezkoAuthor Commented:
Which "Update function" ???

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

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.
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
// Changing text in 'File name'. Here you can save previous text
// Emulating pressing 'Open'
// Now dialog should change current folder to 'c:\temp'
// Here you can restore previous text in 'File name'

// Allow redrawing

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
magnezkoAuthor Commented:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.