realbasic-nug
[Top] [All Lists]

Re: Window.Left and WIndow.Top incorrect

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: Window.Left and WIndow.Top incorrect
From: Greg O'Lone <rbnuglist@stretchedout.com>
Date: Wed, 29 Jul 2009 14:29:11 -0400
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <848CD0ED-93FB-4BFC-8E9C-2F4334388B06@verizon.net>
References: <048D0EFB-D608-4802-99E5-46187B30F447@stretchedout.com> <848CD0ED-93FB-4BFC-8E9C-2F4334388B06@verizon.net>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
On Jul 29, 2009, at 10:42 am, Karen wrote:


On Jul 28, 2009, at 10:16 PM, Greg O'Lone wrote:

I'm attempting to create an autocomplete menu for an editfield (2009r2.1) that appears at the text insertion point and having a problem with the placement of the menu. It seems that when I call TrueWindow.Left and TrueWindow.Top from a subclass of an editfield, I am not getting the coordinates of the window, but the window behind it.

True Window is the wrong approach because it won't work for nested container controls... Put this in a module to calulate ScreenPosition of any RectControl:

Sub ScreenPosition(Extends RectCtrl as RectControl, ByRef ScreenTop as integer, ByRef ScreenLeft as Integer)
 Dim Container as Window

 ScreenTop = RectCtrl.Top
 ScreenLeft = RectCtrl.Left
 Container = RectCtrl.Window

 While  Container IsA ContainerControl
   ScreenTop = ScreenTop + Container.Top
   ScreenLeft = ScreenLeft + Container.Left
   Container = ContainerControl(Container).Window
 Wend

 ScreenTop = ScreenTop + Container.Top
 ScreenLeft = ScreenLeft + Container.Left
End Sub

Karen,

For the most part, I don't use ContainerControls if I can get away with it... and your code does NOT take nested controls into account like controls within a GroupBox or a TabPanel.

Greg

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>