using Windows API Open Dialog/Browse in VBA - center form in scree
Philip,
Use the FindWindow API to get the form's handle.
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWND As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const WM_CLOSE = &H10
Function FindhWnd()
Dim hWND As Long
UserForm1.Show vbModeless
#If VBA6 Then
hWND = FindWindow("ThunderDFrame", UserForm1.Caption)
#Else
hWND = FindWindow("ThunderXFrame", UserForm1.Caption)
#End If
SendMessage hWND, WM_CLOSE, 0, 0
FindhWnd = hWND
End Function
--
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Philip" wrote in message
...
Hi,
I am using an API implementation of SHBrowseForFolder (to get a LAN
directory from the user) and GetOpenFileName API call to show the WIndows
Open Dialog (to get a filename to open).
I would like to additionally be able to center both those Windows dialogs
in
the screen, and also, with the Open Dialog, I'd like to have it
automatically
show the 'Details List view'
Unfortunately, calls like 'SetWindowPos', PostMessage, SendMessage,
GetWindowRect all need a pointer value for the hwnd of the owner form
which
is not available in VBA Forms...
Is there anway to get that value?
thanks
Philip
|