On Feb 3, 2007, at 6:22 PM, Chris Halford wrote:
Why is that when i embed a ContainerControl in a window, its
contained controls left and top are relative to the window and not
the containerControl?
If I drag the ContainerControl in the window from the IDE, the
contained controls left and top are relative to the containerControl.
If i have the bad fortune of locking the right or the top of the
containerControl, the effects are even worse, the contained
controls left and top stay relative to... just wait for it, THE
ORIGINAL POSITION of the ContainerControl. Do I sound frustrated?
Can anyone help out there. Im thinking i'd like for
ContainerControls and there contained controls to act normally.
Their left and top should ALWAYS be relative to their parent window
( Window or ContainerControl).
Chris:
I am not sure what task you are trying to do within a Container, but
I also ran into problems referencing the local coordinates of the mouse
within the container, and again when I tried to reference the mouse
coordinates inside a rectControl within the container. It took me
a while
to understand the referencing used and when I finally did, I wrote a
couple of utility routines to assist me. Maybe these routines
will fix your problem, or by studying their code, you will find the
answer to your problem. (For readability, the line continuation
character (underscore) is used liberally).
I have verified that the controlMouse() functions returns the exact
mouse location within a canvas embedded inside a container control.
For example, if
you place a method called doSomethingAt (x, y) within a canvas object
inside a container, and you call this method with doSomethingAt
(controlMouseX (me), controlMouseY(me), these functions decode the
exact pixel inside the canvas where the mouse is hovering over.....
Hope this helps....
Mark Levinson, MD
Hutchinson, KS
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Protected Function containerMouseX() As integer
'returns the current mouse location relative to the containers
location within the window
return System.MouseX _ 'the mouse click
- self.left _ 'minus the
containers offset in the window
- self.window.left 'minus the window's
offset from the screen (global axis)
End Function
Protected Function containerMouseY() As integer
'returns the current mouse location relative to the containers
location within the window
return System.MouseY _ 'the mouse click
- self.top _ 'minus the
containers offset in the window
- self.window.top 'minus the window's offset
from the screen (global axis)
End Function
Protected Function controlMouseX(theControl as rectControl) As integer
'returns the current mouse location relative to a rectControl
within a container within a window
return System.MouseX _ 'the mouse click
- theControl.left _ 'minus the controls
offset in the container
- self.left _ 'minus the
containers offset in the window
- self.window.left 'minus the window's
offset from the screen (global axis)
End Function
Protected Function controlMouseY(theControl as rectControl) As integer
'returns the current mouse location relative to a rectControl
within a container within a window
return System.MouseY _ 'the mouse click
- theControl.top _ 'minus the controls offset
in the container
- self.top _ 'minus the
containers offset in the window
- self.window.top 'minus the window's offset
from the screen (global axis)
End Function
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>