PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Mark Strickland on August 27, 2007, 01:00:02 AM

Title: Control Position Calculation
Post by: Mark Strickland on August 27, 2007, 01:00:02 AM
I have written a very generalized calendar popup and need to calculate the position of where to popup the form based on a text field that holds the date.  The FF function to get the position of a control gives it relative to the form where the control resides.  I have an application with tabs within tabs and it seems that calculating where to popup the form is not easy to make generalized.  The tabs themselves is not included when the FF function returns the position of a control.

Is there an easy way to calculate the relative position of a control on a form relative to the outermost form when forms are nested on forms using tabs?  This is necessary since to make the popup modal you must specify the top level form as the parent to the popup.

Thanks.
Title: Re: Control Position Calculation
Post by: Marc Van Cauwenberghe on August 27, 2007, 04:54:42 AM
Hello Mark

have you had a look at http://planetsquires.com/support/index.php?topic=2295.0 (http://planetsquires.com/support/index.php?topic=2295.0)

Marc
Title: Re: Control Position Calculation
Post by: TechSupport on August 27, 2007, 08:46:59 AM
Hi Mark,

Follow Marc's link for determining relative positioning. If you want to know what the top level window is for a deeply nested control then try code like the following:


Function GetTopLevelWindow( ByVal hWnd As DWord ) as DWord

  ' Determine the top level window of the specified control
  WHILE ISTRUE (GetWindowLong(hWnd, %GWL_STYLE) AND %WS_CHILD)
    IF ISTRUE (GetWindowLong(hWnd, %GWL_EXSTYLE) AND %WS_EX_MDICHILD) THEN EXIT LOOP
    hWnd = GetParent(hWnd)
  WEND

  FUNCTION = hWnd

End Function