]> git.saurik.com Git - wxWidgets.git/blame - src/msw/main.cpp
Added #pragma implementation for gcc.
[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__)
8f177c8e 67 #define HINSTANCE HANDLE
57c208c5 68
8f177c8e
VZ
69 extern "C"
70#endif // WINE
57c208c5 71
8f177c8e
VZ
72int PASCAL WinMain(HINSTANCE hInstance,
73 HINSTANCE hPrevInstance,
74 LPSTR lpCmdLine,
75 int nCmdShow)
2bda0e17 76{
8f177c8e
VZ
77 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
78 lpCmdLine, nCmdShow);
2bda0e17 79}
8f177c8e
VZ
80
81#endif // !defined(_WINDLL)
2bda0e17
KB
82
83/////////////////////////////////////////////////////////////////////////////////
84// DllMain
85
86#if defined(_WINDLL)
87
88// DLL entry point
89
90extern "C"
91#ifdef __BORLANDC__
92// SCD: I don't know why, but also OWL uses this function
93BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
94#else
95BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
96#endif
97{
98 switch (fdwReason)
b568d04f
VZ
99 {
100 case DLL_PROCESS_ATTACH:
101 // Only call wxEntry if the application itself is part of the DLL.
102 // If only the wxWindows library is in the DLL, then the initialisation
103 // will be called when the application implicitly calls WinMain.
2bda0e17
KB
104
105#if !defined(WXMAKINGDLL)
b568d04f 106 return wxEntry((WXHINSTANCE) hModule);
2bda0e17 107#endif
b568d04f 108 break;
2bda0e17 109
b568d04f
VZ
110 case DLL_PROCESS_DETACH:
111 default:
112 break;
113 }
114 return TRUE;
2bda0e17
KB
115}
116
b568d04f 117#endif // _WINDLL
2bda0e17 118
b568d04f
VZ
119#endif // !NOMAIN
120
121// ----------------------------------------------------------------------------
122// global functions
123// ----------------------------------------------------------------------------
124
125HINSTANCE wxGetInstance()
126{
127 return wxhInstance;
128}
129
130void wxSetInstance(HINSTANCE hInst)
131{
132 wxhInstance = hInst;
133}
2bda0e17 134