+ Reply to Thread
Results 1 to 2 of 2

using Windows API Open Dialog/Browse in VBA - center form in scree

  1. #1
    Philip
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1