?
Solved

send message to button of a window

Posted on 2001-06-27
11
Medium Priority
?
228 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
Independent Software Vendors: 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 150 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

765 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