I do not know if this is a bug or this is what should happen but this code:[code] Dim item As RectControl
Dim newTop As Integer
’ Move Top
’ Set all LockBottom back to original value
For ctr As Integer = 0 To Me.Window.ControlCount-1
If Me.Window.Control(ctr) IsA RectControl Then
item = RectControl(Me.Window.Control(ctr))
If MoveControl(item) And Not (item Is Me) Then
newTop = item.Top + adjust
item.Top = newTop
item.LockBottom = thisControl(ctr)
Else
item.Refresh
End If
End If
Next
[/code]
‘Me.Window’ only seems to work with windows but it does not seem to work with ContainerControls. How would I go about getting the ContainerControl if the parent of the control is a ContainerControl and if it is a window then it should find the window. So basically I am trying to get the parent whether it is a window or a ContainerControl. Thanks in advance.
For ctr As Integer = 0 To ControlCount-1 // no need for Me.Window. in front of ControlCount
If Control(ctr) IsA RectControl Then // same here
... // now includes ContainerControls (as EmbeddedWindowControl, a subclass of Canvas)
If you want to treat ContainerControls separately do this:
For ctr As Integer = 0 To ControlCount-1
If Control(ctr) IsA EmbeddedWindowControl Then
... // handle ContainerControls here
ElseIf Control(ctr) IsA RectControl Then
...// handle RectControls here
[quote=28585:@Lukas Joerg]For ctr As Integer = 0 To ControlCount-1 // no need for Me.Window. in front of ControlCount
If Control(ctr) IsA RectControl Then // same here
... // now includes ContainerControls (as EmbeddedWindowControl, a subclass of Canvas)
If you want to treat ContainerControls separately do this:
For ctr As Integer = 0 To ControlCount-1
If Control(ctr) IsA EmbeddedWindowControl Then
... // handle ContainerControls here
ElseIf Control(ctr) IsA RectControl Then
...// handle RectControls here
[/quote]
Thanks. If this works then that is excellent.
[quote=28585:@Lukas Joerg]For ctr As Integer = 0 To ControlCount-1 // no need for Me.Window. in front of ControlCount
If Control(ctr) IsA RectControl Then // same here
... // now includes ContainerControls (as EmbeddedWindowControl, a subclass of Canvas)
If you want to treat ContainerControls separately do this:
For ctr As Integer = 0 To ControlCount-1
If Control(ctr) IsA EmbeddedWindowControl Then
... // handle ContainerControls here
ElseIf Control(ctr) IsA RectControl Then
...// handle RectControls here
[/quote]
[quote=28585:@Lukas Joerg]For ctr As Integer = 0 To ControlCount-1 // no need for Me.Window. in front of ControlCount
If Control(ctr) IsA RectControl Then // same here
... // now includes ContainerControls (as EmbeddedWindowControl, a subclass of Canvas)
If you want to treat ContainerControls separately do this:
For ctr As Integer = 0 To ControlCount-1
If Control(ctr) IsA EmbeddedWindowControl Then
... // handle ContainerControls here
ElseIf Control(ctr) IsA RectControl Then
...// handle RectControls here
[/quote]
I do not think you understand what I am trying to achieve. I am not searching for ContainerControls. But I am searching for RectControls from within a ContainerControl but Me.Window does not seem to handle ContainerControls. Thanks in advance.
I don’t understand why you insist on using Me.Window instead of Self.Window (which can be shortened to Window - which was my suggestion in my answer). Self.Window will always work, Me.Window only if Me is a RectControl.
But should you have a hierarchy of ContainerControls (ContainerControl on top of another one ), you have to use TrueWindow instead of Window.
[quote=28660:@Lukas Joerg]I don’t understand why you insist on using Me.Window instead of Self.Window (which can be shortened to Window - which was my suggestion in my answer). Self.Window will always work, Me.Window only if Me is a RectControl.
But should you have a hierarchy of ContainerControls (ContainerControl on top of another one ), you have to use TrueWindow instead of Window.[/quote]
Thanks. The code is not mine so I do not know know why the coder did not write that. I am very grateful that you took part in this discussion. Thanks lots.
[quote=28660:@Lukas Joerg]I don’t understand why you insist on using Me.Window instead of Self.Window (which can be shortened to Window - which was my suggestion in my answer). Self.Window will always work, Me.Window only if Me is a RectControl.
But should you have a hierarchy of ContainerControls (ContainerControl on top of another one ), you have to use TrueWindow instead of Window.[/quote]
It does not seem to work. Do you realise I am trying to access the Container of a control from within the code of a class.
Well, in your code you using the Me keyword, which indicates that the code is running in an event handler of some control in a window. You can use Me in other places (it will refer to Self then), but for clarity I’m never using Me outside of an event handler and I also would recommend that to anybody else.
What do you mean by “… from within the code of a class.”
[quote=30490:@Lukas Joerg]Well, in your code you using the Me keyword, which indicates that the code is running in an event handler of some control in a window. You can use Me in other places (it will refer to Self then), but for clarity I’m never using Me outside of an event handler and I also would recommend that to anybody else.
What do you mean by “… from within the code of a class.”[/quote]
I checked the docs. And no I can distinguish between me and self, i think. So what do I write instead of ‘Me.Window’. For example ‘Me.ContainerControl’ (if that would apply to any kind of containercontrol, from tabpanel, pagepanel, window, to just a normal ‘ContainerControl’), ‘Me.Parent’.
I searched through the docs to find something about taking into acount the distance of the containercontrol from the window’s edge. I think that might help me. Thankyou.