Solved

send message to button of a window

Posted on 2001-06-27
11
226 Views
Last Modified: 2010-04-02
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
0
Comment
Question by:etay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 4

Expert Comment

by:IainHere
ID: 6231722
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.
0
 

Author Comment

by:etay
ID: 6231869
i've tried that it doesnt work
i need to click the mute all checkbox in the volume control of the windows
0
 
LVL 30

Expert Comment

by:Axter
ID: 6231870
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:IainHere
ID: 6231954
My word! You went to all that trouble for 50 points!  Very impressive - I think I'll give up :)
0
 
LVL 30

Expert Comment

by:Axter
ID: 6231982
std::vector<WindowPath> windowpath1;
windowpath1.push_back(WindowPath("Volume Control","",0));
windowpath1.push_back(WindowPath("","&Mute all",0));
Ext_Wnd VolumeControl(windowpath1);
0
 
LVL 30

Expert Comment

by:Axter
ID: 6232018
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(???,???,???);
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6232157
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?
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6232176
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.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6232241
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??
0
 
LVL 30

Expert Comment

by:Axter
ID: 6232338
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.
0
 
LVL 30

Accepted Solution

by:
Axter earned 50 total points
ID: 6232352
Adding to what IainHere said above on the SendMessage() function, you can do the following with the wrapper class:

std::vector<WindowPath> windowpath1;
windowpath1.push_back(WindowPath("Volume Control","",0));
windowpath1.push_back(WindowPath("","&Mute all",0));
Ext_Wnd VolumeControl(windowpath1);
VolumeControl.SendMessage(
  BM_SETCHECK,              // message to send
 (WPARAM) wParam,          // check state
 (LPARAM) NULL          // not used; must be zero
);

For the Ext_Wnd class you don't need to use the "hWnd" variable because it stores it, and calls the global SendMessage() function with the stored m_hWnd variable.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question