在工具栏中发送按钮单击消息 [英] Send button click message in toolbar
问题描述
您好,
我想使用Win32 API在工具栏中发送按钮点击消息。
所以,我做了如下代码。
Hello,
I want to send button click message in Toolbar using Win32 API.
So, I made code like below.
//////////////////////////////////////////////////////////////////////////////
TBBUTTON TB_Data={0};
int btn_count= 0, i = 0;
...
// Searching Toolbar handle code using Spy++ and FindWindow function
// Parent_hWnd has handle value of Toolbar
...
btn_count = SendMessage(Parent_hWnd, TB_BUTTONCOUNT, 0, 0);
i = SendMessage(Parent_hWnd, TB_GETBUTTON, (WPARAM)5, (LPARAM)(&TB_Data));
SendMessage(Parent_hWnd, TB_PRESSBUTTON, (WPARAM)TB_Data.idCommand, (LPARAM)TRUE);
SendMessage(Parent_hWnd, TB_PRESSBUTTON, (WPARAM)TB_Data.idCommand, (LPARAM)FALSE);
//////////////////////////////////////////////////////////////////////////////
但它不起作用。
据我所知,下面的代码表示第五个按钮的信息保存在TB_Data中。
然后,如果此代码成功,SendMessage返回1.
But it doesn't work.
As I know, below code means that information of fifth button save in TB_Data.
And then, If this code success, SendMessage return 1.
i = SendMessage(..,TB_GETBUTTON, 5, &TB_Data);
i value is 1.
但是在TB_Data中似乎没有正确的数据保存。
当然SendMessage(..,TB_PRESSBUTTON,..)不起作用。
请告诉我这段代码。
我尝试过的事情:
我想使用Win32 API在工具栏中发送按钮点击消息。
i value is 1.
But It doesn't seem right data save in TB_Data.
Of course SendMessage(..,TB_PRESSBUTTON, ..) doesn't work.
Please advise me about this code.
What I have tried:
I want to send button click message in Toolbar using Win32 API.
推荐答案
亲爱的KarstenK
我无法使用我的电脑回复你的评论。
所以,我回复使用这个。
我使用Spy ++程序确认工具栏的句柄。
此外,它与Parent_hWnd具有相同的值。
Dear KarstenK
I can't reply your comment using my computer.
So, I reply using this.
I confirm the handle of the toolbar using Spy++ program.
Also, it has same value with Parent_hWnd.
这篇关于在工具栏中发送按钮单击消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!