File: wx149.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (130 lines) | stat: -rw-r--r-- 4,557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<HTML>
<head><title>wxModule</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxmodule"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx148.htm#wxminiframe"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx150.htm#wxmouseevent"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxModule</H2>
<P>
The module system is a very simple mechanism to allow applications (and parts of wxWindows itself) to
define initialization and cleanup functions that are automatically called on wxWindows
startup and exit.<P>
To define a new kind of module, derive a class from wxModule, override the OnInit and OnExit functions,
and add the DECLARE_DYNAMIC_CLASS and IMPLEMENT_DYNAMIC_CLASS to header and implementation files
(which can be the same file). On initialization, wxWindows will find all classes derived from wxModule,
create an instance of each, and call each OnInit function. On exit, wxWindows will call the OnExit
function for each module instance.<P>
Note that your module class does not have to be in a header file.<P>
For example:<P>
<PRE>
  // A module to allow DDE initialization/cleanup
  // without calling these functions from app.cpp or from
  // the user's application.

  class wxDDEModule: public wxModule
  {
  DECLARE_DYNAMIC_CLASS(wxDDEModule)
  public:
      wxDDEModule() {}
      bool OnInit() { wxDDEInitialize(); return TRUE; };
      void OnExit() { wxDDECleanUp(); };
  };

  IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule)
</PRE>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/module.h&gt;<P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxmoduleconstr">wxModule::wxModule</A><BR>
<A HREF="#topic574">wxModule::~wxModule</A><BR>
<A HREF="#wxmodulecleanupmodules">wxModule::CleanupModules</A><BR>
<A HREF="#wxmoduleexit">wxModule::Exit</A><BR>
<A HREF="#wxmoduleinit">wxModule::Init</A><BR>
<A HREF="#wxmoduleinitializemodules">wxModule::InitializeModules</A><BR>
<A HREF="#wxmoduleonexit">wxModule::OnExit</A><BR>
<A HREF="#wxmoduleoninit">wxModule::OnInit</A><BR>
<A HREF="#wxmoduleregistermodule">wxModule::RegisterModule</A><BR>
<A HREF="#wxmoduleregistermodules">wxModule::RegisterModules</A><BR>
<P>

<HR>
<A NAME="wxmoduleconstr"></A>
<H3>wxModule::wxModule</H3>
<P>
<B></B> <B>wxModule</B>()<P>
Constructs a wxModule object.<P>

<HR>
<A NAME="topic574"></A>
<H3>wxModule::~wxModule</H3>
<P>
<B></B> <B>~wxModule</B>()<P>
Destructor.<P>

<HR>
<A NAME="wxmodulecleanupmodules"></A>
<H3>wxModule::CleanupModules</H3>
<P>
<B>static void</B> <B>CleanupModules</B>()<P>
Calls Exit for each module instance. Called by wxWindows on exit, so there is no
need for an application to call it.<P>

<HR>
<A NAME="wxmoduleexit"></A>
<H3>wxModule::Exit</H3>
<P>
<B>void</B> <B>Exit</B>()<P>
Calls OnExit. This function is called by wxWindows and should not need to be called
by an application.<P>

<HR>
<A NAME="wxmoduleinit"></A>
<H3>wxModule::Init</H3>
<P>
<B>bool</B> <B>Init</B>()<P>
Calls OnInit. This function is called by wxWindows and should not need to be called
by an application.<P>

<HR>
<A NAME="wxmoduleinitializemodules"></A>
<H3>wxModule::InitializeModules</H3>
<P>
<B>static bool</B> <B>InitializeModules</B>()<P>
Calls Init for each module instance. Called by wxWindows on startup, so there is no
need for an application to call it.<P>

<HR>
<A NAME="wxmoduleonexit"></A>
<H3>wxModule::OnExit</H3>
<P>
<B>virtual void</B> <B>OnExit</B>()<P>
Provide this function with appropriate cleanup for your module.<P>

<HR>
<A NAME="wxmoduleoninit"></A>
<H3>wxModule::OnInit</H3>
<P>
<B>virtual bool</B> <B>OnInit</B>()<P>
Provide this function with appropriate initialization for your module. If the function
returns FALSE, wxWindows will exit immediately.<P>

<HR>
<A NAME="wxmoduleregistermodule"></A>
<H3>wxModule::RegisterModule</H3>
<P>
<B>static void</B> <B>RegisterModule</B>(<B>wxModule*</B><I> module</I>)<P>
Registers this module with wxWindows. Called by wxWindows on startup, so there is no
need for an application to call it.<P>

<HR>
<A NAME="wxmoduleregistermodules"></A>
<H3>wxModule::RegisterModules</H3>
<P>
<B>static bool</B> <B>RegisterModules</B>()<P>
Creates instances of and registers all modules. Called by wxWindows on startup, so there is no
need for an application to call it.<P>

</BODY></HTML>