Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

How To Get Some Control Over GetOpenFileName() With OFN_EXPLORER And lpfnHook

$
0
0


Hello,

First things first:
1.) This is C++ win32 (No Mfc,CString,,,).
2.) This Needs to Run Under Windows Xp Sp3 through Windows 8 (Desktop)

I am trying to work with GetOpenFileName().
OFN_ENABLEHOOK|OFN_EXPLORER to Create A 'Folder'
only selection.

My callbacks are all working correctly.

I have the caller pass in a 'starting' folder.
I am splitting the Starting folder path. Example:
StartingFolder="c:\Source\Osu\GetOpenFileNameTest"
BaseFolder="c:\Source\Osu"
TargetFolder="GetOpenFileNameTest"

I set my OPENFILENAME.szDirName to BaseFolder.
I set my OPENFILENAME.lpstrFileTitle to TargetFolder.

When I call GetOpenFileName() the folder it starts in is correct.
The ListBox that displays files (in my case only folders) does in fact
display the folders contained within OPENFILENAME.szDirName.

I understand that the GetOpenFileName() has a system supplied dialog.
I understand that my callback OPENFILENAME.lpfnHook is actually process
a Dialog that is a Child of the system supplied Dialog for GetOpenFileName().

What I Want to do now is to get a handle to the ListBox that displays the
files (In my case folders) so I can set the ListViewItem in the ListBox
where ListViewItem.pszText is equal to TargetFolder(="GetOpenFileNameTest")
as the selected Item.

To get this handle: DirectoryListView=GetDlgItem(GetDlgItem(Hwnd,lst2),1)
where 'Hwnd' is the Parent of my OPENFILENAME.lpfnHook

My issue is finding out when the ListBox is created and the GetOpenFileName()
Dialog has completed the population of it.

To discourage some quick 'Try this' answers:
In OPENFILENAME.lpfnHook
   WM_INITDIALOG
   The ListBox has not yet been created.

   WM_NOTIFY ->CDN_INITDONE
   The ListBox still has not been created.

I Do Have The System Supplied Dialog Hooked Also, So I have
tried to monkey around with:
WM_NOTIFY
((NMHDR*)lParam)->idFrom==lst2
((NMHDR*)lParam)->code==LVN_INSERTITEM:
     
Setting A Timer and processing when I no longer am receiving this
notification. Unfortunatly I do not receive this notification.

I am hoping that someone has some brilliant insight into my
problem!

Thanks



Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>