Thread: Create an open file window

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    16

    Create an open file window

    How do I create one of those explorer windows for choosing a file to open? I'm guessing its some WinAPI function but I have no idea what it is. Thanks.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    38
    Last edited by nicoqwertyu; 03-13-2010 at 08:01 PM.

  3. #3
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    you can try a good tutorial like TheForger.

    TheForgers - EFNet #Winprog

    i readed it some months ago, it covers most of the commands needed for
    file opening. by the way, its a FileDialog not an Open File Window.

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by UltraKing227 View Post
    you can try a good tutorial like TheForger.

    TheForgers - EFNet #Winprog

    i readed it some months ago, it covers most of the commands needed for
    file opening. by the way, its a FileDialog not an Open File Window.
    Well now that I have a vague grasp of how to use this function.. I'm now getting an "undefined reference to GetOpenFileNameA@4" error when I compile.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    From the MSDN link nicoqwertyu gave you:
    Import library Comdlg32.lib

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Quote Originally Posted by _Mike View Post
    From the MSDN link nicoqwertyu gave you:
    Where exactly do I put that? I don't see it in the source code I got from the place UltraKing linked.

  7. #7
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    try making a Windows-based project instead of a console-one.
    (note: this step is different in every IDE, so i cant give specific instructions
    on how to make a project).

  8. #8
    Registered User UltraKing227's Avatar
    Join Date
    Jan 2010
    Location
    USA, New york
    Posts
    123
    by the way, the reason you get that error is simple.
    GetOpenFileName is only for WinGUI, not dos. so when you make a
    console-based project, the linker gives an error to tell you that Dos
    cant do this stuff.

  9. #9
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    I've made plenty of DOS console projects in MSVC 6 that utilize these open/save dialog windows.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  10. #10
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Changing it to a Win32 GUI project in Code::Blocks didn't do anything. Also, it is compiling with "-lcomdlg32", so that's not the problem.

    I've also seen plenty of console tools that can open a file.

    Looking at MSDN it seems like there's a different set of API for Vista file dialogs, I wonder if that has anything to do with this. I hope not because the Common Item whatever is going straight over my head.

  11. #11
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    What does CommDlgExtendedError() say when it fails?

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. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM