0

Visual Studio 2008 C++ Windows Xp SP3

I have created a wxWidgets form (using wxFormBuilder) and have buttons/menus/toolbars all generating events to call various methods (all this works perfectly). Each of these event methods is defined like this:

void cLoggingFrame::me_InsertCommentText(wxCommandEvent& event);

Now, what I want to be able to do is 're-use' some of these methods by calling them directly. I don't want to generate an event to be handled, I want the method to run when I call it. For example, I want to do something like this (this doesn't work)

me_InsertCommentText(NULL);

Now, I understand that I could have each event method just call another method (without parameters) that could be called from other locations, but in other languages I've been able to bypass the parameter requirement with NULL.

Is there any way to do this with wxWidgets without the need for an additional method?

4

2 回答 2

0

传递给事件处理程序的方法只是普通的 c++ 方法,你必须传递正确的参数,这样就可以了

me_InsertCommentText(wxCommandEvent());
于 2013-08-28T07:11:11.290 回答
0

只需使用 wxwidgets 已经创建的事件变量。命令行应该是这样的:

me_InsertCommentText(event);

于 2016-08-02T17:07:54.987 回答