]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/app.h
Return old, not new, selection from wxMSW wxNotebook::ChangeSelection().
[wxWidgets.git] / include / wx / msw / app.h
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.h
3// Purpose: wxApp class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_APP_H_
13#define _WX_APP_H_
2bda0e17 14
a3ef5bf5 15#include "wx/event.h"
ebea0891 16#include "wx/icon.h"
2bda0e17 17
b5dbe15d
VS
18class WXDLLIMPEXP_FWD_CORE wxFrame;
19class WXDLLIMPEXP_FWD_CORE wxWindow;
20class WXDLLIMPEXP_FWD_CORE wxApp;
21class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
22class WXDLLIMPEXP_FWD_BASE wxLog;
2bda0e17 23
2bda0e17
KB
24// Represents the application. Derive OnInit and declare
25// a new App object to start application
53a2db12 26class WXDLLIMPEXP_CORE wxApp : public wxAppBase
2bda0e17 27{
094637f6
VZ
28public:
29 wxApp();
30 virtual ~wxApp();
580c10e3 31
094637f6 32 // override base class (pure) virtuals
05e2b077 33 virtual bool Initialize(int& argc, wxChar **argv);
94826170
VZ
34 virtual void CleanUp();
35
e2478fde 36 virtual void WakeUpIdle();
2bda0e17 37
094637f6
VZ
38 virtual void SetPrintMode(int mode) { m_printMode = mode; }
39 virtual int GetPrintMode() const { return m_printMode; }
2bda0e17 40
094637f6
VZ
41 // implementation only
42 void OnIdle(wxIdleEvent& event);
43 void OnEndSession(wxCloseEvent& event);
44 void OnQueryEndSession(wxCloseEvent& event);
2bda0e17 45
6046e57a
VZ
46#if wxUSE_EXCEPTIONS
47 virtual bool OnExceptionInMainLoop();
48#endif // wxUSE_EXCEPTIONS
49
d9698bd4
VZ
50 // MSW-specific from now on
51 // ------------------------
52
53 // this suffix should be appended to all our Win32 class names to obtain a
54 // variant registered without CS_[HV]REDRAW styles
9a83f860 55 static const wxChar *GetNoRedrawClassSuffix() { return wxT("NR"); }
d9698bd4
VZ
56
57 // get the name of the registered Win32 class with the given (unique) base
58 // name: this function constructs the unique class name using this name as
59 // prefix, checks if the class is already registered and registers it if it
60 // isn't and returns the name it was registered under (or NULL if it failed)
61 //
62 // the registered class will always have CS_[HV]REDRAW and CS_DBLCLKS
63 // styles as well as any additional styles specified as arguments here; and
64 // there will be also a companion registered class identical to this one
65 // but without CS_[HV]REDRAW whose name will be the same one but with
66 // GetNoRedrawClassSuffix()
67 //
68 // the background brush argument must be either a COLOR_XXX standard value
69 // or (default) -1 meaning that the class paints its background itself
70 static const wxChar *GetRegisteredClassName(const wxChar *name,
71 int bgBrushCol = -1,
72 int extraStyles = 0);
73
74 // return true if this name corresponds to one of the classes we registered
75 // in the previous GetRegisteredClassName() calls
76 static bool IsRegisteredClassName(const wxString& name);
77
2bda0e17 78protected:
1e6feb95 79 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
094637f6 80
2bda0e17 81public:
d9698bd4
VZ
82 // unregister any window classes registered by GetRegisteredClassName()
83 static void UnregisterWindowClasses();
ed45e263 84
6d167489 85#if wxUSE_RICHEDIT
77c46f00 86 // initialize the richedit DLL of (at least) given version, return true if
6d167489
VZ
87 // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3)
88 static bool InitRichEdit(int version = 2);
89#endif // wxUSE_RICHEDIT
90
91 // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
92 // wasn't found at all
93 static int GetComCtl32Version();
2bda0e17 94
5e9b921d
VZ
95 // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not
96 // currently detected)
97 static int GetShell32Version();
98
94826170
VZ
99 // the SW_XXX value to be used for the frames opened by the application
100 // (currently seems unused which is a bug -- TODO)
101 static int m_nCmdShow;
2bda0e17
KB
102
103protected:
094637f6 104 DECLARE_EVENT_TABLE()
c0c133e1 105 wxDECLARE_NO_COPY_CLASS(wxApp);
d9698bd4 106 DECLARE_DYNAMIC_CLASS(wxApp)
2bda0e17
KB
107};
108
6b4296f7
VZ
109#ifdef __WXWINCE__
110
111// under CE provide a dummy implementation of GetComCtl32Version() returning
112// the value passing all ">= 470" tests (which are the only ones used in our
113// code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll
114// functionality
115inline int wxApp::GetComCtl32Version()
116{
117 return 471;
118}
119
120// this is not currently used at all under CE so it's not really clear what do
121// we need to return from here
122inline int wxApp::GetShell32Version()
123{
124 return 0;
125}
126
127#endif // __WXWINCE__
128
956495ca
VZ
129// ----------------------------------------------------------------------------
130// MSW-specific wxEntry() overload and IMPLEMENT_WXWIN_MAIN definition
131// ----------------------------------------------------------------------------
132
133// we need HINSTANCE declaration to define WinMain()
134#include "wx/msw/wrapwin.h"
135
136#ifndef SW_SHOWNORMAL
137 #define SW_SHOWNORMAL 1
138#endif
139
140// WinMain() is always ANSI, even in Unicode build, under normal Windows
141// but is always Unicode under CE
142#ifdef __WXWINCE__
143 typedef wchar_t *wxCmdLineArgType;
144#else
145 typedef char *wxCmdLineArgType;
146#endif
147
d76a558d
VZ
148// wxMSW-only overloads of wxEntry() and wxEntryStart() which take the
149// parameters passed to WinMain() instead of those passed to main()
53a2db12
FM
150extern WXDLLIMPEXP_CORE bool
151 wxEntryStart(HINSTANCE hInstance,
152 HINSTANCE hPrevInstance = NULL,
153 wxCmdLineArgType pCmdLine = NULL,
154 int nCmdShow = SW_SHOWNORMAL);
155
156extern WXDLLIMPEXP_CORE int
157 wxEntry(HINSTANCE hInstance,
158 HINSTANCE hPrevInstance = NULL,
159 wxCmdLineArgType pCmdLine = NULL,
160 int nCmdShow = SW_SHOWNORMAL);
956495ca 161
1b1c490c
VS
162#if defined(__BORLANDC__) && wxUSE_UNICODE
163 // Borland C++ has the following nonstandard behaviour: when the -WU
164 // command line flag is used, the linker expects to find wWinMain instead
165 // of WinMain. This flag causes the compiler to define _UNICODE and
166 // UNICODE symbols and there's no way to detect its use, so we have to
167 // define both WinMain and wWinMain so that IMPLEMENT_WXWIN_MAIN works
168 // for both code compiled with and without -WU.
169 // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863
170 // for more details.
171 #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \
172 extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \
173 HINSTANCE hPrevInstance, \
174 wchar_t * WXUNUSED(lpCmdLine), \
175 int nCmdShow) \
176 { \
7d9550df
VZ
177 wxDISABLE_DEBUG_SUPPORT(); \
178 \
1b1c490c
VS
179 /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \
180 /* wchar_t*, but fortunately it's not used anywhere */ \
181 /* and we can simply pass NULL in: */ \
182 return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \
183 }
184#else
185 #define IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
186#endif // defined(__BORLANDC__) && wxUSE_UNICODE
187
956495ca 188#define IMPLEMENT_WXWIN_MAIN \
1b1c490c
VS
189 extern "C" int WINAPI WinMain(HINSTANCE hInstance, \
190 HINSTANCE hPrevInstance, \
191 wxCmdLineArgType WXUNUSED(lpCmdLine), \
192 int nCmdShow) \
193 { \
7d9550df
VZ
194 wxDISABLE_DEBUG_SUPPORT(); \
195 \
1b1c490c
VS
196 /* NB: We pass NULL in place of lpCmdLine to behave the same as */ \
197 /* Borland-specific wWinMain() above. If it becomes needed */ \
198 /* to pass lpCmdLine to wxEntry() here, you'll have to fix */ \
199 /* wWinMain() above too. */ \
200 return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \
201 } \
202 IMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
203
2bda0e17 204
94826170 205#endif // _WX_APP_H_
2bda0e17 206