CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Nottingham, UK
    Posts
    35

    I want to change the behaviour of the Open common control

    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.


  2. #2
    Join Date
    Apr 1999
    Posts
    8

    Re: I want to change the behaviour of the Open common control

    Hi,
    I have successfully changed the behavior of a CFileDialog by changing the Help button into an Information button that displays information about the selected file.
    I would recommend you to read the excellent article on the matter in the october issue of Visual C++ Developers Journal:
    http://www.vcdj.com/online/articles/oct98/opensave1.asp



    /Michael Grundberg
    M.Sc. Computer Science
    Visionova IT-System, Sweden
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured