OPENFILENAME ofn;

This is a discussion on OPENFILENAME ofn; within the Windows Programming forums, part of the Platform Specific Boards category; DEV-C++ case (a || b) interpretation... it's weird... it only executes the case (a || b): statement if b is ...

  1. #16
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    DEV-C++ case (a || b) interpretation...

    it's weird... it only executes the case (a || b): statement if b is true but if it's a it goes to default...

    btw... i've also declared it outside of the switch statement so.. this is not the problem =( i wish it was....

  2. #17
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Post the error messages...

  3. #18
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    Code:
    OPENFILENAME ofn;
    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    The error comes in the 2nd line of the code and if that line is deleted the error will appear again in every place where a reference to ofn is made...

    error msg is: ofn was not declared in this scope...

    but wtf how can this be it's just above the line where the error is..... why am i starting to think that the solution to this will be really stupid and simple and i'm going to be reaally ashamed mmmm? maybe not.. well let's see how all this turns out..

    thanks again to everyone

  4. #19
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    this is WRONG and will not work as expected

    case (a || b) :
    //code
    break;

    this is correct and will do exactly the same thing

    case a:
    case b:
    //code
    break;
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #20
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Try this one. It wotks for me, and you will have the daclaration outside the WindowProc:
    Code:
    
    /* Displays a filelistbox */
    int GetFile(HWND hWnd, char *achBuf, char *achFilter, char *achTitle){
    	OPENFILENAME oFN;
    	char chRet(0);
    
    	ZeroMemory(&oFN, sizeof(OPENFILENAME));
    	oFN.lStructSize = sizeof(OPENFILENAME);
    	oFN.lpstrTitle = achTitle;
    	oFN.hwndOwner = hWnd;
    	oFN.lpstrFilter = achFilter;
    	oFN.lpstrFile = achBuf;
    	oFN.nMaxFile = _MAX_PATH;
    	return(GetOpenFileName(&oFN)?1:0);
    }
    Edit:
    Is ofn declared anywhere else in your code?

  6. #21
    Registered User
    Join Date
    Oct 2003
    Posts
    21
    Originally posted by knutso
    Edit:
    Is ofn declared anywhere else in your code?
    nope.. i'll try your option but i doubt it'll work *crossing fingers & opening dev-c++*...

  7. #22
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    you have included

    Windows.h?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #23
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Why not attach your .cpp file?
    Others can download it and check what's wrong.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Save vs Save As.... OPENFILENAME flags
    By csonx_p in forum Windows Programming
    Replies: 16
    Last Post: 06-01-2008, 02:42 PM
  2. Openfilename
    By Gordon in forum Windows Programming
    Replies: 15
    Last Post: 09-22-2007, 04:37 PM
  3. Using OPENFILENAME
    By IdioticCreation in forum Windows Programming
    Replies: 9
    Last Post: 01-16-2007, 07:26 AM
  4. OPENFILENAME structure
    By SuperNewbie in forum Windows Programming
    Replies: 1
    Last Post: 01-22-2004, 06:51 AM
  5. OPENFILENAME and multiple files.
    By -leech- in forum Windows Programming
    Replies: 4
    Last Post: 02-25-2003, 12:40 PM

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