|
-
February 3rd, 2005, 09:17 AM
#1
open file window (open...)
I have been looking for the answer but I couldn't find what I am looking for...
I want, using API, open that window where it is possible to select a file. Almost all program has this option inside menu "file" >> "open..."
I would like to know if there is any specific function to do that !! ?
or any tutorial where I could get info about it.
If someone knows the answer for that help me!
Thanks
-
February 3rd, 2005, 09:24 AM
#2
Re: open file window (open...)
-
February 3rd, 2005, 09:37 AM
#3
Re: open file window (open...)
This tutorial seems to be used with MFC...I would like to know what would give me the same result but with API.
Thanks
-
February 3rd, 2005, 09:47 AM
#4
Re: open file window (open...)
-
February 3rd, 2005, 09:48 AM
#5
Re: open file window (open...)
Code:
char szExtBuffer[MAX_PATH] = "";
OPENFILENAME ofn;
strcpy(szExtBuffer, "*.txt; *.log");
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = 0;
ofn.hInstance = 0;
ofn.lpstrFilter = 0;
ofn.lpstrCustomFilter = 0;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = szExtBuffer;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = 0;
ofn.lpstrTitle = "Open file";
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = 0;
ofn.lCustData = 0;
ofn.lpfnHook = 0;
ofn.lpTemplateName = 0;
// Open dialog
if(::GetOpenFileName(&ofn) == FALSE)
// Cancel pressed
-
February 3rd, 2005, 10:19 AM
#6
Re: open file window (open...)
Code:
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = 0;
ofn.hInstance = 0;
ofn.lpstrFilter = 0;
ofn.lpstrCustomFilter = 0;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = szExtBuffer;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = 0;
ofn.lpstrTitle = "Open file";
ofn.Flags = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = 0;
ofn.lCustData = 0;
ofn.lpfnHook = 0;
ofn.lpTemplateName = 0;
This is too much code in my eyes, since it would go easier:
Code:
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szExtBuffer;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = "Open file";
Or even better:
Code:
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szExtBuffer;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrTitle = "Open file";
Last edited by NoHero; February 3rd, 2005 at 10:56 AM.
-
February 8th, 2005, 04:41 AM
#7
Re: open file window (open...)
This discussion was very usefull
Thank you all,
-
February 8th, 2005, 04:49 AM
#8
Re: open file window (open...)
 Originally Posted by NoHero
This is too much code in my eyes, since it would go easier:
This kind of depends on the actual parameters you want to set though...
-
February 8th, 2005, 06:18 AM
#9
Re: open file window (open...)
 Originally Posted by Andreas Masur
This kind of depends on the actual parameters you want to set though... 
Of course. Since 80% of your code are zero setters, so you can make it smaller with my suggestion.
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
|