Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

WDialog:Add() Method
Add a control to the dialog
------------------------------------------------------------------------------

Syntax
<oWnd>:Add( <oCtrl>, [ <bcCmd> ] , [ <bcValid> ] , [ <bcWhen> ] )
       -->   self

Arguments
<oCtrl> is a control window object.

<bcCmd> is either a code block or a message (method) name (for
an OO application).  If this control sends messages to the
dialog, Clip-4-Win will either execute the code block or the
specified message in the dialog (if OO).

For a non-OO app, the code block is passed the dialog handle,
the control handle, the notification code sent by the control
(e.g. one of the CBN_*, EN_*, LBN_*, SB_* values in
WINDOWS.CH), and the control's id.  For an OO app, the code
block is passed the owning dialog object, the control object
and the notification code sent by the control.

For an OO app, the mechanism where the message is sent to
(executed in) the dialog can be described as "smart dialogs,
dumb controls".  If you want to change this, refer to the
OnCommand() method in SOURCE\OO\CLASSES\DIALOG.PRG.

<bcValid> optionally specifies either a code block to be used
for validation or a message (method) name (for an OO app).
This block/message can be used many times during the lifetime
of a dialog, so it is not a good idea to prompt the user.  For
a non-OO app, the code block is passed the dialog handle, the
control handle and the control's id.  For an OO app, the code
block / method is passed the owning dialog object and the
control object.

<bcWhen> is reserved for future use.

Returns
SELF.

Description
This method adds a control (child window) to those currently
active and owned by this dialog.  Such windows are eligible
for special consideration, e.g. they may have OnDrawItem()
messages reflected to them.  Also, the <bcCmd>, <bcValid> and
<bcWhen> may be handled automatically.

Usually you use this method without realising it, as a side
effect of an @ ID ... command.

Example
// A non-OO Example: from SOURCE\VBXDEMO2.PRG:
static function DemoDlg(oWnd)

CREATE DIALOG oDlg RESOURCE "VBXDemoDlg" VBX

@ ID IDC_SPIN1 VBX IN oDlg                                              ;
     ON SpinUp   {|hDlg| SetDlgItemText(hDlg, IDC_VALUE, str(++nSpin))} ;
     ON SpinDown {|hDlg| SetDlgItemText(hDlg, IDC_VALUE, str(--nSpin))}

@ ID IDC_CHANGE_ORIENTATION BUTTON ChangeOrientation IN oDlg
// . . .

static function ChangeOrientation(hDlg)
local     hCtl := VBXGetHctl(GetDlgItem(hDlg, IDC_SPIN1))
local     nValue := VBXGetPropByName(hCtl, "SpinOrientation")
VBXSetPropByName(hCtl, "SpinOrientation", iif(nValue == 0, 1, 0))
return 1


// OO Example: from SOURCE\OO\VBXDEMO.PRG:
CLASS MyVBXDialog INHERIT WVBXDialog
// . . .
METHOD ChangeOrientation()                                      ;
       INLINE local n,                                          ;
              n := ::oSpin:GetPropByName("SpinOrientation"),    ;
              ::oSpin:SetPropByName("SpinOrientation",          ;
                                    iif(n == 0, 1, 0))
// . . .

METHOD OnInitDialog(hCtrlFocus, nPtr) CLASS MyVBXDialog
::nSpin = 0

@ ID IDC_SPIN1 VBX  Object ::oSpin             ;
     ON SpinUp   ::Value++                     ;
     ON SpinDown ::Value--

@ ID IDC_CHANGE_ORIENTATION BUTTON ChangeOrientation
// . . .


See Also: WDialog:Cancel() WDialog:Ok() @ ID ...

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson