How to get the handle of a Vista style Open/SaveDialog?

747 views Asked by At

I'd like to get the window handle of a new vista-style Open/SaveDialog opened by my Delphi application.

It was possible with the old style dialog by parsing OnShow, but with the new style dialog there is no such event.

Is there a possibility maybe to iterate through all window handles in Windows and get it that way?

Thanks!


Edit: I know that OpenDialog.Handle will return the handle, but only when the dialog is visible (otherwise it's 0). I'd need an event to catch the Handle straight after showing the dialog (without any user action, ie.: select an item in the dialog, changing the file type, etc.).

2

There are 2 answers

1
David Heffernan On

I'd like to get the window handle of a new vista-style Open/SaveDialog opened by my Delphi application.

This is available through the dialog's Handle property.

Probably the easiest way to catch the event of the dialog showing is to use a CBT hook that you set immediately before showing the dialog, and remove as soon as it closes.

8
SilverWarior On

TOpenDialog has an OnShow event which fires just after dialog is shown so you can use to get the OpenDialog.Handle since the handle is already set at that time.

EDIT: After some pepole pointed out that using of OnShow event changes the dialogs apperance I tested this out and can confirm that using of OnShow event realy does change the dialogs aperance.