Customizing the Windows CE .NET User Interface, Part 2
Mike Hall
Microsoft Corporation
Steve Maillet
Entelechy Consulting
May 1, 2002
下載 Ieshell.exe.
下載 the IESHELL.exe sample file. (217 KB)
Last month we took a look at customizing certain user interface features of the Microsoft? Windows? CE .NET operating system. This month we extend this to cover building a custom shell using the Microsoft? Windows CE Internet Explorer. Of course, the same process could be used to create a custom shell using a stand-alone application.
定制shells
The Explorer shell provided with Platform Builder is a good general-purpose shell that allows users a great deal of flexibility, while maintaining a generally familiar look and feel. Many embedded devices require a more tightly controlled user experience; for example, HMI industrial controllers, self-service Kiosks, or possibly even the control system of the train I'm riding in as I write this. These types of systems require a custom shell that limits the device to a particular function or set of functions it was designed for. Fortunately, Windows CE was designed with this in mind, and allows you to use any application you want as the shell.
Let's look at some of the functionality a custom shell might need:
1. 在系統(tǒng)啟動時運行.
2. 向用戶提供一個界面(接口).
· 接受用戶收入(,并響應(yīng)).
· 向用戶顯示響應(yīng).
· 顯示某些操作的當(dāng)前狀態(tài).
3. Change modes/Tasks.
在系統(tǒng)啟動時運行shell
在系統(tǒng)啟動時運行shell是非常簡單的,只需要一個 注冊表項.The following extract from the registry shows how the standard shell (explorer.exe is loaded):
[HKEY_LOCAL_MACHINEinit]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00
內(nèi)核初始化之后,將掃描Init key 尋找"LaunchXX"形式的key,然后以數(shù)字順序裝載列在里面的應(yīng)用程序.DependXX values specify the XX value of an application loaded by the kernel as binary values in the registry. (The "hex:" syntax is used in REG files for values of type REG_BINARY.) The data for this registry value is a set of DWORD values corresponding to the Launch values of other applications the program depends on.
NoteThe data is defined as a sequence of bytes, so you must take into account that the operating system expects the data in little-endian 順序.
So the example translates to:
運行explorer.exe after whatever application is listed as "Launch20" and the application listed as "Launch30." (These happen to be Device.exe and Gwes.exe.)
這里有一個catch機制.The dependency is designed for operating system dependent services. The device manager and GWES must actually have initialized to a point where they can be used before the shell can start using them. Therefore, the operating system can't just launch the applications randomly. (Well, actually it could, but that would leave each application to create its own mechanism for indicating it was ready for use—creating general havoc for developers the world over.) 幸運的是, the Windows CE architects considered this and created a standard mechanism for indicating that an application is ready for use. Windows CE uses this mechanism to determine when it should launch the dependent applications.任何在Init key下裝載的應(yīng)用程序都必須調(diào)用函數(shù)SignalStarted(),并把命令行參數(shù)轉(zhuǎn)換為一個長整數(shù)傳進(jìn)去:
SignalStarted(_wtol(lpCmdLine));
這個調(diào)用告訴操作系統(tǒng):程序已經(jīng)自身初始化到了可以被其他應(yīng)用程序放心調(diào)用的地方了。
使用瀏覽器作為shell
Once you have gotten your application to load at boot time in place of the shell, it's time to get busy with the UI coding. Typically, a UI in embedded devices doesn't resemble the traditional Windows application, with its main window and menu, toolbars, status bar, and so on. Instead, an embedded device UI is usually quite visual, and often best created by professional graphics designers. (Most engineers don't even come close to that!) So it's often desirable for the programmer and graphics designer to work together. Such a meeting of minds is proving very successful in Web development and design. Fairly rich, visually pleasing interfaces are generated almost daily on the great WWW. Why not use that model in your embedded system UI design? Windows CE .NET includes a browser component that let's you do just that.
Windows CE .NET下的瀏覽器組件是Microsoft? Internet Explorer 5.5 瀏覽器控件桌面版的一個子集. 這個組件是一個Microsoft ActiveX? 控件,可以支持所有 browsing and rendering functionality in one reusable package. 有一個叫做IESAMPLE的樣例程序 (一會我們將使用它。)
The IESAMPLE application, which hosts the Internet Explorer browser control, provides a familiar Internet Explorer browser interface complete with menus, toolbars, and status bar. However, as previously mentioned, this isn't desirable in most embedded systems. What we need to have is an application that can use the browser in a "Full Screen" mode. Well it just so happens that the good folks at Microsoft thought of that, too. (Although, they failed to mention it in the documentation!) The IESAMPLE application includes a number of #if tests to enable or disable the menus, status bar, and favorites. So you only need to make a few minor modifications to the build of IESAMPLE to get what you need for a browser-based shell.
Setting Up the Project
//其實在下載下來的程序里,下面改動和設(shè)置大部分已經(jīng)做好了.需要做的我在后面標(biāo)識
首先, 使用文章頂部的連接下載這個工程的源碼IESHELL.exe.
The IESAMPLE application is located in _WINCEROOTpublicInternet ExploreroakIESAMPLE. As we've discussed in previous articles, it's generally not a good idea to modify the Microsoft provided code off the COMMON directory or any of the standard configurations. So you can copy the IESAMPLE files to a folder under your platform's workspace folder (that is, _WINCEROOTMyDeviceIESHELL). IESAMPLE is set up to build using a SOURCES file. You can create a new blank Platform Builder project and add the files in the IESHELL folder you copied everything into. The easiest way to do this is to right-click on the project in the file view and click Add files to project. (Add everything except the 'SOURCES' and 'MAKEFILE' and options.cpp. Be sure to use the *.* filtering when adding files to the project to get the various resource files as well.)
Because the project was originally created using a SOURCES file, there are some extra settings you will need to make to the project before it will build correctly.
First, you will need to add the path to the ATL headers on the C/C++ tab under the Preprocessor category. (Be sure to click All Configurations so that the settings apply to each of the project configurations.)
Figure 1. 加上ATL庫
From the same tab in the ProjectSsettings dialog, click the Precompiled Headers category and click the IESHELL project in the left side tree view. This will change the settings for all files in the project. The precompiled header is PRECOMP.H, so all files should be set to use it.
Figure 2. 設(shè)置預(yù)編譯頭
Next, click the stdafx.cpp file in the tree view to alter its settings to generate the pre-compiled header information through precomp.h.
Figure 3. Setting the precompiled header for stdafx.cpp
Next, click the IESHELL project in the tree and then click the Link tab. You will need to add the following libraries to the input libraries (note that they are separated by a space):
ole32.lib oleaut32.lib commctrl.lib uuid.lib wininet.lib winsock.lib
Figure 4. 加上所需的附加庫
Then, on the Link tab, click the Output category, and set the entry point to WinMain, the Stack size to 0x20000, and the commit size to 0x1000.
Figure 5. 設(shè)置保留和提交大小
The SOURCES file uses the RCADDNULL option, which adds a '看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();