REAL基本问题

发布于 2024-10-19 18:39:26 字数 113 浏览 1 评论 0原文

在 REALBasic 中,如何循环遍历 Window1 中的所有对象?是否存在 Window1 及其所有子项的数组属性?另外,如何设置对象的自定义属性:例如 Me.isFlamingo = true 提前致谢!

In REALBasic, how do I loop through all of the objects in Window1? Is there some array property of Window1 with all of its children? Also, how do you set custom properties of objects: e.g. Me.isFlamingo = true
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

锦爱 2024-10-26 18:39:26

可以通过两种方式向内置类(例如按钮)添加属性。更好的方法是子类化 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 Sub

Adding properties to a built-in class like a pushbutton can be done in two ways. The better way would be to subclass the PushBustton class and to add properties to the subclass like you would with any custom class. The other, somewhat uglier way would be to use a pair of overloaded functions like this:

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

And:

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 Sub
旧夏天 2024-10-26 18:39:26

要循环访问窗口上的控件,请使用如下代码:(

  ListBox1.DeleteAllRows

  For i As Integer = 0 To Self.ControlCount-1
    ListBox1.AddRow(Self.Control(i).Name)
  Next

对于本例,请确保向窗口中添加至少一个列表框。)

属性的设置方式与您所描述的一样:ObjectInstance.PropertyName。

如果您遇到已将对象拖到窗口中的情况,则可以使用 Me.PropertyName 修改其属性。否则,您将使用对象名称。

To iterate through the controls on a window, use code like this:

  ListBox1.DeleteAllRows

  For i As Integer = 0 To Self.ControlCount-1
    ListBox1.AddRow(Self.Control(i).Name)
  Next

(For this example, be sure to add at least one ListBox to the Window.)

Properties are set just like you describe: ObjectInstance.PropertyName.

If you are in the event of an object that has been dragged to the window, then you can modify its properties using Me.PropertyName. Otherwise you would use the object name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文