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 - <b>@ id ... vbx</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
@ ID ... VBX
Use a VBX control in a dialog
------------------------------------------------------------------------------

Syntax
#include "windows.ch"
#include "topclass.ch"   --or--   #define  NO_C4WCLASS
#include "commands.ch"
@ ID  <nId>  VBX
     [ FILENAME <cFile> ]
     [ CLASS <cClass> ]
     [ ON <eventN>  <actionN> ] . . .
     [ <clauses> ]

Arguments
FILENAME <cFile> can be used to specify the file containing
the control.  This parameter is not needed if you designed the
dialog with a version of Borland's Resource Workshop which
supports VBX controls (such as the version from BC++ 4.5).

CLASS <cClass> can be used to specify the window class of the
control.

ON <eventN>  <actionN> can be used to specify several events
sent by the VBX, together with corresponding actions to be
carried out.  Each <eventN> should be the name of an event,
and each <actionN> should be either a function or a codeblock.

See the generic @ ID ... <ControlType> command for details of
the <clauses> and/or parameters allowed.

Description
This command can be used to allow VBX controls to be used in a
dialog.  Unless stated elsewhere, to support VBX controls you
need a licensed copy of Borland's BIVBXnnn.DLL, which you
should name BIVBXC4W.DLL.  This DLL then acts as a "host"
(server) for VBX controls, under the control of Clip-4-Win.

If using CREATE DIALOG, you must include the VBX keyword:

     CREATE DIALOG oDlg  RESOURCE "MyDialog"  VBX

You can access properties using the functions
VBXGetPropByName() and VBXSetPropByName() or the methods
GetPropByName() and SetPropByName().

For a more OO approach, you can use the VBXGEN program (see
SOURCE\OO\VBXGEN.PRG) to examine a VBX and to generate its
best guess at a new class for the VBX.  You can then access
properties directly, e.g. as oSpin:SpinOrientation, and events
will be sent to the appropriate method of the class.  See
SOURCE\OO\CIRC3*.* for an example.

See the generic @ ID ... <ControlType> command for more
information.

Example
// An OO example (see SOURCE\OO\VBXDEMO.PRG):

CLASS MyVBXDialog INHERIT WVBXDialog
     PROTECT nSpin  AS INT
     PROTECT oSpin  AS OBJECT
     PROTECT oSay   AS OBJECT

     METHOD ChangeOrientation()                                   ;
            INLINE local n,                                       ;
                   n := ::oSpin:GetPropByName("SpinOrientation"), ;
                   ::oSpin:SetPropByName("SpinOrientation",       ;
                                         iif(n == 0, 1, 0))

     METHOD OnInitDialog(hCtrlFocus, nPtr)

     ACCESS Value             INLINE ::nSpin
     ASSIGN Value(nNew)                                ;
            INLINE ::nSpin := nNew,                    ;
                   ::oSay:Text := str(nNew), ; // show value in dialog
                   nNew
ENDCLASS

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

@ ID IDC_VALUE  SAY str(::nSpin)  Object ::oSay

return super:OnInitDialog(hCtrlFocus, nPtr)


// A non-OO example (see SOURCE\VBXDEMO2.PRG):

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

@ ID IDC_VALUE SAY str(nSpin) IN oDlg

SHOW DIALOG oDlg IN oWnd
return nil

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


See Also: @ ID ...

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