1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
|
<HTML>
<head><title>wxApp</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxapp"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx25.htm#wxactivateevent"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx27.htm#wxarray"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxApp</H2>
<P>
The <B>wxApp</B> class represents the application itself. It is used
to:<P>
<UL>
<LI> set and get application-wide properties;
<LI> implement the windowing system message or event loop;
<LI> initiate application processing via <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A>;
<LI> allow default processing of events not handled by other
objects in the application.
</UL>
<P>
You should use the macro IMPLEMENT_APP(appClass) in your application implementation
file to tell wxWindows how to create an instance of your application class.<P>
Use DECLARE_APP(appClass) in a header file if you want the wxGetApp function (which returns
a reference to your application object) to be visible to other files.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx85.htm#wxevthandler">wxEvtHandler</A><BR>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/app.h><P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx279.htm#wxappoverview">wxApp overview</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic38">wxApp::wxApp</A><BR>
<A HREF="#topic39">wxApp::~wxApp</A><BR>
<A HREF="#wxappargc">wxApp::argc</A><BR>
<A HREF="#wxappargv">wxApp::argv</A><BR>
<A HREF="#wxappcreatelogtarget">wxApp::CreateLogTarget</A><BR>
<A HREF="#wxappdispatch">wxApp::Dispatch</A><BR>
<A HREF="#wxappgetappname">wxApp::GetAppName</A><BR>
<A HREF="#wxappgetauto3d">wxApp::GetAuto3D</A><BR>
<A HREF="#wxappgetclassname">wxApp::GetClassName</A><BR>
<A HREF="#wxappgetexitondelete">wxApp::GetExitOnDelete</A><BR>
<A HREF="#wxappgettopwindow">wxApp::GetTopWindow</A><BR>
<A HREF="#wxappexitmainloop">wxApp::ExitMainLoop</A><BR>
<A HREF="#wxappinitialized">wxApp::Initialized</A><BR>
<A HREF="#wxappmainloop">wxApp::MainLoop</A><BR>
<A HREF="#wxapponactivate">wxApp::OnActivate</A><BR>
<A HREF="#wxapponexit">wxApp::OnExit</A><BR>
<A HREF="#wxapponcharhook">wxApp::OnCharHook</A><BR>
<A HREF="#wxapponidle">wxApp::OnIdle</A><BR>
<A HREF="#wxapponendsession">wxApp::OnEndSession</A><BR>
<A HREF="#wxapponinit">wxApp::OnInit</A><BR>
<A HREF="#wxapponqueryendsession">wxApp::OnQueryEndSession</A><BR>
<A HREF="#wxappprocessmessage">wxApp::ProcessMessage</A><BR>
<A HREF="#wxapppending">wxApp::Pending</A><BR>
<A HREF="#wxappsendidleevents">wxApp::SendIdleEvents</A><BR>
<A HREF="#wxappsetappname">wxApp::SetAppName</A><BR>
<A HREF="#wxappsetauto3d">wxApp::SetAuto3D</A><BR>
<A HREF="#wxappsetclassname">wxApp::SetClassName</A><BR>
<A HREF="#wxappsetexitondelete">wxApp::SetExitOnDelete</A><BR>
<A HREF="#wxappsettopwindow">wxApp::SetTopWindow</A><BR>
<P>
<HR>
<A NAME="topic38"></A>
<H3>wxApp::wxApp</H3>
<P>
<B>void</B> <B>wxApp</B>()<P>
Constructor. Called implicitly with a definition of a wxApp object.<P>
The argument is a language identifier; this is an experimental
feature and will be expanded and documented in future versions.<P>
<HR>
<A NAME="topic39"></A>
<H3>wxApp::~wxApp</H3>
<P>
<B>void</B> <B>~wxApp</B>()<P>
Destructor. Will be called implicitly on program exit if the wxApp
object is created on the stack.<P>
<HR>
<A NAME="wxappargc"></A>
<H3>wxApp::argc</H3>
<P>
int argc<P>
Number of command line arguments (after environment-specific processing).<P>
<HR>
<A NAME="wxappargv"></A>
<H3>wxApp::argv</H3>
<P>
char ** argv<P>
Command line arguments (after environment-specific processing).<P>
<HR>
<A NAME="wxappcreatelogtarget"></A>
<H3>wxApp::CreateLogTarget</H3>
<P>
<B>virtual wxLog*</B> <B>CreateLogTarget</B>()<P>
Creates a wxLog class for the application to use for logging errors. The default
implementation returns a new wxLogGui class.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx132.htm#wxlog">wxLog</A><P>
<HR>
<A NAME="wxappdispatch"></A>
<H3>wxApp::Dispatch</H3>
<P>
<B>void</B> <B>Dispatch</B>()<P>
Dispatches the next event in the windowing system event queue.<P>
This can be used for programming event loops, e.g.<P>
<PRE>
while (app.Pending())
Dispatch();
</PRE>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxapppending">wxApp::Pending</A><P>
<HR>
<A NAME="wxappgetappname"></A>
<H3>wxApp::GetAppName</H3>
<P>
<B>wxString</B> <B>GetAppName</B>() <B>const</B><P>
Returns the application name.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
wxWindows sets this to a reasonable default before
calling <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A>, but the application can reset it at will.<P>
<HR>
<A NAME="wxappgetauto3d"></A>
<H3>wxApp::GetAuto3D</H3>
<P>
<B>bool</B> <B>GetAuto3D</B>() <B>const</B><P>
Returns TRUE if 3D control mode is on, FALSE otherwise.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappsetauto3d">wxApp::SetAuto3D</A><P>
<HR>
<A NAME="wxappgetclassname"></A>
<H3>wxApp::GetClassName</H3>
<P>
<B>wxString</B> <B>GetClassName</B>() <B>const</B><P>
Gets the class name of the application. The class name may be used in a platform specific
manner to refer to the application.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappsetclassname">wxApp::SetClassName</A><P>
<HR>
<A NAME="wxappgetexitondelete"></A>
<H3>wxApp::GetExitOnDelete</H3>
<P>
<B>bool</B> <B>GetExitOnDelete</B>() <B>const</B><P>
Returns TRUE if the application will exit when the top-level window is deleted, FALSE
otherwise.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappsetexitondelete">wxApp::SetExitOnDelete</A><P>
<HR>
<A NAME="wxappgettopwindow"></A>
<H3>wxApp::GetTopWindow</H3>
<P>
<B>wxWindow *</B> <B>GetTopWindow</B>() <B>const</B><P>
Returns a pointer to the top window.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
If the top window hasn't been set using <A HREF="wx26.htm#wxappsettopwindow">wxApp::SetTopWindow</A>, this
function will find the first top-level window (frame or dialog) and return that.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappsettopwindow">wxApp::SetTopWindow</A><P>
<HR>
<A NAME="wxappexitmainloop"></A>
<H3>wxApp::ExitMainLoop</H3>
<P>
<B>void</B> <B>ExitMainLoop</B>()<P>
Call this to explicitly exit the main message (event) loop.
You should normally exit the main loop (and the application) by deleting
the top window.<P>
<HR>
<A NAME="wxappinitialized"></A>
<H3>wxApp::Initialized</H3>
<P>
<B>bool</B> <B>Initialized</B>()<P>
Returns TRUE if the application has been initialized (i.e. if
<A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A> has returned successfully). This can be useful for error
message routines to determine which method of output is best for the
current state of the program (some windowing systems may not like
dialogs to pop up before the main loop has been entered).<P>
<HR>
<A NAME="wxappmainloop"></A>
<H3>wxApp::MainLoop</H3>
<P>
<B>int</B> <B>MainLoop</B>()<P>
Called by wxWindows on creation of the application. Override this if you wish
to provide your own (environment-dependent) main loop.<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns 0 under X, and the wParam of the WM_QUIT message under Windows.<P>
<HR>
<A NAME="wxapponactivate"></A>
<H3>wxApp::OnActivate</H3>
<P>
<B>void</B> <B>OnActivate</B>(<B>wxActivateEvent& </B><I>event</I>)<P>
Provide this member function to know whether the application is being
activated or deactivated (Windows only).<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx260.htm#wxwindowonactivate">wxWindow::OnActivate</A>, <A HREF="wx25.htm#wxactivateevent">wxActivateEvent</A><P>
<HR>
<A NAME="wxapponexit"></A>
<H3>wxApp::OnExit</H3>
<P>
<B>int</B> <B>OnExit</B>()<P>
Provide this member function for any processing which needs to be done as
the application is about to exit.<P>
<HR>
<A NAME="wxapponcharhook"></A>
<H3>wxApp::OnCharHook</H3>
<P>
<B>void</B> <B>OnCharHook</B>(<B>wxKeyEvent&</B><I> event</I>)<P>
This event handler function is called (under Windows only) to allow the window to intercept keyboard events
before they are processed by child windows.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>event</I><UL><UL>
The keypress event.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
Use the wxEVT_CHAR_HOOK macro in your event table.<P>
If you use this member, you can selectively consume keypress events by calling
<A HREF="wx84.htm#wxeventskip">wxEvent::Skip</A> for characters the application is not interested in.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx124.htm#wxkeyevent">wxKeyEvent</A>, <A HREF="wx260.htm#wxwindowonchar">wxWindow::OnChar</A>,
<A HREF="wx260.htm#wxwindowoncharhook">wxWindow::OnCharHook</A>, <A HREF="wx71.htm#wxdialogoncharhook">wxDialog::OnCharHook</A><P>
<HR>
<A NAME="wxapponidle"></A>
<H3>wxApp::OnIdle</H3>
<P>
<B>void</B> <B>OnIdle</B>(<B>wxIdleEvent& </B><I>event</I>)<P>
Override this member function for any processing which needs to be done
when the application is idle. You should call wxApp::OnIdle from your own function,
since this forwards OnIdle events to windows and also performs garbage collection for
windows whose destruction has been delayed.<P>
wxWindows' strategy for OnIdle processing is as follows. After pending user interface events for an
application have all been processed, wxWindows sends an OnIdle event to the application object. wxApp::OnIdle itself
sends an OnIdle event to each application window, allowing windows to do idle processing such as updating
their appearance. If either wxApp::OnIdle or a window OnIdle function requested more time, by
caling <A HREF="wx113.htm#wxidleeventrequestmore">wxIdleEvent::ReqestMore</A>, wxWindows will send another OnIdle
event to the application object. This will occur in a loop until either a user event is found to be
pending, or OnIdle requests no more time. Then all pending user events are processed until the system
goes idle again, when OnIdle is called, and so on.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx260.htm#wxwindowonidle">wxWindow::OnIdle</A>, <A HREF="wx113.htm#wxidleevent">wxIdleEvent</A>,
<A HREF="wx26.htm#wxappsendidleevents">wxWindow::SendIdleEvents</A><P>
<HR>
<A NAME="wxapponendsession"></A>
<H3>wxApp::OnEndSession</H3>
<P>
<B>void</B> <B>OnEndSession</B>(<B>wxCloseEvent& </B><I>event</I>)<P>
This is an event handler function called when the operating system or GUI session is
about to close down. The application has a chance to silently save information,
and can optionally close itself.<P>
Use the EVT_END_SESSION event table macro to handle query end session events.<P>
The default handler calls <A HREF="wx260.htm#wxwindowclose">wxWindow::Close</A> with a TRUE argument
(forcing the application to close itself silently).<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
Under X, OnEndSession is called in response to the 'die' event.<P>
Under Windows, OnEndSession is called in response to the WM_ENDSESSION message.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx260.htm#wxwindowclose">wxWindow::Close</A>,
<A HREF="wx260.htm#wxwindowonclosewindow">wxWindow::OnCloseWindow</A>,
<A HREF="wx45.htm#wxcloseevent">wxCloseEvent</A>,
<A HREF="wx26.htm#wxapponqueryendsession">wxApp::OnQueryEndSession</A><P>
<HR>
<A NAME="wxapponinit"></A>
<H3>wxApp::OnInit</H3>
<P>
<B>bool</B> <B>OnInit</B>()<P>
This must be provided by the application, and will usually create the
application's main window, optionally calling <A HREF="wx26.htm#wxappsettopwindow">wxApp::SetTopWindow</A>.<P>
Return TRUE to continue processing, FALSE to exit the application.<P>
<HR>
<A NAME="wxapponqueryendsession"></A>
<H3>wxApp::OnQueryEndSession</H3>
<P>
<B>void</B> <B>OnQueryEndSession</B>(<B>wxCloseEvent& </B><I>event</I>)<P>
This is an event handler function called when the operating system or GUI session is
about to close down. Typically, an application will try to save unsaved documents
at this point.<P>
If <A HREF="wx45.htm#wxcloseeventcanveto">wxCloseEvent::CanVeto</A> returns TRUE, the application
is allowed to veto the shutdown by calling <A HREF="wx45.htm#wxcloseeventveto">wxCloseEvent::Veto</A>.
The application might veto the shutdown after prompting for documents to be saved, and the
user has cancelled the save.<P>
Use the EVT_QUERY_END_SESSION event table macro to handle query end session events.<P>
You should check whether the application is forcing the deletion of the window
using <A HREF="wx45.htm#wxcloseeventgetforce">wxCloseEvent::GetForce</A>. If this is TRUE,
destroy the window using <A HREF="wx260.htm#wxwindowdestroy">wxWindow::Destroy</A>.
If not, it is up to you whether you respond by destroying the window.<P>
The default handler calls <A HREF="wx260.htm#wxwindowclose">wxWindow::Close</A> on the top-level window,
and vetoes the shutdown if Close returns FALSE. This will be sufficient for many applications.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
Under X, OnQueryEndSession is called in response to the 'save session' event.<P>
Under Windows, OnQueryEndSession is called in response to the WM_QUERYENDSESSION message.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx260.htm#wxwindowclose">wxWindow::Close</A>,
<A HREF="wx260.htm#wxwindowonclosewindow">wxWindow::OnCloseWindow</A>,
<A HREF="wx45.htm#wxcloseevent">wxCloseEvent</A>,
<A HREF="wx26.htm#wxapponendsession">wxApp::OnEndSession</A><P>
<HR>
<A NAME="wxappprocessmessage"></A>
<H3>wxApp::ProcessMessage</H3>
<P>
<B>bool</B> <B>ProcessMessage</B>(<B>MSG *</B><I>msg</I>)<P>
Windows-only function for processing a message. This function
is called from the main message loop, checking for windows that
may wish to process it. The function returns TRUE if the message
was processed, FALSE otherwise. If you use wxWindows with another class
library with its own message loop, you should make sure that this
function is called to allow wxWindows to receive messages. For example,
to allow co-existance with the Microsoft Foundation Classes, override
the PreTranslateMessage function:<P>
<PRE>
// Provide wxWindows message loop compatibility
BOOL CTheApp::PreTranslateMessage(MSG *msg)
{
if (wxTheApp && wxTheApp->ProcessMessage(msg))
return TRUE;
else
return CWinApp::PreTranslateMessage(msg);
}
</PRE>
<HR>
<A NAME="wxapppending"></A>
<H3>wxApp::Pending</H3>
<P>
<B>bool</B> <B>Pending</B>()<P>
Returns TRUE if unprocessed events are in the window system event queue
(MS Windows and Motif).<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappdispatch">wxApp::Dispatch</A><P>
<HR>
<A NAME="wxappsendidleevents"></A>
<H3>wxApp::SendIdleEvents</H3>
<P>
<B>bool</B> <B>SendIdleEvents</B>()<P>
Sends idle events to all top-level windows.<P>
<B>bool</B> <B>SendIdleEvents</B>(<B>wxWindow*</B><I> win</I>)<P>
Sends idle events to a window and its children.<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
These functions poll the top-level windows, and their children, for idle event processing.
If TRUE is returned, more OnIdle processing is requested by one or more window.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxapponidle">wxApp::OnIdle</A>, <A HREF="wx260.htm#wxwindowonidle">wxWindow::OnIdle</A>, <A HREF="wx113.htm#wxidleevent">wxIdleEvent</A><P>
<HR>
<A NAME="wxappsetappname"></A>
<H3>wxApp::SetAppName</H3>
<P>
<B>void</B> <B>SetAppName</B>(<B>const wxString& </B><I>name</I>)<P>
Sets the name of the application. The name may be used in dialogs
(for example by the document/view framework). A default name is set by
wxWindows.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappgetappname">wxApp::GetAppName</A><P>
<HR>
<A NAME="wxappsetauto3d"></A>
<H3>wxApp::SetAuto3D</H3>
<P>
<B>void</B> <B>SetAuto3D</B>(<B>const bool</B><I> auto3D</I>)<P>
Switches automatic 3D controls on or off.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>auto3D</I><UL><UL>
If TRUE, all controls will be created with 3D appearances unless
overridden for a control or dialog. The default is TRUE</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
This has an effect on Windows only.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappgetauto3d">wxApp::GetAuto3D</A><P>
<HR>
<A NAME="wxappsetclassname"></A>
<H3>wxApp::SetClassName</H3>
<P>
<B>void</B> <B>SetClassName</B>(<B>const wxString& </B><I>name</I>)<P>
Sets the class name of the application. This may be used in a platform specific
manner to refer to the application.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappgetclassname">wxApp::GetClassName</A><P>
<HR>
<A NAME="wxappsetexitondelete"></A>
<H3>wxApp::SetExitOnDelete</H3>
<P>
<B>void</B> <B>SetExitOnDelete</B>(<B>bool</B><I> flag</I>)<P>
Allows the programmer to specify whether the application will exit when the
top-level frame is deleted.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>flag</I><UL><UL>
If TRUE (the default), the application will exit when the top-level frame is
deleted. If FALSE, the application will continue to run.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
Currently, setting this to FALSE only has an effect under Windows.<P>
<HR>
<A NAME="wxappsettopwindow"></A>
<H3>wxApp::SetTopWindow</H3>
<P>
<B>void</B> <B>SetTopWindow</B>(<B>wxWindow* </B><I>window</I>)<P>
Sets the 'top' window. You can call this from within <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A> to
let wxWindows know which is the main window. You don't have to set the top window;
it's only a convenience so that (for example) certain dialogs without parents can use a
specific window as the top window. If no top window is specified by the application,
wxWindows just uses the first frame or dialog in its top-level window list, when it
needs to use the top window.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>window</I><UL><UL>
The new top window.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx26.htm#wxappgettopwindow">wxApp::GetTopWindow</A>, <A HREF="wx26.htm#wxapponinit">wxApp::OnInit</A><P>
</BODY></HTML>
|