PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Control Position Calculation  (Read 239 times)

Mark Strickland

  • Guest
Control Position Calculation
« on: August 27, 2007, 12:30: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.
Logged

Marc Van Cauwenberghe

  • Guest
Re: Control Position Calculation
« Reply #1 on: August 27, 2007, 04:24:42 AM »

Hello Mark

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

Marc
Logged

TechSupport

  • Guest
Re: Control Position Calculation
« Reply #2 on: August 27, 2007, 08:16: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:

Code: [Select]
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   
Logged