Chapter 8. Resource File Dialogs

Table of Contents
ResDialog Class
RcDialog Class

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.

ResDialog Class

The ResDialog class is designed to be used together with a binary (compiled) resource. Compiled resources can be attached a module, which in Windows is a binary executable file. (That is, 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 resource only 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.


ResDlg.cls is the source file of this class.

  ::requires "oodialog.cls"


The ResDialog class is a subclass of BaseDialog and therefore inherits all the methods of that class.

new (Class method)

                         +-,--DlgData.-+  +-,--hFile-+

Instantiates a new ResDialog object. The dialog template for the object is taken from the specified module, which normally is a resource only DLL.


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 resolving to the unique number. This number is assigned to the dialog template resource when it was created.


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.102="Please enter your password."

    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. */

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.


                        +-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.

Internal Use:

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.



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.