Microsoft KB Archive/317499

= BUG: Mouse Clicks Do Not Work on a Scrollable SDI Form with a Docked Toolbar =

Article ID: 317499

Article Last Modified on 5/16/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition

-



This article was previously published under Q317499



SYMPTOMS
If you create a top-level (SDI) form in Visual FoxPro 6.0 or 7.0, mouse clicks on controls on the form may seem to be ignored. This problem may occur if the form is scrollable (with a ScrollBars property of more than 0), the form contains a toolbar, and the toolbar is docked to the top of the form.



RESOLUTION
To work around this problem:  Set the ScrollBars property of the form to 0.  Build a parent SDI form that contains a child MDI form (ShowWindow = 1 in the top-level form) and the toolbar. Configure the child form so that it has no title bar or border, and is maximized. In the Activate of the parent form, create the toolbar and child form. Because the child form is maximized and has no border or title bar, it seems as if there is only one form. The problem that is described in this article does not occur if the toolbar is docked to the top because it is actually docked in the parent form instead of the child form (which contains the controls).

The following sample code demonstrates this workaround: *--- PUBLIC oform1
 * Sample workaround code from Microsoft Knowledge Base
 * article Q317499.

oform1=NEWOBJECT(&quot;frmPARENT&quot;) oform1.SHOW RETURN

DEFINE CLASS frmPARENT AS FORM TOP = 21 LEFT = 34 HEIGHT = 235 WIDTH = 422 SHOWWINDOW = 2 CAPTION = &quot;Form1&quot; NAME = &quot;Form1&quot; mytoolbar = .F.    frmChild = .F.

PROCEDURE ACTIVATE IF VARTYPE(THIS.mytoolbar) != &quot;O&quot; THIS.mytoolbar = NEWOBJECT(&quot;testtoolbar&quot;) THIS.mytoolbar.DOCK(0) THIS.mytoolbar.VISIBLE = .T.              THIS.frmChild = NEWOBJECT(&quot;frmChild&quot;) THIS.frmChild.VISIBLE=.T.         ENDIF ENDPROC ENDDEFINE



DEFINE CLASS frmChild AS FORM TOP = 0 LEFT = 0 HEIGHT = 344 WIDTH = 428 SHOWWINDOW = 1 SCROLLBARS = 3 BORDERSTYLE = 0 CAPTION = &quot;&quot; TITLEBAR = 0 WINDOWSTATE = 2 NAME = &quot;Form1&quot;

ADD OBJECT pageframe1 AS PageFrame WITH ; PAGECOUNT = 2, ; TOP = 72, ; LEFT = 72, ; WIDTH = 241, ; HEIGHT = 169, ; NAME = &quot;Pageframe1&quot;, ; Page1.CAPTION = &quot;Page1&quot;, ; Page1.NAME = &quot;Page1&quot;, ; Page2.CAPTION = &quot;Page2&quot;, ; Page2.NAME = &quot;Page2&quot;

PROCEDURE CLICK WAIT WINDOW &quot;ChildForm Click!&quot; NOWAIT ENDPROC ENDDEFINE



DEFINE CLASS testtoolbar AS ToolBar CAPTION = &quot;Toolbar1&quot; HEIGHT = 28 LEFT = 0 TOP = 0 WIDTH = 33 SHOWWINDOW = 1 NAME = &quot;testtoolbar&quot;

ADD OBJECT command1 AS CommandButton WITH ; TOP = 3, ; LEFT = 5, ; HEIGHT = 22, ; WIDTH = 23, ; CAPTION = &quot;&quot;, ; NAME = &quot;Command1&quot; ENDDEFINE 



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



Steps to Reproduce the Problem
If the form is scrollable (the ScrollBars property is anything but 0) and the toolbar is docked at the top, clicking directly on the form controls is ignored. If you click next to the controls, you may be able to find and use the controls. However, three-dimensional effects (such as depressing a command button) do not work, and you cannot switch pages in a PageFrame. The keyboard continues to work correctly for all controls in the following sample code.

If you undock the toolbar or dock it anywhere but at the top, you can use the mouse on the controls. If you dock the toolbar at the top again, the problem returns.  Add the following code to a new program (.prg) file in Visual FoxPro 6.0 or 7.0, and then run the program. When the form appears, a toolbar is docked to the top. Click any of the controls on the form and note that the clicks are ignored.  Toggle the MakeScrollable variable near the top of the code and then run the program again to see and resolve the problem:

MakeScrollable = .T. (Form.ScrollBars = 3) --> Problem exists

MakeScrollable = .F. (Form.ScrollBars = 0) --> No problem

PUBLIC MakeScrollable, ; oform1 MakeScrollable = .T.
 * ~ Toggle this to see and resolve the problem:
 * ~ Form.Scrollbars > 0 - Problem exists
 * ~ Form.Scrollbars = 0 - No problem

oform1=NEWOBJECT(&quot;form1&quot;) oform1.SHOW RELEASE ALL RETURN



DEFINE CLASS form1 AS form

Top = 35 Left = 66 Height = 333 Width = 441 ShowWindow = 2 ScrollBars = 3 mytoolbar = .F.    Caption = &quot;Form1&quot; Name = &quot;form1&quot;

ADD OBJECT pageframe1 AS PageFrame WITH ; PageCount = 2, ; Top = 36, ; Left = 0, ; Width = 332, ; Height = 218, ; Name = &quot;Pageframe1&quot;, ; Page1.Caption = &quot;Page1&quot;, ; Page1.Name = &quot;Page1&quot;, ; Page2.Caption = &quot;Page2&quot;, ; Page2.Name = &quot;Page2&quot;

ADD OBJECT command1 AS CommandButton WITH ; Top = 48, ; Left = 336, ; Height = 27, ; Width = 84, ; Caption = &quot;Command1&quot;, ; Name = &quot;Command1&quot;

ADD OBJECT combo1 AS ComboBox WITH ; Height = 24, ; Left = 336, ; Top = 84, ; Width = 100, ; Name = &quot;Combo1&quot;

ADD OBJECT list1 AS ListBox WITH ; Height = 170, ; Left = 336, ; Top = 120, ; Width = 100, ; Name = &quot;List1&quot;

ADD OBJECT check1 AS CheckBox WITH ; Top = 276, ; Left = 36, ; Height = 17, ; Width = 60, ; Caption = &quot;Check1&quot;, ; Name = &quot;Check1&quot;

ADD OBJECT commandgroup1 AS CommandGroup WITH ; ButtonCount = 2, ; Value = 1, ; Height = 66, ; Left = 120, ; Top = 264, ; Width = 94, ; Name = &quot;Commandgroup1&quot;, ; Command1.Top = 5, ; Command1.Left = 5, ; Command1.Height = 27, ; Command1.Width = 84, ; Command1.Caption = &quot;Command1&quot;, ; Command1.Name = &quot;Command1&quot;, ; Command2.Top = 34, ; Command2.Left = 5, ; Command2.Height = 27, ; Command2.Width = 84, ; Command2.Caption = &quot;Command2&quot;, ; Command2.Name = &quot;Command2&quot;

ADD OBJECT edit1 AS EditBox WITH ; Height = 53, ; Left = 228, ; Top = 264, ; Width = 100, ; Name = &quot;Edit1&quot;

PROCEDURE Activate THIS.mytoolbar = NEWOBJECT(&quot;testtoolbar&quot;) THIS.mytoolbar.DOCK(0) THIS.mytoolbar.VISIBLE = .T.    ENDPROC

ENDDEFINE



DEFINE CLASS testtoolbar AS ToolBar CAPTION = &quot;Toolbar1&quot; HEIGHT = 28 LEFT = 0 TOP = 0 WIDTH = 33 SHOWWINDOW = 1 NAME = &quot;testtoolbar&quot;

ADD OBJECT command1 AS CommandButton WITH ; TOP = 3, ; LEFT = 5, ; HEIGHT = 22, ; WIDTH = 23, ; CAPTION = &quot;&quot;, ; NAME = &quot;Command1&quot; ENDDEFINE </li></ol>

Keywords: kbcodesnippet kbdesigner kbprb kbctrl KB317499

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.