Solved

Simulating Button Click

Posted on 1998-12-30
2
650 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
2 Comments
 

Accepted Solution

by:
gatkinso earned 30 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now