|
-
Oct 8th, 2000, 04:58 AM
#1
Thread Starter
Frenzied Member
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.
-
Oct 8th, 2000, 05:12 AM
#2
Monday Morning Lunatic
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
-
Oct 8th, 2000, 07:35 AM
#3
Thread Starter
Frenzied Member
No Use.
The files in the fileopen dialog stil look like :
"ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ..."
-
Oct 8th, 2000, 07:42 AM
#4
Thread Starter
Frenzied Member
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);
-
Oct 8th, 2000, 09:11 AM
#5
Thread Starter
Frenzied Member
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|