]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/main.cpp
Clean-up, speed-up and bug-fix for wxListCtrl drawing,
[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// ----------------------------------------------------------------------------
37// globals
38// ----------------------------------------------------------------------------
39
40HINSTANCE wxhInstance = 0;
41
42// ============================================================================
43// implementation
44// ============================================================================
45
46// ----------------------------------------------------------------------------
47// various entry points
48// ----------------------------------------------------------------------------
49
50// May wish not to have a DllMain or WinMain, e.g. if we're programming
51// a Netscape plugin or if we're writing a console application
52#if wxUSE_GUI && !defined(NOMAIN)
53
54// NT defines APIENTRY, 3.x not
55#if !defined(APIENTRY)
56 #define APIENTRY FAR PASCAL
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
66#if defined(__TWIN32__) || defined(__WXWINE__)
67 #define HINSTANCE HANDLE
68
69 extern "C"
70#endif // WINE
71
72int PASCAL WinMain(HINSTANCE hInstance,
73 HINSTANCE hPrevInstance,
74 LPSTR lpCmdLine,
75 int nCmdShow)
76{
77 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
78 lpCmdLine, nCmdShow);
79}
80
81#endif // !defined(_WINDLL)
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)
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.
104
105#if !defined(WXMAKINGDLL)
106 return wxEntry((WXHINSTANCE) hModule);
107#endif
108 break;
109
110 case DLL_PROCESS_DETACH:
111 default:
112 break;
113 }
114 return TRUE;
115}
116
117#endif // _WINDLL
118
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}
134