Microsoft KB Archive/191859

= BUG: MonthView Control Prevents CommandButton Click Event =

Article ID: 191859

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q191859



SYMPTOMS
A Visual Basic project contains a MonthView control and a CommandButton. When the date is changed on the MonthView control followed by clicking the CommandButton, the CommandButton gets the focus but the CommandButton's Click event is not executed. If you click the CommandButton a second time, the Click event executes normally.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a reference to the Microsoft Windows Common Controls-2 6.0 by completing the following steps:  From the Project menu, select Components to display the Components dialog box. From the Controls tab, check Microsoft Common Controls-2 6.0. Click OK to close the dialog box. </li> Add a MonthView control and a CommandButton to Form1.</li>  Copy the following to the Code window of Form1: Option Explicit

Private Sub Command1_Click MsgBox "CommandButton Clicked" End Sub

</li> On the Run menu, select Start, or press the F5 key to start the program. Click the CommandButton. A message box appears. Click OK to dismiss the message box.</li> Select a day in the MonthView control and then click the CommandButton. The CommandButton gets the focus but the Click event is not executed. When you click the CommandButton a second time, the Click event occurs and you see the message box.</li></ol>

WORKAROUND
Add the following code to Form1: Private mvHasFocus As Boolean

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If mvHasFocus Then mvHasFocus = False Call Command1_Click End If End Sub

Private Sub MonthView1_GotFocus mvHasFocus = True End Sub

Keywords: kbbug kbctrl KB191859

-

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

© Microsoft Corporation. All rights reserved.