在REALBasic中,如何遍历Window1中的所有对象?Window1及其所有子元素是否都有一些数组属性?另外,如何设置对象的自定义属性:例如Me.isFlamingo = true,提前谢谢!
发布于 2011-03-03 09:34:44
要遍历窗口上的控件,请使用如下代码:
ListBox1.DeleteAllRows
For i As Integer = 0 To Self.ControlCount-1
ListBox1.AddRow(Self.Control(i).Name)
Next(对于本例,请确保在窗口中至少添加一个ListBox。)
属性的设置就像你描述的那样: ObjectInstance.PropertyName。
如果您所处的对象已被拖到窗口中,则可以使用Me.PropertyName修改其属性。否则,您将使用对象名称。
发布于 2011-04-02 04:23:50
向内置类添加属性可以通过两种方式完成。更好的方法是子类化PushBustton类,并像处理任何自定义类一样将属性添加到子类中。另一种更丑陋的方法是使用一对重载函数,如下所示:
Function isFlamingo(Extends ByRef pb As PushButton) As Boolean
Dim flamingo As Boolean
//Do stuff to figure out if the PushButton is Flamingo-y
//and Return a Boolean based on the result
Return flamingo
End Function和:
Sub isFlamingo(Extends ByRef pb As PushButton, Assigns b As Boolean)
If b Then
//Do stuff that makes the PushButton flamingo-y
Else
//Do stuff that makes the PushButton not flamingo-y
End If
End Subhttps://stackoverflow.com/questions/5175333
复制相似问题