Two quick questions about open file dialog boxes

This is a discussion on Two quick questions about open file dialog boxes within the Windows Programming forums, part of the Platform Specific Boards category; First quick question, I'm using OpenFileName structure with GetOpenFileName(), how do I set the starting x,y coordinates of the dialog ...

  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, 04: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, 06:28 AM
  4. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21