Re: OpenFileName - Details as default

new topic     » goto parent     » topic index » view thread      » older message » newer message

Mike777 wrote:
> 
> Using win32lib via Enhanced IDE as my development platform, is there a way to
> ask that the open file name dialog box be opened with the Details view as the
> default, and with the resulting view sorted on either file name or in date
> order
> (by user choice)?  I would have thought that one of the OFN flags would
> specify
> the view or the sort order, but I haven't found anything that indicates it to
> be so.
> 
> <a
> href="http://msdn2.microsoft.com/en-us/library/ms646839">http://msdn2.microsoft.com/en-us/library/ms646839</a>(VS.85).aspx
> 
> is pretty detailed.  It seems that the right way to do this is to specify a
> hook procedure with the flag OFN_ENABLEHOOK. win32Lib's getopenfilename
> procedure
> allows me to set the flag. However, once that is done, I am a bit lost.  It
> looks like the lpfnHook needs to be set with a pointer to a hook procedure and
> then, at some point, change the view (probably with an appropriately placed
> 
> 
> ListView_SetView(hListView,LV_VIEW_DETAILS)
> 
> It doesn't appear that the lpfnHook item is exposed to me. But I'm just
> guessing
> at 1/2 of this.
> 
> Thanks
> 
> Mike

What you are asking for, which is documented in nan MSDN forum post, is to
directly interact with a dialog box, which are black boxes by dsign.

If there is consolidated significant demand for such things about the standard
Windows dialogs, like color or font picker, find/replace boxes etc, I'll consider
including some stuff in 70.5, or 71.0 if tehnical hurdles are many, which I
suspect.

The following will attempt to explain how to go about that issue, and assumes
some familiarity with Win API programming.

The lpfnHook member isn't exposed directly, but it will in the next version
using getOpenFileNameEx().

The prototype for the OfnProcHook placeholder routine is given in MSDN. You have
to design an Euphoria function with a compatible arg list and set the lpfnHook
member to call_back(routine_id(the_routine)).

As the arg list shows, this function will receive messages. The one of concern
to us is WM_INITDIALOG. wParam is a control handle from the dialog, probably the
Ok button. The lParam won't matter here.

As you figured, we need to know the handle of the listview in the box so as to
send it an LVM_SETVIEW message. Problem is, disalog boxes are designed to hide
the controls they display. Technically, we are going to hack at the std dlgbox.

We have a control handle. From there, GetParent() will provide the handle to the
dialog box. Perhaps we need to call it several times checking the class, but I
don't think so, if the returned control is indeed a button.

Now we have to scan the box whose handle we just reckoned for the listview.
Since this listview is obviously tab stoppable, there is a way to get it, which
is the GetNextDlgItem(hDlg,hCtl,bPrevious) API. Since you don't know whether he
listview is created before or after the Ok button (I bet before), call it first
with bPrevious=1, but be prepared to use 0 if no listvie was found (starting from
hCtl again).

For each succesful return of the function, we check its class name using
GetClassName() and hope to identify a listview. That's how I'd go about it - NOT
TESTED. Btw, the function should return w32True tfor the initial focus to be set.

The method I have seen on the MSDN forum is to use WinSpy to infer the id of the
listview (not a win32lib id!), then call GetDlgItem() on that and retrieve the
handle. A third method would be to check the resource files of a C compiler and
extract the id from there - then convert to handle as above.

If you read till there, you can do it.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu