FIX: AlwaysOnTop Property Always Returns .F. For TopLevel Forms (194612)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q194612

SYMPTOMS

You can use the AlwaysOnTop property of a Visual FoxPro form in conjunction with a TopLevel form to create an application that prevents other windows from covering the applications window. Changing the AlwaysOnTop property at run-time changes the behavior of the form, but querying the property value always returns .F. This behavior only exists when the ShowWindow property of the form is set to 2 - As TopLevel Form.

RESOLUTION

You can use a custom property and an AlwaysOnTop Assign method to work around this problem. The following code uses a custom form property called AlwaysOnTop_Actual to store the actual setting of the AlwaysOnTop property of the form. The value of this custom property changes in the AlwaysOnTop_Assign method:
   PUBLIC ox
      ox = NewObject("test")
      ox.Show
      ?ox.AlwaysOnTop_Actual
      ox.AlwaysOnTop = .F.
      ?ox.AlwaysOnTop_Actual
      ox.AlwaysOnTop = .T.
      ?ox.AlwaysOnTop_Actual

   DEFINE CLASS test AS form
      ShowWindow = 2
      AlwaysOnTop = .T.
      AlwaysOnTop_Actual = .T.

      PROCEDURE AlwaysOnTop_Assign
         LPARAMETERS vNewVal
         This.AlwaysOnTop_Actual = vNewVal
         THIS.AlwaysOnTop = m.vNewVal
      ENDPROC

   ENDDEFINE
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed

MORE INFORMATION

Steps to Reproduce Behavior

Run the following program code:
   PUBLIC ox
      ox = NewObject("test")
      ox.Show
      ?ox.AlwaysOnTop
      ox.AlwaysOnTop = .F.
      ?ox.AlwaysOnTop
      ox.AlwaysOnTop = .T.
      ?ox.AlwaysOnTop

   DEFINE CLASS test AS form
      ShowWindow = 2
      AlwaysOnTop = .T.
   ENDDEFINE
				
Note the querying the AlwaysOnTop property always returns .F.

Modification Type:MinorLast Reviewed:3/7/2005
Keywords:kbBug kbfix kbVS600sp3fix KB194612