init.h 4.3 KB

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