Clive Walker
April 16th, 1999, 04:26 AM
I have derived a class from CFileDialog because I have added a preview control to the open common dialog. I have overridden CFileDialog::OnFileNameChange which gets called as expected when the user selects a file so I can redraw the preview control. However I also need to know when a user selects a directory but doesn’t actually open it, this is because a document in the application I'm working can be made up from multiple files in a directory, but only if the directory has a certain extension (Yeah I know its weird). I would also like to stop them entering a directory of this type and if possible display a different icon in the list control, rather than the normal folder icon. So I have overridden CFileDialog::OnLBSelChangedNotify because I thought this would give me the ID of the list control as the first parameter, from this I could get its handle and could find out what I needed to know, but this override never gets called, does anyone know why?
I have managed to cludge the code for a partial solution by calling GetFocus and casting to a CListCtrl in my OnFileNameChange function to get access to the list control in the open dialog. I can then access the list control and find out if the user has selected a directory, however this is by know means a perfect, it doesn’t work the first time you select something. I have tried in vain to get the handle of the ClistCtrl, using ChildWindowFromPoint etc but GetFocus was the only method I found that would work.
I’m using MS Visual C++ 6.0 and it mentions in the help about OFNHookProc that you can subclass the standard controls on a common dialog ( but they don’t recommend it ), this seems the only way for me to go if I want to change the behaviour of the list control, ie Change the icon for certain folders and stop the user opening them and also return these types of directory as a file when the user selects ok. Has anyone ever done this and does anyone have a foolproof method of getting the handle of these standard controls?
I don't particularly want to write my open gadget from scratch, especially as the dialog box resource templates are no longer supplied.
I have managed to cludge the code for a partial solution by calling GetFocus and casting to a CListCtrl in my OnFileNameChange function to get access to the list control in the open dialog. I can then access the list control and find out if the user has selected a directory, however this is by know means a perfect, it doesn’t work the first time you select something. I have tried in vain to get the handle of the ClistCtrl, using ChildWindowFromPoint etc but GetFocus was the only method I found that would work.
I’m using MS Visual C++ 6.0 and it mentions in the help about OFNHookProc that you can subclass the standard controls on a common dialog ( but they don’t recommend it ), this seems the only way for me to go if I want to change the behaviour of the list control, ie Change the icon for certain folders and stop the user opening them and also return these types of directory as a file when the user selects ok. Has anyone ever done this and does anyone have a foolproof method of getting the handle of these standard controls?
I don't particularly want to write my open gadget from scratch, especially as the dialog box resource templates are no longer supplied.