Advertisement

GetOpenFileName question (windows)

Started by June 09, 2000 04:09 PM
4 comments, last by logomez 24 years, 6 months ago
I am trying to customize the Common Dialog to retrieve a file from a user using the GetOpenFileName() call. I would like to be able to set the current directory being displayed programatically after the GetOpenFileName() function has been called. For example when a user clicks on a specific button that I have added to the dialog then the dialog changes the directory it is in to a directory I specify. I have not seen any explicit function calls to do this but I have heard it can be done. Does anyone have any suggestions? thanks, luis
ok, hope this is what you mean.

OPENFILENAME file = {			sizeof(OPENFILENAME),			hWnd,			NULL,			TEXT("My save games\0*.msg\0All Files\0*.*\0\0"),			NULL,0,1,			strFileName,			MAX_PATH,			NULL,0,			"\\GameDir",			TEXT("Open Save Game"),			OFN_FILEMUSTEXIST/OFN_HIDEREADONLY,			0,0,			TEXT(".msg"),			0,NULL,NULL};if(GetOpenFileName( &file ) ){ //...
Advertisement
I am making a similar call like the one you wrote, but additionally I wish to be able to change the directory
initially specified \\Gamedir after the dialog has been displayed by making some call or sending some message.

I think this is best illustrated with the followind example. Again, suppose i add a Home Button to this dialog box and in response to the user clicking it I change the directory of the Dialog Box to my Home folder. The user does not do the navigation
through the folders. I take him/her directly to it, by just one
click of a button.

thanks again,

luis
Let me explain some more.

Where I have "\\GameDir", put in a string there.

(Create the string as follows: char myPath[MAX_PATH] = ""; )

What GetOpenFileName() will do is change that string to the directory you finally opened a file.

You can change the specific directory any time you wish by just changing the string.

Edited by - Nytegard on June 9, 2000 6:20:57 PM
Nytegard,

i think we are still talking about different things. I think you are saying that on a second call to GetOpenFileName() after I have modified the string buffer to whatever i want it to be the new dialog box will appear in the folder i specified in the string.

Is that what you are suggesting? I did try changing the string while the dialog is still showing but that does not change the directory.

What i need to do is call GetOpenfileName once and for the dialog to change directory automatically if i change my string while the dialog is still displayed. It should not involve closing it and then make another call to GetOpenFileName

any more suggestions,

i really appreciate all the help though

luis
Have you used the SetCurrentDirectory() function?

BOOL SetCurrentDirectory(
LPCTSTR lpPathName // new directory name
);

I don''t know if this will help, but you should look at the WIN32 API help file.

-dron1

This topic is closed to new replies.

Advertisement