Create a web style graphical user interface in the MFC programming (5)

xiaoxiao2021-04-02  223

Create a Dialog window with the Chtmldialog class to display HTML

In addition to the main window, most applications also need to create other session windows. These session windows may also require a very complex interface, not just in the appearance, but also the same response to user operations. So, it is necessary to use DHTML to design the user interface in these places. About how to use CView's derived class to display the content of the session window, Paul Dilascia in MSDN has provided us with a solution. After the CHTMLVIEW is improved in front, we now use CView's derived class chtmldialog to display the contents of the Dialog window. Chtmlclass will solve two problems for us: set the name and size of the Dialog window. The specific parameters will be indicated by the HTML page.

The use of the CHTMLDialog class:

♦ Insert Dialog into the resource file and display static elements in the Dialog interface (these elements will be replaced by the element of HTML), then create an MFC base class (derived from cDialog).

♦ A class (such as DLG4.h) is derived from Chtmldialog in the header file.

// inheriting the class from chtmldialogclass cdlg4: public chtmldialog {// constructionpublic:

♦ Make sure that the constructor of the base class Chtmldialog first runs (eg DLG4.cpp) when the constructor of derived CDLG4 is run.

CDLG4 :: CDLG4 (CWND * PPARENT / * = NULL * /): Chtmldialog (cdlg4 :: IDd, pparent, idr_html4, idc_static1) ///// {{AFX_DATA_INIT (CDLG4) // Note: The ClassWizard Will Add Member Initialization Here //}} AFX_DATA_INIT}

The CHTMLDialog class can also allow changing the size of the session box. Please see the two screenshots below.

I have seen the previous notes, it seems that all the questions are solved? No, there are two questions to leave some small troubles.

1. While the HTML format interface displayed in the window, the external attribute of the function setWindowlong setting window cannot take effect.

2. When the user changed the setting of IE, the program's interface will change after changing the display settings of the HTML format.

If most people can tolerate the first question, the second question is unacceptable. This will cause our program to show different appearances under different user IE settings.

For this second question, currently, there is already a higher solution called Advanced Hosting Interfaces (AHI). Ethan Akhgari provides us with a good example to introduce this better solution.

Translator "listening to the wind" Note:

I translated this master as a good article to be programmed to learn interface, but what I am willing to violate my English, maybe my translation does not understand. So attach the original address:

http://www.codeproject.com/dialog/web_gui.asp

转载请注明原文地址:https://www.9cbs.com/read-131411.html

New Post(0)