]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/main.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: WinMain/DllMain
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/cmdline.h"
35 #include "wx/msw/private.h"
37 // Don't implement WinMain if we're building an MFC/wxWidgets hybrid app.
38 #if wxUSE_MFC && !defined(NOMAIN)
43 // BC++ has to be special: its run-time expects the DLL entry point to be
44 // named DllEntryPoint instead of the (more) standard DllMain
45 #define DllMain DllEntryPoint
48 #if defined(__WXMICROWIN__)
49 #define HINSTANCE HANDLE
54 // ============================================================================
55 // implementation: various entry points
56 // ============================================================================
58 // ----------------------------------------------------------------------------
59 // Windows-specific wxEntry
60 // ----------------------------------------------------------------------------
62 WXDLLEXPORT
int wxEntry(HINSTANCE hInstance
,
63 HINSTANCE
WXUNUSED(hPrevInstance
),
64 wxCmdLineArgType
WXUNUSED(pCmdLine
),
67 // remember the parameters Windows gave us
68 wxSetInstance(hInstance
);
69 wxApp::m_nCmdShow
= nCmdShow
;
71 // parse the command line: we can't use pCmdLine in Unicode build so it is
72 // simpler to never use it at all (this also results in a more correct
75 // break the command line in words
77 const wxChar
*cmdLine
= ::GetCommandLine();
80 args
= wxCmdLineParser::ConvertStringToArgs(cmdLine
);
83 int argc
= args
.GetCount();
85 // +1 here for the terminating NULL
86 wxChar
**argv
= new wxChar
*[argc
+ 1];
87 for ( int i
= 0; i
< argc
; i
++ )
89 argv
[i
] = wxStrdup(args
[i
]);
92 // argv[] must be NULL-terminated
95 return wxEntry(argc
, argv
);
98 // May wish not to have a DllMain or WinMain, e.g. if we're programming
99 // a Netscape plugin or if we're writing a console application
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 // Note that WinMain is also defined in dummy.obj, which is linked to
110 // an application that is using the DLL version of wxWidgets.
117 DllMain(HANDLE hModule
, DWORD fdwReason
, LPVOID
WXUNUSED(lpReserved
))
119 // Only call wxEntry if the application itself is part of the DLL.
120 // If only the wxWidgets library is in the DLL, then the
121 // initialisation will be called when the application implicitly
126 case DLL_PROCESS_ATTACH
:
127 return wxEntry(hModule
);
129 case DLL_PROCESS_DETACH
:
136 #endif // !WXMAKINGDLL
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
155 HINSTANCE wxhInstance
= 0;
157 HINSTANCE
wxGetInstance()
162 void wxSetInstance(HINSTANCE hInst
)