<< Click to Display Table of Contents >>
Script to Create and Place Objects on a Grid |
The next script references an hpXGridCalc object and creates up to 9 (nine) hpLinkIcon-type objects, placing them on the grid defined in an hpXGridCalc object. After reaching the limit of 9 (nine) objects, these ones are deleted and counting is then restarted.
Sub hpCommandButton1_OnEventClick()
Set gridCalc = Screen.Item("hpXGridCalc1")
With gridCalc
'Defines initial coordinates
Xini = .X
Yini = .Y
'Deletes grid objects
'and restarts Index counting
If .Index > (.Columns * .Rows) Then
.Index = 1
For Each obj In Screen
If InStr(obj.Name,"hpLinkIconTestGridA") <> 0 Then
Screen.DeleteObject(obj.Name)
End If
Next
End If
'Creates an hpLinkIcon-type object
'already placed on the grid
Set elm = Screen.AddObject("hpLinkIcon", False, "hpLinkIconTestGridA")
elm.X = Xini + .Xindex
elm.Y = Yini + .Yindex
elm.IconName = "hpIcon" & CStr(.Index)
elm.Activate()
elm.BringToFront()
'Points Index to the next object to create
.Index = .Index + 1
End With
End Sub