The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
July 31, 2021, 10:30:10 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Campus
| | |-+  Windows Explorer-style "browse for file" window
« previous next »
Pages: [1] 2 3 ... 5 Print
Author Topic: Windows Explorer-style "browse for file" window  (Read 36776 times)
raleeper
Member
*****
Gender: Male
Posts: 285


Windows Explorer-style "browse for file" window
« on: June 25, 2011, 08:49:58 PM »

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
Member
*****
Gender: Male
Posts: 6011



Re: Windows Explorer-style "browse for file" window
« Reply #1 on: June 25, 2011, 08:58:21 PM »

Search the forum for GetOpenFileName and GetSaveFileName.
Logged

dedndave
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #2 on: June 25, 2011, 09:22:45 PM »

removed the code in this post - see my next post
« Last Edit: June 27, 2011, 12:43:19 PM by dedndave » Logged
raleeper
Member
*****
Gender: Male
Posts: 285


Re: Windows Explorer-style "browse for file" window
« Reply #3 on: June 25, 2011, 10:45:33 PM »

Search the forum for GetOpenFileName and GetSaveFileName.

Thank You!
Exactly what I wanted.
Logged
raleeper
Member
*****
Gender: Male
Posts: 285


Re: Windows Explorer-style "browse for file" window
« Reply #4 on: June 25, 2011, 10:55:40 PM »

dedndave:

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

Thank you, ral
Logged
dedndave
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #5 on: June 27, 2011, 12:42:14 PM »

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
Logged
raleeper
Member
*****
Gender: Male
Posts: 285


Re: Windows Explorer-style "browse for file" window
« Reply #6 on: February 07, 2012, 03:40:57 AM »

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
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #7 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   Tongue
Logged
raleeper
Member
*****
Gender: Male
Posts: 285


Re: Windows Explorer-style "browse for file" window
« Reply #8 on: February 07, 2012, 04:22:13 AM »

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   Tongue
Logged
dedndave
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #9 on: February 07, 2012, 04:31:43 AM »

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
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #10 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
Logged
ragdog
Member
*****
Posts: 1008


Re: Windows Explorer-style "browse for file" window
« Reply #11 on: February 07, 2012, 06:37:11 PM »

Here is a nice example

I think it was from Gunner

* Custom Open File Dialog.zip (7.47 KB - downloaded 333 times.)
Logged
dedndave
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #12 on: February 07, 2012, 08:31:36 PM »

i like it   Tongue

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

* SmallOFN.zip (8.42 KB - downloaded 318 times.)
Logged
raleeper
Member
*****
Gender: Male
Posts: 285


Re: Windows Explorer-style "browse for file" window
« Reply #13 on: February 08, 2012, 02:13:40 PM »

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
Member
*****
Posts: 12523


Re: Windows Explorer-style "browse for file" window
« Reply #14 on: February 08, 2012, 04:21:53 PM »

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   Tongue
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 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!