Duplicate
Duplicate()
Duplicate menu item as separator
Returns result of type OBJECT or SYM
Applies to: MenuItem
Introduced in KCML version 5.02
Duplicate(iLeft, iTop)
Duplicate control
iLeft | Integer | Horizontal position of new control |
---|---|---|
iTop | Integer | Vertical position of new control |
Returns result of type OBJECT or SYM
Applies to: Generic , Picture Object
Introduced in KCML version 5.02
Duplicate(iLeft, iTop, sTitle$)
Duplicate control with title
iLeft | Integer | Horizontal position of new control |
---|---|---|
iTop | Integer | Vertical position of new control |
sTitle$ | String | Text$ property of new control |
Returns result of type OBJECT or SYM
Applies to: Generic
Introduced in KCML version 5.02
Duplicate(iLeft, iTop, sTitle$, iSymTabPage)
Duplicate control with title and tab page
iLeft | Integer | Horizontal position of new control |
---|---|---|
iTop | Integer | Vertical position of new control |
sTitle$ | String | Text$ property of new control |
iSymTabPage | Integer | SYM of tab page to which the control should be added |
Returns result of type OBJECT or SYM
Applies to: Generic
Introduced in KCML version 5.02
Duplicate(sText$)
Duplicate menu item
sText$ | String | Text of menu item |
---|
Returns result of type OBJECT or SYM
Applies to: MenuItem
Introduced in KCML version 5.02
Duplicate(sText$, iChildFlag)
Duplicate menu item with child flag
sText$ | String | Text of menu item |
---|---|---|
iChildFlag | Integer | Set if menu item should be created as child of existing item |
Returns result of type OBJECT or SYM
Applies to: MenuItem
Introduced in KCML version 5.02
Duplicate(sTitle$)
Duplicate tab page
sTitle$ | String | Text for new tab page |
---|
Returns result of type OBJECT or SYM
Applies to: TabbedItem
Introduced in KCML version 5.02
The Duplicate() method is used within the Create() event handler to duplicate a control to a new location on the current form. The CreateControl() method introduced in KCML 6.20 is a more powerful and flexible alternative and is to be preferred in applications that construct or modify their forms at runtime.
The parameters specify the new location of the control relative to the top left hand corner of the form. The optional string parameter allows the controls label to be changed. This is only relevant to controls that have text labels such as buttons and static text controls and can be blank if not applicable. The fourth optional parameter specifies the sym of a parent control. Tab pages can also be created using the Duplicate() tab control method which returns such a sym.
The method returns, depending on context, either a sym pointer or an OBJECT reference to the newly created control to allow the program to later reference the controls properties and methods.
For example, the following duplicates the control editControl1 and then modifies the controls properties:
newsym = .editControl1.Duplicate(10, 25) .*newsym.Type$ = "N-8.3" .*newsym.Text$ = Total
If the new control has a Text$ property this can be set using a third argument.
The Duplicate() method can also be used to create new tab pages and add controls to those pages as well as to duplicate menu options including child menus and separators.
It can also be used to create a picture object on the fly. Because picture objects are an abstraction and not actually part of the form, in this one case it is possible to use the Duplicate() method at run time after the Create() event as in the following example program.
- DEFFORM Form1()={.form,.form$,.Style=0x50c000c\ 4,.Width=330,.Height=228,.Text$="Form",.Id=\ 1024},{.ok,.button$,.Style=0x50010001,.Left=275,\ .Top=6,.Width=50,.Height=14,.Text$="OK",.__\ Anchor=5,.Id=1},{.cancel,.button$,.Style=0x50010\ 000,.Left=275,.Top=23,.Width=50,.Height=14,\ .Text$="Cancel",.__Anchor=5,.Id=2},{.help,.butto\ n$,.Style=0x50010000,.Left=275,.Top=44,.Wid\ th=50,.Height=14,.Text$="&Help",.__Anchor=5,.Id=\ 9},{.gridControl1,.kcmlgrid$,.Style=0x50010\ 030,.Left=18,.Top=22,.Width=230,.Height=178,.Id=\ 1000,.Rows=2,.Cols=2,.FixedRows=1,.Row1={.R\ ow=1,.Col=0,.RowHeight=82},.Row2={.Row=2,.Col=0,\ .RowHeight=66},.Col1={.Row=0,.Col=1,.ColWid\ th=80},.Col2={.Row=0,.Col=2,.ColWidth=84}},{.pic\ Control1,.Picture$,.Template=1} + DEFEVENT Form1.Create() END EVENT - DEFEVENT Form1.help.Click() a = .picControl1.Duplicate(0, 0) .*a.Filename$ = "d:/winnt/winnt.bmp" .gridControl1.Cell(2, 1).Picture = SYM(*a) END EVENT FORM END Form1 Form1.Open()
Menu
Here is an example showing how 3 items can be added:
newsym = .menu1.fileoption1.Duplicate("Open") newsym = .menu1.fileoption1.Duplicate("Close") newsym = .menu1.fileoption1.Duplicate("Print")
Would duplicate the menu option, fileoption1. While:
.menu1.fileoption1.Duplicate("Child 1", 0) .menu1.fileoption1.Duplicate("Child 2", 0)
would create a child menu for the duplicated option. Furthermore
.menu1.fileoption1.Duplicate()
would create a menu separator as if no argument is specified then a separator is created. The following are equivalent:
.menu.menuitem1.Duplicate() .menu.menuitem1.Duplicate("")
If the second argument is not specified, or is FALSE then the new menu item will appear at the same level and immediately after the existing menu item. The following are equivalent:
.menu.menuitem1.Duplicate("&New Item") .menu.menuitem1.Duplicate("&New Item", FALSE)
If the second argument is specified then it is a boolean value indicating whether the new item should be a child of the menu item (that is the menu item will produce a popup menu on which the new item will appear).
The result of each of these Duplicate() methods is the sym of the new menu item. This may also be used with the object notation. The following are ways of creating a "New" menu item on the file menu and adding a toolbar image:
newsym = .menu1.File.Duplicate("&New", TRUE) .menu1.newsym.picture = &.FileNew OBJECT new = .menu1.File.Duplicate("&New", TRUE) new.picture = &.FileNew
Events on duplicated menu items are returned to the menu item's event handler (and this includes duplicates of duplicates). It is possible to use the Sym property of menu items to determine which menu item was actually selected. Thus, using the above example
:IF (...Sym == newsym) REM New ... ENDIF IF (...Sym == new.sym) REM New ... ENDIF
Tab
For example this creates a new page and adds a button:
newsym = .tabControl1.Tab1.Duplicate("New page") .btnControl2.Duplicate(5, 12, "Click Me", newsym)
Note that the source control must be available on the previously duplicated tab.