Control Position Calculation

Started by Mark Strickland, August 27, 2007, 01:00:02 AM

Previous topic - Next topic

Mark Strickland

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.

Marc Van Cauwenberghe


TechSupport

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