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