File open / save dialog

I am trying to browse a directory in the Open / Save File dialog box. I could get the handle of the general dialog as well as its control window. But I don’t know how to specify the file name and click “Save / Open” button to save / open the file. I could not find the SendMessage options required to complete these steps. Any suggestions?

+2


a source to share


3 answers


I am assuming you are trying to control another application and why you are getting a window handle etc.

If so, you can use SendKeys to send Alt-N to select the name field, then the filename, then Alt-S to hit save.



If you are just trying to use the Open or Save dialog in your own program, then you should use the built-in components OpenFileDialog and SaveFileDialog.

0


a source


Why are you using SendMessage? Why not use built-in classes OpenFileDialog

and SaveFileDialog

?

See here for more details OpenFileDialog

:



http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

+2


a source


What actions are you trying to do? You have a C # tag post but I can't think of a reason to get hwnds and use SendMessage.

For example, in WPF OpenFileDialog / SaveFileDialog you can set the FileName property (or filenames) or set InitialDirectory.

0


a source







All Articles