FIX: Enter/Leave Events Are Not Getting Fired in Code-Behind HTMLID: Q223370
|
When using Windows Foundation Classes (WFC) controls on a Web page, while it is possible to add OnEnter and OnLeave event handlers (delegates), the events do not actually fire, and the handler methods do not get called.
Microsoft has confirmed this to be a problem in versions of Microsoft Visual J++.
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:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
<HTML>
<BODY>
<P>
<OBJECT
classid=java:com.ms.wfc.html.DhModule
height=0
width=0 ...
VIEWASTEXT>
<PARAM
NAME="CABBASE"
VALUE="WFCUICodeBehind.CAB">
<PARAM
NAME="__CODECLASS"
VALUE="Class1">
</OBJECT>
<OBJECT
classid=java:com.ms.wfc.ui.Button
height=50
id=Button1
name=wfcButton
style="HEIGHT: 50px;
LEFT: 0px;
TOP: 0px;
WIDTH: 250px"
width=219
VIEWASTEXT>
<PARAM NAME="data" VALUE="UEsBAAAEc2l6ZQsAE2NvbS5tcy53ZmMudWkuUG9pbnQIAAAA+gAAADIAAAAACHRhYkluZGV4BQAAAAAABHRleHQJABhXRkMgQnV0dG9uIERyYWcgYW5kIERyb3AAAA==">
</OBJECT>
<!-- Insert HTML here -->
</P>
</BODY>
</HTML>
import com.ms.wfc.html.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.om.*;
import com.ms.com.*;
import com.ms.wfc.app.*;
public class Class1 extends DhDocument
{
Button wfcButtonDragDrop;
Button wfcButtonDynamic;
EventHandler enter = new EventHandler(onEnter);
EventHandler leave = new EventHandler(onLeave);
EventHandler mEnter = new EventHandler(onMEnter);
EventHandler mLeave = new EventHandler(onMLeave);
public Class1()
{
initForm();
wfcButtonDynamic = new Button();
wfcButtonDynamic.setSize(250, 50);
wfcButtonDynamic.setText("WFC Button Dynamic");
wfcButtonDynamic.addOnEnter(enter);
wfcButtonDynamic.addOnLeave(leave);
wfcButtonDynamic.addOnMouseEnter(mEnter);
wfcButtonDynamic.addOnMouseLeave(mLeave);
wfcButtonDynamic.addOnClick(new EventHandler(onClick));
DhComponentWrapper bwrap = new DhComponentWrapper(wfcButtonDynamic);
bwrap.setSize(250, 50);
add(bwrap);
}
public void dispose()
{
super.dispose();
}
private void initForm()
{
}
protected void onDocumentLoad(Object sender, Event e)
{
//DhElement tmp = this.findElement("wfcButton");
//ClassCastException because IHTMLElement is not
//exposed for WFC Controls
IHTMLDocument2 doc = (IHTMLDocument2)getPeer();
IHTMLElementCollection all = doc.getAll();
wfcButtonDragDrop = (Button)all.item(new Variant("wfcButton"),
new Variant(0));
wfcButtonDragDrop.addOnEnter(enter);
wfcButtonDragDrop.addOnLeave(leave);
wfcButtonDragDrop.addOnMouseEnter(mEnter);
wfcButtonDragDrop.addOnMouseLeave(mLeave);
}
private void onEnter(Object source, Event e)
{
((Button)source).setText("Enter");
}
private void onLeave(Object source, Event e)
{
((Button)source).setText("Leave");
}
private void onMEnter(Object source, Event ev)
{
((Button)source).setText("Mouse Enter");
}
private void onMLeave(Object source, Event ev)
{
((Button)source).setText("Mouse Leave");
}
private void onClick(Object source, Event ev)
{
Button b1 = new Button();
b1.setDock(ControlDock.TOP);
b1.addOnEnter(enter);
b1.addOnLeave(leave);
b1.addOnMouseEnter(mEnter);
b1.addOnMouseLeave(mLeave);
Button b2 = new Button();
b2.addOnEnter(enter);
b2.addOnLeave(leave);
b2.addOnMouseEnter(mEnter);
b2.addOnMouseLeave(mLeave);
b2.setDock(ControlDock.BOTTOM);
Form f = new Form();
f.setBackColor(Color.WHITE);
f.setSize(400, 400);
f.add(b1);
f.add(b2);
Application.run(f);
}
}
For more information on the IHTMLDocument2 interface, see the MSDN Online Web Workshop, or search the MSDN index for "IHTMLDocument2."
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Robert LaCasse, Microsoft Corporation
Additional query words:
Keywords : kbservicepack kbActiveX kbCOMt kbCtrlCreate kbide kbJava kbJavaVM KbUIDesign kbVJ600fix kbWFC kbGrpJava kbVS600sp2 kbVS600SP1 kbVS600sp3fix
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: June 22, 1999