Display HTML format with a ChtmlView class
We need to make some changes in the HTML code in the program interface, allowing them to look slightly different from IE.
It is easy to display HTML format in the MFC program. Just we need to call the ChtmlView class to complete this work. First we have to create a new "MFC AppWizard (EXE)" project, select a single document structure view and open Multi-Document Document View Structure Support. Then create and set the ChtmlView class to the base class in the Class Wizard. Finally, add the page of the HTML format to the system resource.
In order to make our web interface look more like a program interface rather than the IE window, the code for the HTML page must do some necessary modifications.
♦ Set the color of the HTML background to the color of the standard Windows application background.
♦ Disable the right-click menu of the HTML page unless the right-click menu used in the Editbox box.
♦ Prohibiting the text in the HTML page is in the mouse box, like, the text exceptions in the Editbox box.
♦ To change the shape when the mouse pointer is static text, in IE, the mouse pointer will become a "work" shape when the mouse pointer is static text, and this is true in the Editbox box. This phenomenon in Windows applications should be avoided.
The following code achieves the above four items:
// forbid user's mouse selecting for the content
// (Allow Text Selection in Editbox Only)
Function Onsect1 () {
IF (window.event.srcelement.tagname! = "infut") {
Window.Event.ReturnValue = false;
WINDOW.EVENT.CANCELBBBE = true;
}
}
// FORBID IE Context Menu
// (Allow In Editbox Only)
// (if The real context menu must be shown - Advanceв Hosting
// Interfaces Must Be Used)
Function onContextMenu () {
IF (window.event.srcelement.tagname! = "infut") {
Window.Event.ReturnValue = false;
WINDOW.EVENT.CANCELBBBE = true;
Return False;
}
}
// Install Context Menu and Mark Handlers ON HTML Loading.
//
Function online ()
{
// Forbid Cursor Change (Except "Input"
// entry box and "a" hyperlink) for html text.
Var objs = document.All;
For (i = 0; i // "Input" entry box and "a" HyperLink IF (Objs (i) .tagname! = "Input" && Objs (i) .tagname! = "a") Objs (i) .style.cursor = "default"; // Event Handler - Content SelectionDocument.onlection.OnSelectStart = Onsect1; // Event Handler - Context Menu Document.onContextMenu = onContextMenu; } Script> Leftmargin = 0 TopMargin = 0 Right Margin = 0 bottommargin = 0 Style = "Background-Color: ButtonFace;"> // The Html Background Color Will Be As in Windows Applications ... With the above method, we can use HTML to implement our program interface. The menu, toolbar, and static lines have kept down. After all, we are not to force all traditional controls. In this way, we gain greater flexibility.