Click here to Skip to main content
15,889,865 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to send button click message in Toolbar using Win32 API.
So, I made code like below.

C++
//////////////////////////////////////////////////////////////////////////////

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);

//////////////////////////////////////////////////////////////////////////////

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.
C++
i = SendMessage(..,TB_GETBUTTON, 5, &TB_Data);

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.
Posted
Updated 17-Feb-16 20:34pm
v3
Comments
KarstenK 16-Feb-16 6:54am    
Is Parent_hWnd really the handle of the toolbar? Plz use the value from the creation.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900