]> git.saurik.com Git - wxWidgets.git/blame - src/msw/main.cpp
do take the toolbar into account for Windows CE, otherwise the menus overlap with...
[wxWidgets.git] / src / msw / main.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
b568d04f 2// Name: msw/main.cpp
e2478fde 3// Purpose: WinMain/DllMain
2bda0e17
KB
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6c9a19aa
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
b568d04f
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
b568d04f 21 #pragma implementation
a3b46648
UU
22#endif
23
2bda0e17
KB
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
b568d04f 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
2432b92d 31#include "wx/event.h"
2bda0e17 32#include "wx/app.h"
94826170 33#include "wx/cmdline.h"
b568d04f
VZ
34
35#include "wx/msw/private.h"
36
e2478fde 37// Don't implement WinMain if we're building an MFC/wxWindows hybrid app.
4cd513ab 38#if wxUSE_MFC && !defined(NOMAIN)
e2478fde 39 #define NOMAIN 1
4cd513ab
JS
40#endif
41
e2478fde
VZ
42#ifdef __BORLANDC__
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
46#endif
47
48#if defined(__WXMICROWIN__)
49 #define HINSTANCE HANDLE
50#endif
beed393c 51
94826170
VZ
52#if wxUSE_GUI
53
b568d04f 54// ============================================================================
e2478fde 55// implementation: various entry points
b568d04f
VZ
56// ============================================================================
57
94826170
VZ
58// ----------------------------------------------------------------------------
59// Windows-specific wxEntry
60// ----------------------------------------------------------------------------
61
b5fe6924
VS
62WXDLLEXPORT int wxEntry(HINSTANCE hInstance,
63 HINSTANCE WXUNUSED(hPrevInstance),
7c8c7cc2 64 wxCmdLineArgType WXUNUSED(pCmdLine),
b5fe6924 65 int nCmdShow)
94826170
VZ
66{
67 // remember the parameters Windows gave us
13bdd545 68 wxSetInstance(hInstance);
94826170
VZ
69 wxApp::m_nCmdShow = nCmdShow;
70
b2b1371c
VZ
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
73 // argv[0])
74
75 // break the command line in words
76 wxArrayString args;
77 const wxChar *cmdLine = ::GetCommandLine();
78 if ( cmdLine )
79 {
80 args = wxCmdLineParser::ConvertStringToArgs(cmdLine);
81 }
82
83 int argc = args.GetCount();
84
85 // +1 here for the terminating NULL
86 wxChar **argv = new wxChar *[argc + 1];
87 for ( int i = 0; i < argc; i++ )
88 {
89 argv[i] = wxStrdup(args[i]);
90 }
91
92 // argv[] must be NULL-terminated
93 argv[argc] = NULL;
94826170
VZ
94
95 return wxEntry(argc, argv);
96}
97
2bda0e17 98// May wish not to have a DllMain or WinMain, e.g. if we're programming
b568d04f 99// a Netscape plugin or if we're writing a console application
94826170 100#if !defined(NOMAIN)
2bda0e17 101
e2478fde
VZ
102extern "C"
103{
2bda0e17 104
e2478fde 105// ----------------------------------------------------------------------------
2bda0e17 106// WinMain
e2478fde
VZ
107// ----------------------------------------------------------------------------
108
2bda0e17
KB
109// Note that WinMain is also defined in dummy.obj, which is linked to
110// an application that is using the DLL version of wxWindows.
111
ac9a3c61 112#if defined(_WINDLL)
2bda0e17
KB
113
114// DLL entry point
115
e2478fde
VZ
116BOOL WINAPI
117DllMain(HANDLE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved))
2bda0e17 118{
e2478fde
VZ
119 // Only call wxEntry if the application itself is part of the DLL.
120 // If only the wxWindows library is in the DLL, then the
121 // initialisation will be called when the application implicitly
122 // calls WinMain.
beed393c 123#ifndef WXMAKINGDLL
2bda0e17 124 switch (fdwReason)
b568d04f
VZ
125 {
126 case DLL_PROCESS_ATTACH:
13bdd545 127 return wxEntry(hModule);
2bda0e17 128
b568d04f 129 case DLL_PROCESS_DETACH:
94826170
VZ
130 wxEntryCleanup();
131 break;
b568d04f 132 }
33ac7e6f
KB
133#else
134 (void)hModule;
135 (void)fdwReason;
beed393c 136#endif // !WXMAKINGDLL
e2478fde 137
b568d04f 138 return TRUE;
2bda0e17
KB
139}
140
ac9a3c61 141#endif // _WINDLL
e2478fde
VZ
142
143} // extern "C"
2bda0e17 144
b568d04f
VZ
145#endif // !NOMAIN
146
94826170
VZ
147#endif // wxUSE_GUI
148
b568d04f 149// ----------------------------------------------------------------------------
e2478fde 150// global HINSTANCE
b568d04f
VZ
151// ----------------------------------------------------------------------------
152
ec67cff1 153#if wxUSE_BASE
e2478fde
VZ
154
155HINSTANCE wxhInstance = 0;
156
b568d04f
VZ
157HINSTANCE wxGetInstance()
158{
159 return wxhInstance;
160}
161
162void wxSetInstance(HINSTANCE hInst)
163{
164 wxhInstance = hInst;
165}
2bda0e17 166
ec67cff1 167#endif // wxUSE_BASE
e2478fde 168