User Tools

Site Tools


create_return_new_control_created_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== CREATE (return new control created) ====== Previous pageReturn to chapter overviewNext page

CREATE( control , type [, parent ] [, position ] )

blk2blue.jpg

CREATE Creates a new control.
control A field number or field equate label for the control to create. The valid range of field numbers is -4000h to 4000h. If the control equal to 0, the CREATE procedure returns the next available field number and assigns that to the control being created.
type An integer constant, expression, EQUATE, or variable that specifies the type of control to create.
parent A field number or field equate label that specifies the OPTION, GROUP, SHEET, TAB, MENU, HEADER, FOOTER, DETAIL, BREAK, or FORM to contain the new control. If omitted, the control has no parent.
position An integer constant, expression, or variable that specifies the position within a MENU to place a new ITEM control. If omitted, the ITEM is added to the end.

CREATE dynamically creates a new control in the currently active APPLICATION or WINDOW, returning the value of the control parameter. If the field creation fails, a 0 is returned. This procedure is valid in Clarion Win32 Windows, and also for REPORT structures in both Clarion Win32 and Clarion#.

When first created, the new control is initially hidden, so its properties can be set using the runtime property assignment syntax, SETPOSITION, and SETFONT. It appears on screen only by issuing an UNHIDE statement for the control.

You can also use CREATE to create report controls. To do this, you must first use SETTARGET to make the report the currently active TARGET, and you must also specify a parent for the control.

EQUATE statements for the type parameter are contained in the EQUATES.CLW file. The following list is a comprehensive sample of these (see EQUATES.CLW for the complete list):

CREATE:sstring STRING(picture),USE(variable)
CREATE:string STRING(constant)
CREATE:image IMAGE()
CREATE:region REGION()
CREATE:line LINE()
CREATE:box BOX()
CREATE:ellipse ELLIPSE()
CREATE:entry ENTRY()
CREATE:button BUTTON()
CREATE:prompt PROMPT()
CREATE:option OPTION()
CREATE:radio RADIO()
CREATE:check CHECK()
CREATE:group GROUP()
CREATE:list LIST()
CREATE:combo COMBO()
CREATE:spin SPIN()
CREATE:text TEXT()
CREATE:custom CUSTOM()
CREATE:droplist LIST(),DROP()
CREATE:dropcombo COMBO(),DROP()
CREATE:menu MENU()
CREATE:item ITEM()
CREATE:toolbar TOOLBAR()
CREATE:RTF RTF TEXT control

Note: The CREATE:Toolbar constant is a modifier to instruct the runtime library that the control must be created inside the toolbar rather than inside window client area:

CREATE (0, CREATE:Button + CREATE:Toolbar)

!creates a button on the toolbar if it exists

CREATE (0, CREATE:Button)

!creates a button in the window client area

Return Data Type: SIGNED

Example:

PROGRAM
INCLUDE('keycodes.clw')
MAP
END
TestGroup   GROUP,PRE(CTL)
CODE         LONG
Name         STRING(30)
           END
X           SHORT
Y           SHORT
Width       SHORT
Height      SHORT
Code4Entry  STRING(10)
?Code4Entry EQUATE(100)   !Create an arbitrary field equate number for CREATE to use
FEQ         EQUATE(101)
UseVarText1 &STRING
Window WINDOW,VSCROLL,GRAY,MAXIMIZE
      ENTRY(@N3),AT(3,32),USE(Ctl:Code)
      ENTRY(@S30),AT(98,8),USE(Ctl:Name)
      BUTTON('OK'),AT(5,7),USE(?OkButton)
      BUTTON('Cancel'),AT(45,7),USE(?CanxButton)
    END
CODE
OPEN(Window)
ACCEPT
 CASE ACCEPTED()
 OF ?Ctl:Code
  IF Ctl:Code = 4
  CREATE(?Code4Entry,CREATE:entry)           !Create the control
   ?Code4Entry{PROP:use} = Code4Entry         !Set USE variable
   ?Code4Entry{PROP:text} = '@s10'            !Set entry picture
   GETPOSITION(?Ctl:Code,X,Y,Width,Height)
   ?Code4Entry{PROP:Xpos} = X + Width + 40    !Set x position
   ?Code4Entry{PROP:Ypos} = Y                 !Set y position
   UNHIDE(?Code4Entry)                        !Display the new control
  ELSIF Ctl:Code = 5
   CREATE(FEQ, CREATE:text)
   UseVarText1 &= NEW(STRING(10000))
   FEQ{PROP:use} = UseVarText1
   GETPOSITION(?Ctl:Code,X,Y,Width,Height)
   FEQ{PROP:Xpos} = X + Width + 40    !Set x position
   FEQ{PROP:Ypos} = Y + 5             !Set y position
   FEQ{PROP:width} = 300
   FEQ{PROP:height} = 100
   FEQ{PROP:Vscroll} = TRUE
   UNHIDE(FEQ)                        !Display the new control
  END
 OF ?OkButton
  BREAK
 OF ?CanxButton
  CLEAR(TestGroup)
  BREAK
 END
END
DISPOSE(UseVarText1)
CLOSE(Window)
RETURN

See Also:     CLONE , DESTROY , SETPOSITION , SETTARGET, UNHIDE

create_return_new_control_created_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1