1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Windows-specific wxEntry() overload
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_INIT_H_
13 #define _WX_MSW_INIT_H_
15 // ----------------------------------------------------------------------------
16 // Windows-specific wxEntry() overload and wxIMPLEMENT_WXWIN_MAIN definition
17 // ----------------------------------------------------------------------------
19 // we need HINSTANCE declaration to define WinMain()
20 #include "wx/msw/wrapwin.h"
23 #define SW_SHOWNORMAL 1
26 // WinMain() is always ANSI, even in Unicode build, under normal Windows
27 // but is always Unicode under CE
29 typedef wchar_t *wxCmdLineArgType
;
31 typedef char *wxCmdLineArgType
;
34 // Windows-only overloads of wxEntry() and wxEntryStart() which take the
35 // parameters passed to WinMain() instead of those passed to main()
36 extern WXDLLIMPEXP_CORE
bool
37 wxEntryStart(HINSTANCE hInstance
,
38 HINSTANCE hPrevInstance
= NULL
,
39 wxCmdLineArgType pCmdLine
= NULL
,
40 int nCmdShow
= SW_SHOWNORMAL
);
42 extern WXDLLIMPEXP_CORE
int
43 wxEntry(HINSTANCE hInstance
,
44 HINSTANCE hPrevInstance
= NULL
,
45 wxCmdLineArgType pCmdLine
= NULL
,
46 int nCmdShow
= SW_SHOWNORMAL
);
48 #if defined(__BORLANDC__) && wxUSE_UNICODE
49 // Borland C++ has the following nonstandard behaviour: when the -WU
50 // command line flag is used, the linker expects to find wWinMain instead
51 // of WinMain. This flag causes the compiler to define _UNICODE and
52 // UNICODE symbols and there's no way to detect its use, so we have to
53 // define both WinMain and wWinMain so that wxIMPLEMENT_WXWIN_MAIN works
54 // for both code compiled with and without -WU.
55 // See http://sourceforge.net/tracker/?func=detail&atid=309863&aid=1935997&group_id=9863
57 #define wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD \
58 extern "C" int WINAPI wWinMain(HINSTANCE hInstance, \
59 HINSTANCE hPrevInstance, \
60 wchar_t * WXUNUSED(lpCmdLine), \
63 wxDISABLE_DEBUG_SUPPORT(); \
65 /* NB: wxEntry expects lpCmdLine argument to be char*, not */ \
66 /* wchar_t*, but fortunately it's not used anywhere */ \
67 /* and we can simply pass NULL in: */ \
68 return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \
71 #define wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
72 #endif // defined(__BORLANDC__) && wxUSE_UNICODE
74 #define wxIMPLEMENT_WXWIN_MAIN \
75 extern "C" int WINAPI WinMain(HINSTANCE hInstance, \
76 HINSTANCE hPrevInstance, \
77 wxCmdLineArgType WXUNUSED(lpCmdLine), \
80 wxDISABLE_DEBUG_SUPPORT(); \
82 /* NB: We pass NULL in place of lpCmdLine to behave the same as */ \
83 /* Borland-specific wWinMain() above. If it becomes needed */ \
84 /* to pass lpCmdLine to wxEntry() here, you'll have to fix */ \
85 /* wWinMain() above too. */ \
86 return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow); \
88 wxIMPLEMENT_WXWIN_MAIN_BORLAND_NONSTANDARD
91 #endif // _WX_MSW_INIT_H_