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

Syntax
#include "windows.ch"
#include "topclass.ch"   --or--   #define  NO_C4WCLASS
#include "commands.ch"
@ ID  <nId>  CONTROL <class>
     [ WCLASS <cnWClass> ]
     [ STYLE <nStyle> ]
     [ <clauses> ]

Arguments
<class> specifies the class used to create objects for your
control type.

WCLASS <cnWClass> can be used to specify the window class, as
could be used by CreateWindow().  The window class should be
either one of the predefined control classes (DLG_*, or the
name e.g. "listbox"), or your own window class.  If you use
your own window class you should make sure it's been
registered with Windows by calling the RegisterClass()
function before a dialog using your control is created.
Failing to do this will make the various dialog creation
functions, e.g. DialogBox(), return an error: -1 for
DialogBox(), 0 for CreateDialog().

STYLE <nStyle> can be specified as with any control, but is
mentioned here to point out that if you don't specify a STYLE,
CTL_DEFSTYLE (defined in COMMANDS.CH) will be added
automatically.  Your style should normally include WS_VISIBLE
and WS_CHILD (as per CTL_DEFSTYLE).  A common style also used
is WS_TABSTOP.  Forgetting WS_CHILD for a control in a dialog
usually causes the dialog function to return an error: -1 for
DialogBox(), 0 for CreateDialog().

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

Description
This command allows you to use a user-defined control type in
a dialog.

You can use this command for any of the predefined controls,
too.  You might do this to specify your own <class> (which
would probably be a sub-class of the default one) or perhaps
to debug why your own control isn't behaving as expected.

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

Example
// These 2 dynamic controls are the same, except the 2nd uses the
// class MyCB:
@ Id IDD_CBOX  Obj ::oCB   ComboBox  Items {"A List", "Of Choices"} ;
     At 170,2 Size 60,50
@ Id IDD_CBOX  Obj ::oCB   Control MyCB  WClass DLG_COMBOBOX ;
     Style CBS_DROPDOWNLIST + WS_TABSTOP + CTL_DEFSTYLE ;
     Items {"A List", "Of Choices"} At 170,2 Size 60,25

// These 2 resource controls are the same, except the 2nd uses
// the class MyCB:
@ Id IDD_CBOX  Obj ::oCB   ComboBox  Items {"A List", "Of Choices"}
@ Id IDD_CBOX  Obj ::oCB   Control MyCB  Items {"A List", "Of Choices"}

@ Id IDD_BMPBTN   Control WButtonBitmap  WClass DLG_BUTTON  ;
     Init {.f., IDB_BITMAP, .f., .f., .f.}                  ;
     Style BS_OWNERDRAW + WS_TABSTOP + CTL_DEFSTYLE         ;
     At 66,2 Size 12,12


See Also: @ ID ...

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