News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Windows Explorer-style "browse for file" window

Started by raleeper, June 25, 2011, 08:49:58 PM

Previous topic - Next topic

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

jj2007

Search the forum for GetOpenFileName and GetSaveFileName.

dedndave

#2
removed the code in this post - see my next post

raleeper

Quote from: jj2007 on June 25, 2011, 08:58:21 PM
Search the forum for GetOpenFileName and GetSaveFileName.

Thank You!
Exactly what I wanted.

raleeper

dedndave:

This looks great.  It will take a while to digest.

Thank you, ral

dedndave

here is a link to the same code - but simplified for better understanding
it also includes the FnAlloc and HFree routines

http://www.masm32.com/board/index.php?topic=16800.msg139721#msg139721

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?

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   :P

raleeper

Excellent!  Looks eminently doable.  Thanks

Quote from: dedndave on February 07, 2012, 04:10:16 AM
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   :P

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

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

ragdog

Here is a nice example

I think it was from Gunner

dedndave

i like it   :P

here is one that sets the initial position of the Open File dialog box

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

Quote from: dedndave on February 07, 2012, 05:59:36 PM
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

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   :P
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.....