Thread: GetOpenFileName() ?

  1. #16
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> it returns false

    Ah, so call CommDlgExtendedError() and see why.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  2. #17
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Well I did some error checking and found out that CommDlgExtendedError() returns CDERR_STRUCTSIZE, this means that:

    The lStructSize member of the initialization structure for the corresponding common dialog box is invalid.

    ofn.lStructSize = sizeof(ofn);

    What's wrong with that?
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  3. #18
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Try changing...
    Code:
    ofn.lStructSize = sizeof(ofn);
    ... to...
    Code:
    ofn.lStructSize = sizeof(OPENFILENAME);
    ... and see if that works. If it doesn't work, tell me what OS version you are using.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #19
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>I'm using borland C++ 5.5 compiler<<

    If you are using bcc5.5 cmd line tools with win9x/nt and have not set up your configuration files correctly then the kind of problem you are experiencing will typically occur.

    Read my post in this faq for further information.

  5. #20
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    If you are using bcc5.5 cmd line tools with win9x/nt and have not set up your configuration files correctly then the kind of problem you are experiencing will typically occur.
    I never had any problems before that, all controls and dialogs worked...


    And, the CDERR_STRUCTSIZE is still there, after I changed the size... So, I'm running win98 second edition
    Last edited by Devil Panther; 07-19-2003 at 08:21 AM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  6. #21
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Try changing...
    Code:
    ofn.lStructSize = sizeof(OPENFILENAME);
    ... to...
    Code:
    ofn.lStructSize = sizeof(OPENFILENAME_SIZE_VERSION_400);
    ... and see if that works.

    Ken is thinking along the same lines as me, a number of structures have been changed by MS, particulaly after 0x0400. This was one of them.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #22
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Nothing... still the same error.

    adrianxw, you know I think I'm up to something... can you download http://www.winprog.org/tutorial/files/source.zip and run app_two.exe (it's located inside the zip), then try to FILE->OPEN inside app_two.exe

    You see, because app_two uses GetOpenFileName(), but the FILE->OPEN doesn't open me anything, no dialog not nothing.
    Check it out, and let me know if that works for you.


    Thanks
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  8. #23
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Originally posted by Devil Panther
    I never had any problems before that, all controls and dialogs worked...
    If you use bcc5.5 and you compile and run your program which contains common dialogs on win98 (generally win9x/nt) and you have not defined:
    -DWINVER=0x0400
    -D_WIN32_WINNT=0x0400
    in your bcc32.cfg file then your common dialog will not appear.

    Do you have those macros defined in your bcc32.cfg file? If not, put them in and recompile - your common dialog (file) will show, provided there are no other errors in your code.

  9. #24
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    If I try to run the .exe on my Win95 machine, it behaves as you suggest, however, when I compile it, (after fixing a couple of things that MSVC grouched about), it worked as expected. On my WinXP system the .exe runs.

    I am quite sure your problem is with the changed definition of the OPENFILENAME structure. Try what Ken is saying, you somehow need to make sure that your compiler knows which version of the structure you need.

    I often find myself putting a #define for _WIN32_WINNT in programs.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  10. #25
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    IT WORKS!!!!

    IT WORKS IT REALLY WORKS... Ken you were right.

    gee guys... I don't know what say...
    Thanks for all of your help, it's good to know that when you have a problem, there is a place like this.

    Thanks a million.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GetOpenFileName not working...
    By manugarciac in forum Windows Programming
    Replies: 6
    Last Post: 04-24-2007, 10:50 PM
  2. GetOpenFileName function for dir's?
    By willc0de4food in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2006, 12:54 AM
  3. Major Problems with GetSaveFileName() and GetOpenFileName()
    By CodeHacker in forum Windows Programming
    Replies: 8
    Last Post: 07-12-2004, 11:05 AM
  4. Troubles with GetOpenFileName()
    By lyx in forum Windows Programming
    Replies: 13
    Last Post: 10-28-2003, 09:47 PM
  5. GetOpenFileName() won't show
    By harryP in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2003, 04:47 PM