|
Pages: [1] 2 3 ... 5
|
 |
|
Author
|
Topic: Windows Explorer-style "browse for file" window (Read 47312 times)
|
|
raleeper
|
I can't find anything in the SDK help or elsewhere on how to open such a window.
It seems to me there ought to be a function that takes as input size, position, etc. and path, and returns on success a pointer to the selected path/filename string.
Can anyone help?
Thanks, ral
|
|
|
|
|
Logged
|
|
|
|
|
jj2007
|
Search the forum for GetOpenFileName and GetSaveFileName.
|
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
removed the code in this post - see my next post
|
|
|
|
« Last Edit: June 27, 2011, 12:43:19 PM by dedndave »
|
Logged
|
|
|
|
|
raleeper
|
Search the forum for GetOpenFileName and GetSaveFileName.
Thank You! Exactly what I wanted.
|
|
|
|
|
Logged
|
|
|
|
|
raleeper
|
dedndave:
This looks great. It will take a while to digest.
Thank you, ral
|
|
|
|
|
Logged
|
|
|
|
|
|
|
raleeper
|
Ah. I have it working. Thanks to jj2007 and dedndave.
Now the next question. How about a tip on how to get the (or any) dialog window to appear initially in a specified location?
|
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
you can use the MoveWindow function (simple) or SetWindowPos (more complicated - more controls) works for any window - all you need is the handle to the window in some cases, you get the handle, by whatever means, then use GetWindowRect to get the current position and size then use MoveWindow or SetWindowPos, as needed one way to get the handle of the specific dialog you are talking about is to write a simple hook for it there are a variety of other methods used to get window handles EnumWindows EnumChildWindows some handles are a little harder to get - like menu handles and balloon tips 
|
|
|
|
|
Logged
|
|
|
|
|
raleeper
|
Excellent! Looks eminently doable. Thanks you can use the MoveWindow function (simple) or SetWindowPos (more complicated - more controls) works for any window - all you need is the handle to the window in some cases, you get the handle, by whatever means, then use GetWindowRect to get the current position and size then use MoveWindow or SetWindowPos, as needed one way to get the handle of the specific dialog you are talking about is to write a simple hook for it there are a variety of other methods used to get window handles EnumWindows EnumChildWindows some handles are a little harder to get - like menu handles and balloon tips 
|
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
if you write a hook procedure for GetSaveFileName or GetOpenFileName, you simply put the address of the hook procedure in the OPENFILENAME structure, lpfnHook member in the hook, you should be able to trap the WM_INITDIALOG message and set the position the dialog window handle is one of the parameters passed to the hook proc
|
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
i was playing with some code for this
i noticed one thing that i had not noticed before in my original code, i used NULL for the hWndOwner member - meaning the dialog has no parent window (actually, the desktop is the parent) doing this allows the dialog to pop up outside of the parent window coordinates i wanted to assign a parent window so that i could use parent client coordinates as a reference when i changed the hWndOwner member, the dialog pops up at client (parent) coordinates 0,0 maybe this is what you were trying to achieve to begin with
|
|
|
|
|
Logged
|
|
|
|
|
ragdog
|
Here is a nice example
I think it was from Gunner
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
i like it  here is one that sets the initial position of the Open File dialog box
|
|
|
|
Logged
|
|
|
|
|
raleeper
|
1. I want to set the position relative to my main window - I had already seen this and used its handle instead of NULL. 2. Ultimately I want to set the position as near the current position of the mouse cursor as possible, or more precisely, in the position that minimizes the distance to the first displayed item in the file list. Thanks, ral i was playing with some code for this
i noticed one thing that i had not noticed before in my original code, i used NULL for the hWndOwner member - meaning the dialog has no parent window (actually, the desktop is the parent) doing this allows the dialog to pop up outside of the parent window coordinates i wanted to assign a parent window so that i could use parent client coordinates as a reference when i changed the hWndOwner member, the dialog pops up at client (parent) coordinates 0,0 maybe this is what you were trying to achieve to begin with
|
|
|
|
|
Logged
|
|
|
|
|
dedndave
|
you can use GetCursorPos to get the mouse cursor position it wouldn't be very simple to get the location of the first item on the list, however  still, you can estimate it close enough set the hWndOwner member back to NULL let me see if i can get you close - give me a few minutes.....
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1] 2 3 ... 5
|
|
|
 |