]> git.saurik.com Git - wxWidgets.git/blame - src/msw/main.cpp
Rotated text patch from Hans-Joachim Baader (with some corrections)
[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$
8// Copyright: (c) Julian Smart and Markus Holzem
b568d04f 9// Licence: wxWindows license
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
36// ----------------------------------------------------------------------------
37// globals
38// ----------------------------------------------------------------------------
39
40HINSTANCE wxhInstance = 0;
41
42// ============================================================================
43// implementation
44// ============================================================================
45
46// ----------------------------------------------------------------------------
47// various entry points
48// ----------------------------------------------------------------------------
2bda0e17
KB
49
50// May wish not to have a DllMain or WinMain, e.g. if we're programming
b568d04f
VZ
51// a Netscape plugin or if we're writing a console application
52#if wxUSE_GUI && !defined(NOMAIN)
2bda0e17
KB
53
54// NT defines APIENTRY, 3.x not
55#if !defined(APIENTRY)
b568d04f 56 #define APIENTRY FAR PASCAL
2bda0e17
KB
57#endif
58
59/////////////////////////////////////////////////////////////////////////////////
60// WinMain
61// Note that WinMain is also defined in dummy.obj, which is linked to
62// an application that is using the DLL version of wxWindows.
63
64#if !defined(_WINDLL)
65
4286a5b5 66#if defined(__TWIN32__) || defined(__WXWINE__)
57c208c5
JS
67
68extern "C"
69BOOL PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
70
71#else
72
2bda0e17
KB
73#ifdef __WATCOMC__
74int PASCAL
75#else
76int APIENTRY
77#endif
78
57c208c5
JS
79 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
80#endif
81// __TWIN32__
82
2bda0e17 83{
57c208c5 84 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, lpCmdLine, nCmdShow);
2bda0e17
KB
85}
86#endif
87
88/////////////////////////////////////////////////////////////////////////////////
89// DllMain
90
91#if defined(_WINDLL)
92
93// DLL entry point
94
95extern "C"
96#ifdef __BORLANDC__
97// SCD: I don't know why, but also OWL uses this function
98BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
99#else
100BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
101#endif
102{
103 switch (fdwReason)
b568d04f
VZ
104 {
105 case DLL_PROCESS_ATTACH:
106 // Only call wxEntry if the application itself is part of the DLL.
107 // If only the wxWindows library is in the DLL, then the initialisation
108 // will be called when the application implicitly calls WinMain.
2bda0e17
KB
109
110#if !defined(WXMAKINGDLL)
b568d04f 111 return wxEntry((WXHINSTANCE) hModule);
2bda0e17 112#endif
b568d04f 113 break;
2bda0e17 114
b568d04f
VZ
115 case DLL_PROCESS_DETACH:
116 default:
117 break;
118 }
119 return TRUE;
2bda0e17
KB
120}
121
b568d04f 122#endif // _WINDLL
2bda0e17 123
b568d04f
VZ
124#endif // !NOMAIN
125
126// ----------------------------------------------------------------------------
127// global functions
128// ----------------------------------------------------------------------------
129
130HINSTANCE wxGetInstance()
131{
132 return wxhInstance;
133}
134
135void wxSetInstance(HINSTANCE hInst)
136{
137 wxhInstance = hInst;
138}
2bda0e17 139