]> git.saurik.com Git - wxWidgets.git/blame - src/msw/main.cpp
* Apply patch #735595. Add miminumAcceptable{Height,Width}
[wxWidgets.git] / src / msw / main.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
b568d04f 2// Name: msw/main.cpp
2bda0e17
KB
3// Purpose: Main/DllMain
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
a3b46648 20#ifdef __GNUG__
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"
b568d04f
VZ
33
34#include "wx/msw/private.h"
35
4cd513ab
JS
36// Don't implement WinMain if we're building an MFC/wxWindows
37// hybrid app.
38#if wxUSE_MFC && !defined(NOMAIN)
39#define NOMAIN 1
40#endif
41
beed393c
VZ
42// from src/msw/app.cpp
43extern void WXDLLEXPORT wxEntryCleanup();
44
b568d04f
VZ
45// ----------------------------------------------------------------------------
46// globals
47// ----------------------------------------------------------------------------
48
49HINSTANCE wxhInstance = 0;
50
51// ============================================================================
52// implementation
53// ============================================================================
54
55// ----------------------------------------------------------------------------
56// various entry points
57// ----------------------------------------------------------------------------
2bda0e17
KB
58
59// May wish not to have a DllMain or WinMain, e.g. if we're programming
b568d04f
VZ
60// a Netscape plugin or if we're writing a console application
61#if wxUSE_GUI && !defined(NOMAIN)
2bda0e17
KB
62
63// NT defines APIENTRY, 3.x not
64#if !defined(APIENTRY)
b568d04f 65 #define APIENTRY FAR PASCAL
2bda0e17
KB
66#endif
67
68/////////////////////////////////////////////////////////////////////////////////
69// WinMain
70// Note that WinMain is also defined in dummy.obj, which is linked to
71// an application that is using the DLL version of wxWindows.
72
73#if !defined(_WINDLL)
74
b4da152e 75#if defined(__TWIN32__) || defined(__WXMICROWIN__)
8f177c8e 76 #define HINSTANCE HANDLE
57c208c5 77
8f177c8e 78 extern "C"
b4da152e 79#endif
57c208c5 80
8f177c8e
VZ
81int PASCAL WinMain(HINSTANCE hInstance,
82 HINSTANCE hPrevInstance,
83 LPSTR lpCmdLine,
84 int nCmdShow)
2bda0e17 85{
8f177c8e
VZ
86 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
87 lpCmdLine, nCmdShow);
2bda0e17 88}
8f177c8e
VZ
89
90#endif // !defined(_WINDLL)
2bda0e17
KB
91
92/////////////////////////////////////////////////////////////////////////////////
93// DllMain
94
95#if defined(_WINDLL)
96
97// DLL entry point
98
99extern "C"
100#ifdef __BORLANDC__
101// SCD: I don't know why, but also OWL uses this function
102BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
103#else
104BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
105#endif
106{
beed393c 107#ifndef WXMAKINGDLL
2bda0e17 108 switch (fdwReason)
b568d04f
VZ
109 {
110 case DLL_PROCESS_ATTACH:
111 // Only call wxEntry if the application itself is part of the DLL.
beed393c
VZ
112 // If only the wxWindows library is in the DLL, then the
113 // initialisation will be called when the application implicitly
114 // calls WinMain.
b568d04f 115 return wxEntry((WXHINSTANCE) hModule);
2bda0e17 116
b568d04f 117 case DLL_PROCESS_DETACH:
beed393c
VZ
118 if ( wxTheApp )
119 wxTheApp->OnExit();
120 wxEntryCleanup();
121 break;
b568d04f 122 }
33ac7e6f
KB
123#else
124 (void)hModule;
125 (void)fdwReason;
beed393c 126#endif // !WXMAKINGDLL
33ac7e6f 127 (void)lpReserved;
b568d04f 128 return TRUE;
2bda0e17
KB
129}
130
b568d04f 131#endif // _WINDLL
2bda0e17 132
b568d04f
VZ
133#endif // !NOMAIN
134
135// ----------------------------------------------------------------------------
136// global functions
137// ----------------------------------------------------------------------------
138
139HINSTANCE wxGetInstance()
140{
141 return wxhInstance;
142}
143
144void wxSetInstance(HINSTANCE hInst)
145{
146 wxhInstance = hInst;
147}
2bda0e17 148