Analysis of Windows CE Browser source

Source: Internet
Author: User
Tags message queue thread

A lot of netizens have asked questions about developing browsers. Can understand that most of the products based on CE now have the function of browsing on the Internet. Ce also provides two kinds of IE browser source code. A iesample, another kind of iesimple. Their storage path is under the%_winceroot%\public\ie\oak. The difference is that iesample is CE under IE Standard version of the source code, has a toolbar, status bar, Address bar, as well as Internet options, favorites and so on. Almost the same as PC windows IE. And Iesimple is the mini version, only the basic Iwebbrowser control, the user interface only full screen of the Web page, by default with shortcut keys to operate. I earlier on the source of iesimple analysis, because I know little about OLE, so in the analysis process can not 100% grasp the source code, fortunately this does not affect my overall analysis of the iesimple. Believe that users have read these two articles (and a configuration), if you want to base on the Iesimple source code to develop their own browser is much easier. The reason for choosing iesimple is because its source code is more concise, only the implementation of the main functions, no collection of code, on this basis, we want to join the function and interface is easier. The main code for Iesimple and Iesample is basically the same. The following figure shows the basic process of iesimple, and the configuration of IE will be explained in the next article.

Iesimple has only two. h files and one. cpp file. Class Cmainwnd is declared in Mainwnd.h, and in many member variables of class Cmainwnd, _hwnd save Cmainwnd Window handle, _pbrowser Save interface IWebBrowser2 Pointer, _ Hwndbrowser saves the browser window handle and _rcwnd the Cmainwnd window size. These variables are always present in the code, so this is proposed here. The functions of each function mentioned in the above diagram are explained below:

The WinMain function finds the stack size of the thread that created the Cmainwnd window first in a specific location in the registry. If this value is appropriate, then the value of the stack is used when creating the thread. Then register the Cmainwnd window class, then call PeekMessage to create the message queue, and then invoke the HANDLENEWWINDOWS2 function, which enters the while loop at the end of the function execution, and the contents of the loop body is the wait function, Because each thread makes the event object Ghexitevent in a signaled state before it ends, the main thread ends when all created threads end. For the HANDLENEWWINDOWS2 function, it is executed at least once throughout the iesimple run. Whenever you open a page in a new window, it is executed once. The HandleNewWindow2 function first creates a Cmainwnd object, then increments the global variable that records the number of threads, then creates a new thread, and the thread function is NewWindow. For the NewWindow function, it initializes the COM library and then calls the Cmainwnd Create member function. The GetMessage function is then called to collect messages and process them. End processing when window exits. For the Create member function, it calls the CreateWindowEx function to create a window and a progress bar window, and then calls the Createbrowser function to create a browser window, and finally calls Handlecommand (Id_fullscreen, 0) Full screen display of Web page content. For the Createbrowser function, it first calls the Getproxyoption function to get the Internet connection Agent option, and then calls the CoCreateInstance function to create the WebBrowser object. It then invokes the Setclientsit setting WebBrowser client, then activates the Iwebbrowser control, then saves the pointer to the interface IWebBrowser2 and saves the window handle that participates in the WebBrowser local activation.

Other functions Handlecommand handle user commands such as forward, backward, home, refresh, stop, and so on. The execution of a command is actually a call to the IWebBrowser2 interface function. The Mainwndproc function is a CMAINWND message handler function. The Openurldlgproc function is the message handler function for the Open dialog box. There are two more functions to explain in the next article.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.