EVC development Example 3: browser window

Source: Internet
Author: User

EVC development Example 3: browser window

Someone has asked me questions about displaying GIF images. My answer is either to use a class dedicated to displaying GIF images abroad or to use the iwebbrowser COM component. I also said that I have used it to customize IE. In fact, Microsoft provides the source of CE's IEProgramThis component is used to implement various functions of IE. I am doing ie because the IE that comes with Windows CE does not meet our requirements in all aspects, so I wrote a browser that meets our requirements on the basis of the IE source program. This articleArticleInstead of explaining how to use a browser, you can use the iwebbrowser component to display GIF and jpg images. Of course, you can also display webpages. Making a browser is much more complicated than displaying images and webpages.
Most developers in the Pocket PC will be surprised, isn't there htmlview? How can I write it myself. Because the SDK in the kernel customized by Microsoft for the Pocket PC contains controls that support web browsing, but not in Windows CE. net. This requires self-implementation. Here I use a simulator for testing. The simulator can pass through the actual platform. The operation is basically the same.

1. Create a kernel with IE
You should be familiar with customizing a kernel in the simulator. I have mentioned it more than once in my previous articles. So here I will briefly explain how to customize the kernel. Step 1: Select "emulator: x86", and then select "Internet appliance" in "available configuration ". Next, select "Internet browser", step 5 select "Internet browser", step 6 remove all network options, and finally "done ". Add the environment variable "imgram64" before compilation, and select "emulator: x86 Win32 {wce emulator} release" to start compilation. After compilation, click "download/initialize"
Download the kernel and run it on the simulator. Click the IE shortcut icon on the desktop. If IE is displayed, the first step is successful.

2. Programming
I use EVC to compile this program separately. It is not written in petabytes. The Application Wizard that comes with Pb does not have the MFC option, so it is easier to compile it with EVC. After compilation, copy the program to the kernel directory and run it using Pb.
I will not explain the program in detail, but I will explain it in detail.Code. Call up EVC and use the Application Wizard to generate an MFC program. Assume that the project is named iegif. Select the single-document program as the first step, and select the language from the drop-down list. Step 2 check "Windows Sockets" and "ActiveX controls". The default value is for other steps.
Before using the iwebbrowser component, you must first include the header files required by the component. Add the following file names in "stdafx. H:

 
/// // # UNDEF _ urlmon_h __# include <urlmon. h> # UNDEF _ shlobj_h _ # include <shlobj. h> # UNDEF _ winnetwk _ # include <winnetwk. h> # UNDEF _ afxhtml_h __# include "afxhtml. h"

Add the following code to the ciegifview class declaration in the iegifview. h file:

 
Public: iwebbrowser2 * m_pbrowser; cwnd m_wndbrowser; // The Void navigate (cstring) container of iwebbrowser2; // call the navigate interface of iwebbrowser2

Initialize the pointer in the constructor of the ciegifview class:

 
Ciegifview: ciegifview () {m_pbrowser = NULL ;}

Define the following functions in the iegifview. cpp file:

Void ciegifview: navigate (cstring strurl) {colevariant empty; BSTR bstrurl = strurl. allocsysstring (); m_pbrowser-> navigate (bstrurl, colevariant (long) 0, vt_i4), empty );}

Define the message processing function in the iegifview. cpp file:

/// Response wm_createint ciegifview: oncreate (maid) {If (cview: oncreate (lpcreatestruct) {If (-1) Return-1; //////////////////////////////////////// ////////// rect rectclient; getclientrect (& rectclient); // display GIF in the entire area of the client // create the control if (! M_wndbrowser.createcontrol (clsid_webbrowser, null, ws_visible | ws_child, rectclient, this, visible) {destroywindow (); Return false;} // obtain the pointer lpunknown lpunk = cursor (); hresult hR = lpunk-> QueryInterface (iid_iwebbrowser2, (void **) & m_pbrowser); If (! Succeeded (HR) {m_pbrowser = NULL; m_wndbrowser.destroywindow (); destroywindow (); Return false;} return 0;} // response command on_command (id_opengif, onopengif) /// use a button or menu item. ID: id_opengifvoid ciegifview: onopengif () {cfiledialog DLG (true, null, null); If (DLG. domodal () = idcancel) {return;} navigate (DLG. getpathname ());}


Figure 1. gif

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.