Solved

Simulating Button Click

Posted on 1998-12-30
2
660 Views
Last Modified: 2013-11-20
Is there any way to simulate a button click on a button of a dialog box without waiting for user's input from keyboard.
In other words an automatic button push on a particular button of a dialog box. How does one get the information about each button(handles,identifiers etc)
0
Comment
Question by:NatasBoy
[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
2 Comments
 

Accepted Solution

by:
gatkinso earned 30 total points
ID: 1327000
Use the SendDlgItemMessage function.

SendDlgItemMessage(
     int nID,                              //button id
     UINT message,                  //message to send in this case BM_SETSTATE
     WPARAM wParam = 0,      //TRUE for pressed, FALSE for release
     LPARAM lParam = 0 );       //must be zero

You should know the ID of each button, assuming you wrote the dialog.  However you possibly could use the ::EnumChildWindows  API function to gather info about the control in the dialog
0
 

Author Comment

by:NatasBoy
ID: 1327001
Thanks for putting me on the right track!! I just altered the message to BM_CLICK which simulates a button click. I have also assumed the button id to be IDYES which is the most common for the Save prompt dialog box on exiting an application containing unsaved data. But please tell me how to find the button id in a dialog box which matches a particular string such as 'Yes' or 'Ok'. Also, please explain the EnumChildWindows API you suggested to achieve the above purpose.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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