home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
RB3641.ZIP
/
EX1
/
TESTDLG2.CLS
< prev
next >
Wrap
Text File
|
1991-12-20
|
3KB
|
92 lines
DialogBox subclass: #TestDialog
instanceVariableNames: ''
classVariableNames:
'ItemIds '
poolDictionaries:
'PMConstants ' !
!TestDialog class methods !
initialize
"Fill the ItemIds dictionary holding
the ID values of controls in the Dialog Box.
This method must be written by application developer
in order to provide a link between dialog box
controls and application methods.
ItemIds dictionary can be generated 'manually'
( like in here ) or by reading the include-file
(xxx.h) generated by Dialog Box Editor."
ItemIds := Dictionary new.
ItemIds at: 101 put: #ok;
at: 'entryfield' put: 103;
"Notice the checkbox has two entries. The first
associates the dialog ID with the symbolic name. The
second associates the control itself with the method
used to manipulate it."
at: 'myCheckbox' put: 102;
at: 102 put: #myCheckbox.!
windowId
"Answer the dialog id of the TestDialog."
^101! !
!TestDialog methods !
itemIds
"Returns the value of itemIds dictionary used to
correlate the IDs in the dialog .res file and the
symbolic names used here in the methods."
^ItemIds!
myCheckbox
"Private - The user clicked on the checkbox."
(self queryButton: (ItemIds at: 'myCheckbox'))
ifTrue: [
"Perhaps do some processing here..."
]
ifFalse: [
]!
ok
"Called when the user selects the OK push button in
the dialog box. No processing is done, just closing
the dialog and printing out the contents of the
entryfield. Validation could be done here, for instance."
Transcript nextPutAll: 'In the entryfield was ', (self queryItemText: (ItemIds at: 'entryfield')) ;
cr .
^self close!
open
"Used for TestDialog to show how to open a dialog,
set a text limit on an entry field and fill in some
text and set the state of a checkbox."
"Changed from ToDoAboutDialogBox."
self fromResFile: 'ex1\test.res'.
" self fromModule: (DynamicLinkLibrary open:'c:\stvpm\todo\dlgdll.dll') id: self class windowId."
"Taken and changed from NewSubclassDialog."
self setItemText: (ItemIds at: 'entryfield') string: 'hello world'.
self setTextLimit: (ItemIds at: 'entryfield') to: 25. "arbitrary"
"New code."
self setButton: (ItemIds at: 'myCheckbox') value: true.
"Unchanged from ToDoAboutDialogBox."
self showWindow.
self processInput! !