Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default using Windows API Open Dialog/Browse in VBA - center form in scree

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
browse to open and save as in Excel vbs seven Excel Discussion (Misc queries) 3 October 25th 07 10:30 AM
Browse button on form for folder path Greshter Excel Discussion (Misc queries) 2 January 12th 06 10:20 PM
Center text in dialog box Raza Excel Worksheet Functions 1 December 5th 05 08:34 PM
control of dialog macro dialog box. on open Gerry Abbott Excel Programming 0 July 22nd 04 05:41 PM
Browse Dialog Box in VBA? Raul[_4_] Excel Programming 5 May 12th 04 03:29 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"