[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

send message to button of a window

Posted on 2001-06-27
11
Medium Priority
?
231 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

649 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