Microsoft KB Archive/191454

= PRB: Event Procedures May Be Executed for Unhandled Events =

Article ID: 191454

Article Last Modified on 1/8/2003

-

APPLIES TO


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

-



This article was previously published under Q191454



SYMPTOMS
When adding a control to a DHTML page in Visual Basic 6.0, code from other events may be executed.



CAUSE
In regular Visual Basic applications, if code is not written for an event, no other code will be executed when the event fires.

In Visual Basic 6.0 DHTML applications, events are shared between the parent object and the child object.

This is called Event Bubbling and is a property of the DHTML object model.



RESOLUTION
To obtain the same behavior that Visual Basic exhibits, set the cancelBubble property of the Event object.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a DHTML Application Project in Visual Basic. Open the DHTMLPage1 DHTML Designer. Insert a Table onto the page. Insert a Button into one of the cells. Make sure that the Button is in the table cell by checking the document pane.  Add the following code to the Table1_onclick event: MsgBox "Table Clicked" </li>  Add the following code to the Button1_onclick event: MsgBox "Button Clicked" </li> Run the project. Note that when the button is clicked, the Button1 MsgBox appears. Then, after clicking OK, the Table1 MsgBox appears.

NOTE: It is easier to insert the Button into the Table cell with Absolute Positioning turned off.</li></ol>

The following line of code will disable Event Bubbling. It can be placed anywhere inside your DHTML project. BaseWindow.event.cancelBubble = True Conversely, you can re-enable Event Bubbling by setting the property to False.

<div class="references_section">