The resource definition for a dialog can either be constructed manually, (see the UserDialog Class,) or the definition can be read from a file. ooDialog provides two main dialog classes that read their dialog definitions from a file: the ResDialog class and the RcDialog class.
The ResDialog class uses a dialog definition from a binary file and a RcDialog class gets the definition 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 "What You See Is What You Get" manner. Since resource definitions are standardized, resource editors that produce Windows compatible files can be used to define dialogs for use with ooDialog.
The ResDialog class is designed to be used together with a binary (compiled) resource. A binary dialog resource is linked to a DLL (that is, a file with the extension .DLL).
ResDlg.cls is the source file of this class.
::requires "oodialog.cls"
The ResDialog class is a subclass of BaseDialog and therefore has all the methods defined for that class.
>>-aResDialog~Init(--Library--,--Resource--+-------------+--+----------+--)-->< +-,--DlgData.-+ +-,--hFile-+
The Init method of the parent class, BaseDialog, has been overridden.
The arguments when creating a new dialog instance of this class are:
The file name of the DLL where the resource is located.
The ID of the resource. This is an unique number, or sybmbolic ID, you assigned to the (dialog) resource while creating it.
A stem variable (don't forget the trailing period) that contains initialization data.
The file name of a header file containing symbolic ID defines for resources.
This sample code creates a new dialog object from the ResDialog class. It uses dialog resource 100 in the MYDLG.DLL file. The dialog is initialized with the values of the MyDlgData. stem variable.
MyDlgData.101="1" MyDlgData.102="Please enter your password." MyDlgData.103="" dlg = ResDialog~new("MYDLG.DLL", 100, MyDlgData.) if dlg~initCode <> 0 then do say 'The dialog could not be created' return .false /* Or some other error handling code. */ end ...
An additional example can be found under the Init method, in the BaseDialog section, that shows the use of the dialog data stem and header file arguments in more detail.
Note: For a ResDialog the InitCode attribute will be -1 after the dialog object is instantiated if the resource ID could not be resolved. For other cases where initialization failed the value will be some other non-zero value.
>>-aResDialog~StartIt(--+------+--+-----------+--)------------->< +-icon-+ +-,--modal--+
The StartIt method is intended for internal use only. It is used to create the real Windows object based on the dialog template in the binary resource file. It is called by the Execute or ExecuteAsync methods.
This method is intended for internal use. It can be overridden, although that is not recommended.
There are two optional arguments:
The resource ID of the icon to be used as the dialog icon. When this argument is omitted the default dialog icon is used.
If a modal or a modeless dialog is to be created. A value of 0 signals a modal dialog should be created. A value of 1, or the string "NOTMODAL" case insignificant, signals a modeless dialog should be created. The default is 0.
>>-aResDialog~SetMenu(--resid--)-------------------------------><
The SetMenu method adds a menu resource, that is stored in the same DLL, to the dialog. Note that the menu needs additional space and therefore displaces the rest of the dialog items.
SetMenu can be called in the InitDialog method only.
There is only one argument:
ID of the menu resource stored in the same DLL as the dialog.