Results 1 to 4 of 4

Thread: How to get the "hWnd" of a button of Toolbar.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Location
    China
    Posts
    25

    Question

    How to get the "hWnd" of a button of Toolbar.
    Use FindWindow API? What the two parameters of it?

  2. #2
    New Member
    Join Date
    Aug 2000
    Posts
    3

    here is a start

    get rid of a start button then bring it back. If you use the commented code you will not bring back the start button till a reboot, be careful have fun.....

    Dim hWnd1 As Long


    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long


    Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long


    Private Declare Function ShowWindow Lib _
    "user32" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long
    Const SW_HIDE = &H0
    Const SW_SHOW = &H5


    'Private Declare Function SendMessage Lib "user32" Alias _
    '"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ' ByVal wParam As Long, lParam As Any) As Long

    'Const WM_CLOSE = &H10



    Private Sub Command1_Click()
    'SendMessage FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString), WM_HIDE, 0, 0
    ShowWindow FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString), SW_HIDE


    End Sub

    Private Sub Command2_Click()
    'SendMessage FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString), WM_SHOW, 0, 0
    ShowWindow FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString), SW_SHOW
    End Sub

    Private Sub Form_Load()
    ShowWindow FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString), SW_HIDE
    End Sub

  3. #3
    Guest
    Not really.

    The start button is A CONTROL itself, while a toolbar button is A PART of the control. Tecnically, it's impossigle, but I'm sure there's a way...

    Try to Spy++ the start button. It works, doesn't it? But try the same thing on a toolbar...not so easy, am I correct?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Location
    China
    Posts
    25

    Wink Thank you all and I settle my trouble in another way

    I wanna let a form fly into a button on toolbar.So I have to konw it handle.But now I put a CommandButton and make sure he can at the same place with the button on toolbar and my trouble settled in this way.

Posting Permissions

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



Click Here to Expand Forum to Full Width