Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r8763]: docs / trunk / oodialog / en-US / resdialog.xml Maximize Restore History

Download this file

resdialog.xml    434 lines (401 with data), 20.2 kB

  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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "oodialog.ent">
%BOOK_ENTITIES;
]>
<!--#########################################################################
#
# Description: Open Object Rexx: ooDialog Reference XML file.
#
# Copyright (c) 2005-2013 Rexx Language Association. All rights reserved.
# Portions Copyright (c) 2004, IBM Corporation. All rights reserved.
#
# This program and the accompanying materials are made available under
# the terms of the Common Public License v1.0 which accompanies this
# distribution. A copy is also available at the following address:
# http://www.oorexx.org/license.html
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
#
# Neither the name of Rexx Language Association nor the names
# of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#########################################################################
-->
<chapter id="resourcedialogs"><title>Resource File Dialogs</title>
<indexterm><primary>Resource file dialogs</primary></indexterm>
<para>
The resource definition, or dialog <xref linkend="ovvDialogTemplate"/>, for a dialog can either be
constructed manually, (see the <xref linkend="clsUserDialog"/> Class,) or read from a file. ooDialog
provides two main dialog classes that read the dialog templates from a file: the
<xref linkend="clsResDialog"/> class and the <xref linkend="clsRcDialog"/> class.
</para>
<para>
The <computeroutput>ResDialog</computeroutput> class uses a dialog template from a binary file and a
<computeroutput>RcDialog</computeroutput> class gets the template from a resource script file. Resource script files
are plain text files. In general, both types of files are produced by resource editors which allow the user to
visually design the dialog in a &quot;What You See Is What You Get&quot; manner. Since resource definitions are
standardized, resource editors that produce Windows compatible files can be used to define dialogs for use with
ooDialog.
</para>
<section id="clsResDialog" xreflabel="ResDialog"><title>ResDialog Class</title>
<indexterm><primary>Resource file dialogs</primary><secondary>ResDialog class</secondary></indexterm>
<indexterm><primary>ResDialog class</primary></indexterm>
<para>
The ResDialog class is designed to be used together with a binary (compiled) resource. Compiled resources can be
attached to a <emphasis role="italic">module</emphasis>, which in Windows is a binary executable file. (Usually, a
file with the extension .exe or .dll). It is possible to create a DLL that has no executable code and attach compiled
resources to it. The common term for this type of DLL is a <emphasis role="italic">resource only</emphasis> DLL. A
resource only DLL is the type of module that makes the most sense to use with the ResDialog class. However, there is
no reason why any DLL, that has the compiled resource attached to it, could not be used.
</para>
<para>
<emphasis role="bold">Note:</emphasis> the <computeroutput>ResDialog</computeroutput> class is a concrete subclass of
the <xref linkend="chpDialogObject"/> object and therefore has all of the methods of the dialog object.
From the Rexx programmer's perspective, the only difference to be aware of is in the
<xref linkend="mthNewClsResDialog"/> method.
</para>
<section id="mthNewClsResDialog" xreflabel="new"><title>new (Class method)</title>
<indexterm><primary>new</primary><secondary>ResDialog class</secondary></indexterm>
<programlisting>
<![CDATA[
>>--new(--module--,--id--+-------------+--+----------+--)----------------------><
+-,--dlgData.-+ +-,--hFile-+
]]>
</programlisting>
<para>
Instantiates a new <computeroutput>ResDialog</computeroutput> object. The dialog template for the object is taken from
the specified module, which is usually a resource only DLL.
</para>
<variablelist>
<varlistentry><term><emphasis role="bold">Arguments:</emphasis></term>
<listitem>
<para>
The arguments when creating a new dialog instance of this class are:
<variablelist>
<varlistentry><term>module [required]</term>
<listitem>
<para>
The file name of the executable module (a DLL or EXE) in which the resource (the compiled dialog template) is
located.
</para>
</listitem></varlistentry>
<varlistentry><term>id [required]</term>
<listitem>
<para>
The resource ID of the dialog template. This may be numeric or <xref linkend="defSymbolicId"/>.
The resource ID is assigned to the dialog template when it was compiled.
</para>
</listitem></varlistentry>
<varlistentry><term>dlgData. [optional]</term>
<listitem>
<para>
A <xref linkend="termDialogDataStem"/> variable (don't forget the trailing period) that
contains data used to initialize the underlying dialog's controls.
</para>
</listitem></varlistentry>
<varlistentry><term>hFile [optional]</term>
<listitem>
<para>
The name of a <xref linkend="defHeaderFile"/> containing symbolic ID defines for resource IDs.
</para>
</listitem></varlistentry>
</variablelist>
</para>
</listitem></varlistentry>
<varlistentry><term><emphasis role="bold">Remarks:</emphasis></term>
<listitem>
<para>
Normally a programmer does not instantiate a <computeroutput>ResDialog</computeroutput> directly, but rather creates
a subclass of a <computeroutput>ResDialog</computeroutput> and instantiates the subclass. Recall that in ooRexx,
when a new object is instantiated, the <emphasis role="italic">new</emphasis> method invokes the <emphasis
role="italic">init</emphasis>() method of the object, using the method arguments of the <emphasis
role="italic">new</emphasis>() method. So, the arguments of the <emphasis role="italic">new</emphasis> method are
also the arguments of the <emphasis role="italic">init</emphasis> method.
</para>
<para>
Therefore, if the programmer over-rides the <emphasis role="italic">init</emphasis> method in the subclass of the
<computeroutput>ResDialog</computeroutput>, care must be taken to invoke the superclass <emphasis
role="italic">init</emphasis> method with the correct arguments.
</para>
<para>
When a <computeroutput>ResDialog</computeroutput>, or subclass, is instantiated, and the file specified in the
<emphasis role="italic">module</emphasis> argument can not be found, or can not be loaded as an executable module, a
message box will pop up informing the user of the problem.
</para>
</listitem></varlistentry>
<varlistentry><term><emphasis role="bold">Example:</emphasis></term>
<listitem>
<para>
This sample code creates a new dialog object from a subclass of <computeroutput>ResDialog</computeroutput>. It uses
the dialog template with resource ID 100 in the <computeroutput>MyDlg.dll</computeroutput> file. The state of the
dialog's controls are initialized with the values of the ctrlData. stem variable.
<programlisting>
<![CDATA[
ctrlData.101="1"
ctrlData.102="Please enter your password."
ctrlData.103=""
dlg = .PasswordDialog~new("passwordDlg.dll", 100, ctrlData.)
if dlg~initCode <> 0 then do
say 'The dialog could not be created'
return .false
/* Or some other error handling code. */
end
...
::requires "ooDialog.cls"
::class "PasswordDialog" subclass ResDialog
...
]]>
</programlisting>
</para>
<para>
An additional <link linkend="exampleDialogObjectnew">example</link> can be found under the <emphasis
role="italic">new</emphasis> method of the dialog object that shows the use of the dialog data stem and header file
arguments in more detail.
</para>
</listitem></varlistentry>
</variablelist>
</section>
</section>
<section id="clsRcDialog" xreflabel="RcDialog"><title>RcDialog Class</title>
<indexterm><primary>Resource file dialogs</primary><secondary>RcDialog class</secondary></indexterm>
<indexterm><primary>RcDialog class</primary></indexterm>
<para>
The <computeroutput>RcDialog</computeroutput> class gets its dialog <xref linkend="ovvDialogTemplate"/>
from a resource script file. Resource script files are plain text files usually produced by a resource editor. The
files generally have a file extension of &quot;.rc&quot;, but an extension of &quot;.dlg&quot; is used by some
resource editors.
</para>
<variablelist>
<varlistentry><term><emphasis role="bold">Notes:</emphasis></term>
<listitem>
<para>
The <computeroutput>RcDialog</computeroutput> class subclasses the <xref linkend="clsUserDialog"/>
class. The <computeroutput>UserDialog</computeroutput> is a concrete subclass of the
<xref linkend="chpDialogObject"/> object. Therefore the <computeroutput>RcDialog</computeroutput> has
available all of the methods of the dialog object and the <computeroutput>UserDialog</computeroutput>. For the Rexx
programmer, there are only a few differences to be aware of between the <computeroutput>UserDialog</computeroutput>
and the <computeroutput>RcDialog</computeroutput>.
</para>
<para>
The <computeroutput>RcDialog</computeroutput> class is a convenience class that uses the
<xref linkend="mthLoad"/> method of the <computeroutput>UserDialog</computeroutput> to load the dialog
template from the resource script file. The programmer then does not need to worry about the details of how and when to
load the resource script. There is a slight difference in <xref linkend="mthNewClsRcDialog"/> the class. The programmer
does not need to use the <xref linkend="mthDefineDialog"/> method because the dialog is defined in the resource script.
Other than that, the <computeroutput>RcDialog</computeroutput> class is used in the same manner as the
<computeroutput>UserDialog</computeroutput> class.
</para>
<para>
Although the programmer does not need to use the <emphasis role="italic">define</emphasis>() method, there is
nothing preventing its use. The <emphasis role="italic">define</emphasis>() method could be used at runtime to add
additional dialog controls to those defined in the resource script.
</para>
</listitem></varlistentry>
</variablelist>
<section id="mthNewClsRcDialog" xreflabel="new"><title>new (Class method)</title>
<indexterm><primary>new</primary><secondary>RcDialog class</secondary></indexterm>
<programlisting>
<![CDATA[
>>--init(--script--,--id--+------------+--+---------+--+--------+--+------------+--)--><
+-,-dlgData.-+ +-,-hFile-+ +-,-opts-+ +-,-expected-+
]]>
</programlisting>
<para>
Instantiates a <computeroutput>RcDialog</computeroutput> object.
</para>
<variablelist>
<varlistentry><term><emphasis role="bold">Arguments:</emphasis></term>
<listitem>
<para>
The arguments when creating a new dialog instance of this class are:
<variablelist>
<varlistentry><term>script [required]</term>
<listitem>
<para>
The file name of the resource script containing the dialog template.
</para>
</listitem></varlistentry>
<varlistentry><term>id [required]</term>
<listitem>
<para>
The resource ID of the dialog template. This may be numeric or <xref linkend="defSymbolicId"/>.
</para>
</listitem></varlistentry>
<varlistentry><term>dlgData. [optional]</term>
<listitem>
<para>
A <xref linkend="termDialogDataStem"/> variable (don't forget the trailing period) that
contains data used to initialize the underlying dialog's controls.
</para>
</listitem></varlistentry>
<varlistentry><term>hFile [optional]</term>
<listitem>
<para>
The name of a <xref linkend="defHeaderFile"/>) containing symbolic ID defines for resource IDs.
</para>
</listitem></varlistentry>
<varlistentry><term>opts [optional]</term>
<listitem>
<para>
Zero or more of the following keywords, separated by blanks:
<variablelist>
<varlistentry><term>CENTER</term>
<listitem>
<para>
The dialog is to be positioned in the center of the screen.
</para>
</listitem></varlistentry>
<varlistentry><term>CONNECTBUTTONS</term>
<listitem>
<para>
Each push <xref linkend="clsButton"/> in the underlying dialog has the CLICKED
<xref linkend="ovvEvents"/> notification connected automatically to a method in the Rexx dialog object.
This is the same as using the <xref linkend="mthConnectButtonEvent"/>() method for the
CLICKED notification. The name for the method is generated automatically by the ooDialog framework. The method
name is the button label with all spaces, ampersands, colons, and trailing <emphasis
role="italic">...</emphasis> characters removed.
</para>
</listitem></varlistentry>
<varlistentry><term>CONNECTRADIOS</term>
<listitem>
<para>
Similar to CONNECTBUTTONS, this option connects the CLICKED event notification from each
<xref linkend="clsRadioButton"/> button to a method in the Rexx dialog object. Again, this is the same as
using the <emphasis role="italic">connectButtonEvent</emphasis> method. For radio buttons, the generated
method name is the button label with all spaces, ampersands, colons, and trailing <emphasis
role="italic">...</emphasis> characters removed. The resulting text is then <emphasis
role="bold">prepened</emphasis> with the text <computeroutput>ID</computeroutput>.
</para>
</listitem></varlistentry>
<varlistentry><term>CONNECTCHECKS</term>
<listitem>
<para>
Exactly the same as CONNECTRADIOS, for check <xref linkend="clsCheckBox"/> controls. The object
method name is generated in the same way as it is for radio buttons. That is, the method name is the button
label, with all spaces, ampersands, colons, and trailing <emphasis role="italic">...</emphasis> characters
removed. Which is then <emphasis role="bold"> prepended</emphasis> with the text
<computeroutput>ID</computeroutput>.
</para>
</listitem></varlistentry>
</variablelist>
</para>
</listitem></varlistentry>
<varlistentry><term>expected [optional]</term>
<listitem>
<para>
This is the maximum number of dialog controls expected in the dialog template. It serves the same purpose as the
<emphasis role="italic">expected</emphasis> argument in the <xref linkend="mthCreate"/>() method of
the <computeroutput>UserDialog</computeroutput>. The default value for this argument is 200.
</para>
</listitem></varlistentry>
</variablelist>
</para>
</listitem></varlistentry>
<varlistentry><term><emphasis role="bold">Remarks:</emphasis></term>
<listitem>
<para>
Normally a programmer does not instantiate a <computeroutput>RcDialog</computeroutput> directly, but rather creates
a subclass of a <computeroutput>RcDialog</computeroutput> and instantiates the subclass. Recall that in ooRexx, when
a new object is instantiated, the <emphasis role="italic">new</emphasis> method invokes the <emphasis
role="italic">init</emphasis>() method of the object using the arguments passed to the <emphasis
role="italic">new</emphasis>() method. So, the arguments of the <emphasis role="italic">new</emphasis> method are
also the arguments of the <emphasis role="italic">init</emphasis> method.
</para>
<para>
If the programmer over-rides the <emphasis role="italic">init</emphasis> method in the subclass of the
<computeroutput>RcDialog</computeroutput>, care must be taken to invoke the superclass <emphasis
role="italic">init</emphasis> method with the correct arguments.
</para>
</listitem></varlistentry>
<varlistentry><term><emphasis role="bold">Example:</emphasis></term>
<listitem>
<para>
This example creates a new dialog object using the <computeroutput>SimpleLB</computeroutput> class, which
subclasses the <computeroutput>RcDialog</computeroutput>. It uses the dialog definition with symbolic ID
<computeroutput>IDD_DIALOG1</computeroutput> in the <computeroutput>listBox.rc</computeroutput> resource script
file. The dialog is initialized so that the &quot;Doctor&quot; item is selected in the list box with
symbolic ID of <computeroutput>IDC_LB</computeroutput> by using the <computeroutput>dlgData.</computeroutput> stem
variable. The symbolic IDs for this program are contained in the &quot;resource.h&quot; file. When the user
closes the dialog, the <computeroutput>dlgData.IDC_LB</computeroutput> variable will contain the text of the
selected item in the list box.
</para>
<programlisting>
<![CDATA[
/* Simple ListBox using a .rc file for the dialog template */
dlgData.IDC_LB = "Doctor"
dlg = .SimpleLB~new("listBox.rc", IDD_DIALOG1, dlgData., "resource.h")
if dlg~initCode = 0 then do
dlg~execute("SHOWTOP")
end
else do
say "Problem creating the dialog. init code:" dlg~initCode
return 99
end
say "The user's choosen profession is" dlgData.IDC_LB
return 0
::requires "ooDialog.cls"
::class 'SimpleLB' subclass RcDialog
::method initDialog
lb = self~newListBox(IDC_LB)
lb~add("Business Manager" )
lb~add("Software Developer")
lb~add("Accountant")
lb~add("Lawyer")
lb~add("Doctor")
]]>
</programlisting>
<para>
To try the example, cut and paste the above code into a file named <computeroutput>listBox.rex</computeroutput> and
paste the following code into the files <computeroutput>listBox.rc</computeroutput> and
<computeroutput>resource.h</computeroutput>.
</para>
<programlisting>
<![CDATA[
/* listBox.rc */
#include <windows.h>
#include <commctrl.h>
#include "resource.h"
IDD_DIALOG1 DIALOGEX 30,30,179,182
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "List Box Example"
FONT 8,"MS Shell Dlg 2",400,0,1
BEGIN
DEFPUSHBUTTON "Close",IDOK,122,161,50,14
LISTBOX IDC_LB,8,28,163,122,WS_TABSTOP | LBS_NOINTEGRALHEIGHT | LBS_SORT
CTEXT "Pick Your Choosen Profession",IDC_STATIC,26,13,122,9
END
/* resource.h */
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDD_DIALOG1 100
#define IDC_LB 1001
]]>
</programlisting>
</listitem></varlistentry>
</variablelist>
</section>
</section>
</chapter>