]>
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"
38 // BC++ has to be special: its run-time expects the DLL entry point to be
39 // named DllEntryPoint instead of the (more) standard DllMain
40 #define DllMain DllEntryPoint
43 #if defined(__WXMICROWIN__)
44 #define HINSTANCE HANDLE
49 // ============================================================================
50 // implementation: various entry points
51 // ============================================================================
53 // ----------------------------------------------------------------------------
54 // Windows-specific wxEntry
55 // ----------------------------------------------------------------------------
57 WXDLLEXPORT
int wxEntry(HINSTANCE hInstance
,
58 HINSTANCE
WXUNUSED(hPrevInstance
),
59 wxCmdLineArgType
WXUNUSED(pCmdLine
),
62 // remember the parameters Windows gave us
63 wxSetInstance(hInstance
);
64 wxApp::m_nCmdShow
= nCmdShow
;
66 // parse the command line: we can't use pCmdLine in Unicode build so it is
67 // simpler to never use it at all (this also results in a more correct
70 // break the command line in words
72 const wxChar
*cmdLine
= ::GetCommandLine();
75 args
= wxCmdLineParser::ConvertStringToArgs(cmdLine
);
78 int argc
= args
.GetCount();
80 // +1 here for the terminating NULL
81 wxChar
**argv
= new wxChar
*[argc
+ 1];
82 for ( int i
= 0; i
< argc
; i
++ )
84 argv
[i
] = wxStrdup(args
[i
]);
87 // argv[] must be NULL-terminated
90 return wxEntry(argc
, argv
);
93 // May wish not to have a DllMain or WinMain, e.g. if we're programming
94 // a Netscape plugin or if we're writing a console application
100 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
104 // Note that WinMain is also defined in dummy.obj, which is linked to
105 // an application that is using the DLL version of wxWidgets.
112 DllMain(HANDLE hModule
, DWORD fdwReason
, LPVOID
WXUNUSED(lpReserved
))
114 // Only call wxEntry if the application itself is part of the DLL.
115 // If only the wxWidgets library is in the DLL, then the
116 // initialisation will be called when the application implicitly
121 case DLL_PROCESS_ATTACH
:
122 return wxEntry(hModule
);
124 case DLL_PROCESS_DETACH
:
131 #endif // !WXMAKINGDLL
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
150 HINSTANCE wxhInstance
= 0;
152 HINSTANCE
wxGetInstance()
157 void wxSetInstance(HINSTANCE hInst
)