How to simulate clicks on toolbar buttons?
-
Hi, I tried both TB_PRESSBUTTON and WM_LBUTTONDOWN, but I failed. Do you have any ideas to solve this problem? Thanks in advance.
-
Hi, I tried both TB_PRESSBUTTON and WM_LBUTTONDOWN, but I failed. Do you have any ideas to solve this problem? Thanks in advance.
do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.
Maximilien Lincourt Your Head A Splode - Strong Bad
I would do a PostMessage myself... ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-
do you need a visual feedback ? Toolbar buttons are COMMANDS, so , you could ( never tried it ) do a SendMessage with the appropriate command ID.
Maximilien Lincourt Your Head A Splode - Strong Bad
Hi, I tried to send the WM_COMMAND to my toolbar, it worked. But it failed when I sent that message to the toolbar of the Open File Dialog (CFileDialog). Here is my code:
hwndToolBar = ::FindWindowEx(hwndParent, NULL, _T("ToolbarWindow32"), NULL); ::SendMessage(hwndToolBar, WM_COMMAND, MAKEWPARAM((WORD)40961, CN_COMMAND), NULL); // 40961 is the ID of the "Up One Level" button.
I didn't know why it failed. Please help me. What I need is programmatically clicking on the "Up One Level" button. Thanks in advance. -- modified at 14:39 Thursday 15th December, 2005 -
Hi, I tried to send the WM_COMMAND to my toolbar, it worked. But it failed when I sent that message to the toolbar of the Open File Dialog (CFileDialog). Here is my code:
hwndToolBar = ::FindWindowEx(hwndParent, NULL, _T("ToolbarWindow32"), NULL); ::SendMessage(hwndToolBar, WM_COMMAND, MAKEWPARAM((WORD)40961, CN_COMMAND), NULL); // 40961 is the ID of the "Up One Level" button.
I didn't know why it failed. Please help me. What I need is programmatically clicking on the "Up One Level" button. Thanks in advance. -- modified at 14:39 Thursday 15th December, 2005Are you sure the FindWindowEx returns an HWND? Perhaps it returns NULL.
-
I would do a PostMessage myself... ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-
Are you sure the FindWindowEx returns an HWND? Perhaps it returns NULL.
It works now. The problem is that when I send the message. It wouldn't work in WM_INITDIALOG and WM_NOTIFY (code CDN_INITDONE). It worked well in WM_NOTIFY (code CDN_SELCHANGE and probably others but I've not tested yet!) Thanks for helping.
-
It works now. The problem is that when I send the message. It wouldn't work in WM_INITDIALOG and WM_NOTIFY (code CDN_INITDONE). It worked well in WM_NOTIFY (code CDN_SELCHANGE and probably others but I've not tested yet!) Thanks for helping.
That's cool, but to be safe, you should always check if FindWindow(Ex) succeeds before using the HWND.