]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/main.cpp
make sure we are removing ourselves from the focus of the toplevel frame when deletin...
[wxWidgets.git] / src / msw / main.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: msw/main.cpp
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
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#include "wx/event.h"
32#include "wx/app.h"
33
34#include "wx/msw/private.h"
35
36// from src/msw/app.cpp
37extern void WXDLLEXPORT wxEntryCleanup();
38
39// ----------------------------------------------------------------------------
40// globals
41// ----------------------------------------------------------------------------
42
43HINSTANCE wxhInstance = 0;
44
45// ============================================================================
46// implementation
47// ============================================================================
48
49// ----------------------------------------------------------------------------
50// various entry points
51// ----------------------------------------------------------------------------
52
53// May wish not to have a DllMain or WinMain, e.g. if we're programming
54// a Netscape plugin or if we're writing a console application
55#if wxUSE_GUI && !defined(NOMAIN)
56
57// NT defines APIENTRY, 3.x not
58#if !defined(APIENTRY)
59 #define APIENTRY FAR PASCAL
60#endif
61
62/////////////////////////////////////////////////////////////////////////////////
63// WinMain
64// Note that WinMain is also defined in dummy.obj, which is linked to
65// an application that is using the DLL version of wxWindows.
66
67#if !defined(_WINDLL)
68
69#if defined(__TWIN32__) || defined(__WXWINE__) || defined(__WXMICROWIN__)
70 #define HINSTANCE HANDLE
71
72 extern "C"
73#endif // WINE
74
75int PASCAL WinMain(HINSTANCE hInstance,
76 HINSTANCE hPrevInstance,
77 LPSTR lpCmdLine,
78 int nCmdShow)
79{
80 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
81 lpCmdLine, nCmdShow);
82}
83
84#endif // !defined(_WINDLL)
85
86/////////////////////////////////////////////////////////////////////////////////
87// DllMain
88
89#if defined(_WINDLL)
90
91// DLL entry point
92
93extern "C"
94#ifdef __BORLANDC__
95// SCD: I don't know why, but also OWL uses this function
96BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
97#else
98BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
99#endif
100{
101#ifndef WXMAKINGDLL
102 switch (fdwReason)
103 {
104 case DLL_PROCESS_ATTACH:
105 // Only call wxEntry if the application itself is part of the DLL.
106 // If only the wxWindows library is in the DLL, then the
107 // initialisation will be called when the application implicitly
108 // calls WinMain.
109 return wxEntry((WXHINSTANCE) hModule);
110
111 case DLL_PROCESS_DETACH:
112 if ( wxTheApp )
113 wxTheApp->OnExit();
114 wxEntryCleanup();
115 break;
116 }
117#else
118 (void)hModule;
119 (void)fdwReason;
120#endif // !WXMAKINGDLL
121 (void)lpReserved;
122 return TRUE;
123}
124
125#endif // _WINDLL
126
127#endif // !NOMAIN
128
129// ----------------------------------------------------------------------------
130// global functions
131// ----------------------------------------------------------------------------
132
133HINSTANCE wxGetInstance()
134{
135 return wxhInstance;
136}
137
138void wxSetInstance(HINSTANCE hInst)
139{
140 wxhInstance = hInst;
141}
142