Thread: Two quick questions about open file dialog boxes

  1. #1
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728

    Two quick questions about open file dialog boxes

    First quick question, I'm using OpenFileName structure with GetOpenFileName(), how do I set the starting x,y coordinates of the dialog box? It always opens in the top left corner and I want the dialog box to open more centered, and I don't see anywhere in the structure to set the coordinates.

    Second quick question, how do I create a open file dialog box that allows you to choose only choose and view directories, preferably using the same above structures/functions?

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    1. You can use a hook procedure to modify default behaviour. Set the lpfnHook member of the OPENFILENAME struct to an OFNHookProcOldStyle pointer; the Flags member of the OPENFILENAME struct needs to have the OFN_EXPLORER bit set. Then just handle the WM_INITDIALOG message in the hook procedure and use either MoveWindow or SetWindowPos to shift/resize it as required.

    2. SHBrowseForFolder - plenty of examples to be found in this board, like this one.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Cool, thanks!

  4. #4
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    One last question about opening files, I noticed that my open file dialog boxes open as new windows and will show up in the toolbar, while most applications that I use this does not happen nor does it happen with other windows I create. How would I set this attribute?

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Make sure you set the hwndOwner of the OPENFILENAME struct to the window handle of your application/common dialog launcher.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Thanks, considering I cut and paste a lot of the openfile code from the internet, I'd be willing to bet thats the problem. I'll check when I get home tonight.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  3. open a file browser from a win32 dialog
    By jcorrington in forum Windows Programming
    Replies: 4
    Last Post: 11-10-2004, 07:28 AM
  4. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM