File Open/Save Dialog
I'm trying to browse a directory in File Open/Save dialog. I could able to get the handle of common dial开发者_如何学运维og as well as its control window. But I don't know how to provide a filename and click the Save/Open button to Save/Open a file. I couldn't find the SendMessage parameters needed to perform these actions. Any suggestions?
Why are you using SendMessage? Why not use the built in OpenFileDialog
and SaveFileDialog
classes?
See here for details about OpenFileDialog
:
http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx
I'm assuming that you are trying to control a different application, and that's why you are getting the handle of the window etc.
If that's the case, you could 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 an Open or Save dialog in your own program, then you should use the built-in OpenFileDialog and SaveFileDialog components.
What actions are you trying to do? You have the post tagged as C#, but I can't think of a reason to get the hwnds and use SendMessage.
For example, in the WPF OpenFileDialog/SaveFileDialog you can set the property FileName (or FileNames) or set the InitialDirectory.
精彩评论