开发者

Simulating Button Click to UI class from console

开发者 https://www.devze.com 2023-03-04 09:33 出处:网络
I\'m working on a project that currently exists as a user-interactive application w/ MFC dialog boxes.I have to extend it so that it can be used as an application that accepts command-line parameters.

I'm working on a project that currently exists as a user-interactive application w/ MFC dialog boxes. I have to extend it so that it can be used as an application that accepts command-line parameters. 开发者_如何学运维To do that, i have to call the method that is mapped to the button click of one of the MFC-based dialog boxes from another class. How can I do that?


Crate a public method in the class containing your button-click-method, and let it call the private button-click-method. You got me? ;-)


Create and expose a public method in your Form class that will call the button click handler.

Header declaration:

public:
    void DoClick();

Definition:

void YourDlg::DoClick()
{
    OnBnClickedOk(); // for example
}

Also remember that the dialog class needs to be instantiated when you call it.

0

精彩评论

暂无评论...
验证码 换一张
取 消