Results 1 to 5 of 5

Thread: OPENFILENAME

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    How to make a buffer in this case. Is there something like Space(n) in VB in C++.
    Code:
    OPENFILENAME op;
    op.lStructSize  = sizeof(op);
    op.hwndOwner  = hDlg;
    op.nMaxFile  = 256; //something is wrong here
    char a[255]; //something is wrong here
    op.lpstrFile  = a; //something is wrong here
    op.Flags  = OFN_CREATEPROMPT;
    GetOpenFileName(&op);
    The Fileopen dialog is looking like !#$@!@#!!# ,i can't see the file names.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use:
    Code:
    OPENFILENAME op;
    char a[256];
    
    op.lStructSize  = sizeof(OPENFILENAME);
    op.hwndOwner  = hDlg;
    op.nMaxFile  = sizeof(a);
    op.lpstrFile  = a;
    op.Flags  = OFN_CREATEPROMPT;
    GetOpenFileName(&op);
    ...instead. It's not too different, but it's what was in the PSDK. Anyway, just using char a[256] allocates the buffer for you (it's full of random data).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    No Use.
    The files in the fileopen dialog stil look like :
    "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ..."
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Proble Solved.
    I found this code on the i-net.Although i don't fully understand it , it works great.
    Code:
    #include <memory.h>
    #define FILENAMESIZE	512
    ...
    OPENFILENAME	ofn;
    BOOL		b = FALSE;
    char *szFullPathName;
    	lstrcpy(szFullPathName,"");
    	memset(&ofn,0,sizeof(OPENFILENAME));
    	ofn.lStructSize = sizeof(OPENFILENAME);
    	ofn.hwndOwner = hDlg;
    	ofn.nFilterIndex = 1;
    	ofn.lpstrFile = szFullPathName;
    	ofn.nMaxFile = FILENAMESIZE;
    	ofn.lpstrDefExt = "txt";
    b = GetOpenFileName(&ofn);
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I just get the warning that the variable szFullPathName is not initialized.How to initialize it.
    I tried this,it works but later i get an illegal operation when i want to save a file.
    Code:
    TCHAR *szFullPathName;
    szFullPathName = new TCHAR[512];
    Is this OK or i need to initialize it in some other way.

    [Edited by Vlatko on 10-08-2000 at 10:13 AM]
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width