Link to home
Start Free TrialLog in
Avatar of etay
etay

asked on

send message to button of a window

i need to activate a checkbox on a window which runs in windows system
i manage to get the windows hwnd.
i know the checkbox name
how can i find with the parent window handle & caption & the checkbox name the checkbox handle & send a message to check that checkbox?

for code i will add points
Avatar of IainHere
IainHere

Sounds like you're up to no good. Use GetParent to get the parents handle, the use GetWindowText to get the caption.  You already have the name of the checkbox?  If you mean the class name, you can use FindWindowEx using the other information you have to get the checkbox handle.

Then, with the handle of the checkbox, you can use SendMessage.  Sorry I don't have more info or code, but this should help you along a bit, and all the functions are fully documented in MSDN.

Have fun.
Avatar of etay

ASKER

i've tried that it doesnt work
i need to click the mute all checkbox in the volume control of the windows
Avatar of Axter
Check out the following link:
http://www.axter.com/faq/topic.asp?TOPIC_ID=35&FORUM_ID=4&CAT_ID=9&Topic_Title=Controlling+Another+Program&Forum_Title=C%2FC%2B%2B

It has a wrapper class that does what IainHere stated above.
My word! You went to all that trouble for 50 points!  Very impressive - I think I'll give up :)
std::vector<WindowPath> windowpath1;
windowpath1.push_back(WindowPath("Volume Control","",0));
windowpath1.push_back(WindowPath("","&Mute all",0));
Ext_Wnd VolumeControl(windowpath1);
IainHere,
Didn't you see the date on the link.  That's an old class I created a couple months ago for another project.

etay,
On my previous comment, I posted example code for getting the window handle for the Mute-All checkbox on the Volume Control.

If I had time, I would show you how to send the check message.
If IainHere or none of the other experts haveing givin you the additional information by the time I get back, then I'll posted it for you.

It should be something like the following:
VolumeControl.SendMessage(???,???,???);
If you have a handle on the checkbox, use:

<from msdn under BM_SETCHECK>

SendMessage(
  (HWND) hWnd,              // handle to destination window
  BM_SETCHECK,              // message to send
  (WPARAM) wParam,          // check state
  (LPARAM) lParam          // not used; must be zero
);

in order to set it, you'd use

SendMessage(hwndMuteAll, BM_SETCHECK, BST_CHECKED, 0);

Hope this helps.  Also, "i've tried that it doesnt work" - which bit doesn't work?
Axter:  I was trying to suggest that you'd created the website specifically to answer this question.  Sorry I didn't make it more clear.  Or funny.
Axter,

>>Didn't you see the date on the link.  That's an old
>>class I created a couple months ago for another
>>project.

Don't give me that!  Give yourself full credit.  You ANTICIPATED that this question would come up and proactively created this example so you'd be ready...

Right??
jhance,
>>Don't give me that!  Give yourself full credit.  You
>>ANTICIPATED that this question would come up and
>>proactively created this example so you'd be ready...
>>Right??
Ok, I must confess.  I did create the class for a personel project, but I posted it on the web because I see this question asked so many times in EE.
Thought it be easier to answer with wrapper class.

Though I need to add some more examples to it.
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial