wxAppDerivedClass& wxGetApp()
This function doesn't exist in wxWidgets but it is created by using the IMPLEMENT_APP macro. Thus, before using it anywhere but in
the same module where this macro is used, you must make it available using DECLARE_APP.
The advantage of using this function compared to directly using the global wxTheApp pointer is that the latter is of type wxApp *
and so wouldn't allow you to access the functions specific to your application class but not present in wxApp while wxGetApp() returns
the object of the right type.
DECLARE_APP(className)
This is used in headers to create a forward declaration of the wxGetApp function implemented by IMPLEMENT_APP. It creates the declaration
className& wxGetApp(void).
Example:
DECLARE_APP(MyApp)
Include files
<wx/app.h>
IMPLEMENT_APP(className)
This is used in the application class implementation file to make the application class known to wxWidgets for dynamic construction.
You use this instead of
Example:
IMPLEMENT_APP(MyApp)
This function doesn't exist in wxWidgets but it is created by using the IMPLEMENT_APP macro. Thus, before using it anywhere but in
the same module where this macro is used, you must make it available using DECLARE_APP.
The advantage of using this function compared to directly using the global wxTheApp pointer is that the latter is of type wxApp *
and so wouldn't allow you to access the functions specific to your application class but not present in wxApp while wxGetApp() returns
the object of the right type.
DECLARE_APP(className)
This is used in headers to create a forward declaration of the wxGetApp function implemented by IMPLEMENT_APP. It creates the declaration
className& wxGetApp(void).
Example:
DECLARE_APP(MyApp)
Include files
<wx/app.h>
IMPLEMENT_APP(className)
This is used in the application class implementation file to make the application class known to wxWidgets for dynamic construction.
You use this instead of
Example:
IMPLEMENT_APP(MyApp)
本文介绍了wxWidgets中用于创建应用程序类的宏DECLARE_APP和IMPLEMENT_APP的使用方法。通过这两个宏可以实现wxGetApp函数,该函数允许从任何地方获取到当前应用程序对象,而不仅仅是wxApp的指针。
2120

被折叠的 条评论
为什么被折叠?



