1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
18 class WXDLLIMPEXP_FWD_CORE wxFrame
;
19 class WXDLLIMPEXP_FWD_CORE wxWindow
;
20 class WXDLLIMPEXP_FWD_CORE wxApp
;
21 class WXDLLIMPEXP_FWD_CORE wxKeyEvent
;
22 class WXDLLIMPEXP_FWD_BASE wxLog
;
24 // Represents the application. Derive OnInit and declare
25 // a new App object to start application
26 class WXDLLEXPORT wxApp
: public wxAppBase
28 DECLARE_DYNAMIC_CLASS(wxApp
)
34 // override base class (pure) virtuals
35 virtual bool Initialize(int& argc
, wxChar
**argv
);
36 virtual void CleanUp();
38 virtual bool Yield(bool onlyIfNeeded
= false);
39 virtual void WakeUpIdle();
41 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
42 virtual int GetPrintMode() const { return m_printMode
; }
44 // implementation only
45 void OnIdle(wxIdleEvent
& event
);
46 void OnEndSession(wxCloseEvent
& event
);
47 void OnQueryEndSession(wxCloseEvent
& event
);
50 virtual bool OnExceptionInMainLoop();
51 #endif // wxUSE_EXCEPTIONS
54 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
58 static bool RegisterWindowClasses();
59 static bool UnregisterWindowClasses();
62 // initialize the richedit DLL of (at least) given version, return true if
63 // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3)
64 static bool InitRichEdit(int version
= 2);
65 #endif // wxUSE_RICHEDIT
67 // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
68 // wasn't found at all
69 static int GetComCtl32Version();
71 // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not
72 // currently detected)
73 static int GetShell32Version();
75 // the SW_XXX value to be used for the frames opened by the application
76 // (currently seems unused which is a bug -- TODO)
77 static int m_nCmdShow
;
81 DECLARE_NO_COPY_CLASS(wxApp
)
86 // under CE provide a dummy implementation of GetComCtl32Version() returning
87 // the value passing all ">= 470" tests (which are the only ones used in our
88 // code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll
90 inline int wxApp::GetComCtl32Version()
95 // this is not currently used at all under CE so it's not really clear what do
96 // we need to return from here
97 inline int wxApp::GetShell32Version()
102 #endif // __WXWINCE__
104 // ----------------------------------------------------------------------------
105 // MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition
106 // ----------------------------------------------------------------------------
108 // we need HINSTANCE declaration to define WinMain()
109 #include "wx/msw/wrapwin.h"
111 #ifndef SW_SHOWNORMAL
112 #define SW_SHOWNORMAL 1
115 // WinMain() is always ANSI, even in Unicode build, under normal Windows
116 // but is always Unicode under CE
118 typedef wchar_t *wxCmdLineArgType
;
120 typedef char *wxCmdLineArgType
;
123 // wxMSW-only overloads of wxEntry() and wxEntryStart() which take the
124 // parameters passed to WinMain() instead of those passed to main()
125 extern bool WXDLLEXPORT
126 wxEntryStart(HINSTANCE hInstance
,
127 HINSTANCE hPrevInstance
= NULL
,
128 wxCmdLineArgType pCmdLine
= NULL
,
129 int nCmdShow
= SW_SHOWNORMAL
);
131 extern int WXDLLEXPORT
132 wxEntry(HINSTANCE hInstance
,
133 HINSTANCE hPrevInstance
= NULL
,
134 wxCmdLineArgType pCmdLine
= NULL
,
135 int nCmdShow
= SW_SHOWNORMAL
);
137 #define IMPLEMENT_WXWIN_MAIN \
138 extern "C" int WINAPI WinMain(HINSTANCE hInstance, \
139 HINSTANCE hPrevInstance, \
140 wxCmdLineArgType lpCmdLine, \
143 return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); \