-
a problem when using "SendMessage" to retrieve the number of the buttons on toolbar
I encountered a problem when use API function "SendMessage" to retrieve the
number of the buttons on the toolbar supported by CommCtrl32. I add two buttons
on the toolbar by its property dialog box. i just want to testify the retrieve
value of the "SendMessage"function is 2, however in my project,the result
is out of my expect! it is 0, shown in my TextBox. what's wrong with me ?
my code is as follws:
###########################################################################
Private Const WM_USER = &H400
Private Const TB_BUTTONCOUNT = WM_USER + 75
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
Private Sub Command1_Click()
Dim throw As Long
throw = SendMessage(Toolbar1.hwnd, TB_BUTTONCOUNT, 0, 0)
Text1.Text = throw
End Sub
###########################################################################
-
Re: a problem when using "SendMessage" to retrieve the number of the buttons on toolbar
You're sending message(s) to the wrong window. The VB ocx version of
the toolbar utilizes its own parent window, and the hwnd property is
actually for the parent. Use GetWindow with GW_CHILD to obtain the
hwnd of the "real" toolbar.
Ex:
throw = SendMessage(GetWindow(Toolbar1.hwnd,GW_CHILD), _
TB_BUTTONCOUNT, ByVal 0&, ByVal 0&)
On 19 Nov 2002 07:29:28 -0800, "jogge" <vb.@127.0.0.1> wrote:
>I encountered a problem when use API function "SendMessage" to retrieve the
>number of the buttons on the toolbar supported by CommCtrl32. I add two buttons
>on the toolbar by its property dialog box. i just want to testify the retrieve
>value of the "SendMessage"function is 2, however in my project,the result
>is out of my expect! it is 0, shown in my TextBox. what's wrong with me ?
>
>my code is as follws:
>
>###########################################################################
>
>Private Const WM_USER = &H400
>Private Const TB_BUTTONCOUNT = WM_USER + 75
>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
>
>Private Sub Command1_Click()
>Dim throw As Long
>throw = SendMessage(Toolbar1.hwnd, TB_BUTTONCOUNT, 0, 0)
>Text1.Text = throw
>End Sub
>###########################################################################
-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
-
Re: a problem when using "SendMessage" to retrieve the number of the buttons on toolbar
Tom :
thank for your quick response! your reply make me understand the cause!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|