Click to See Complete Forum and Search --> : OPENFILENAME
Vlatko
Oct 8th, 2000, 04:58 AM
How to make a buffer in this case. Is there something like Space(n) in VB in C++.
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.
parksie
Oct 8th, 2000, 05:12 AM
Use:
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).
Vlatko
Oct 8th, 2000, 07:35 AM
No Use.
The files in the fileopen dialog stil look like :
"лллллллллллллллллллллллллллллллл..."
Vlatko
Oct 8th, 2000, 07:42 AM
Proble Solved.
I found this code on the i-net.Although i don't fully understand it , it works great.
#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);
Vlatko
Oct 8th, 2000, 09:11 AM
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.
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]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.