Mike Hall Steve Maillet May 1, 2002 下载 .
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. 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. 在系统启动时运行. 2. 向用户提供一个界面(接口). · 接受用户收入(,并响应). · 向用户显示响应. · 显示某些操作的当前状态. 3. Change modes/Tasks. 在系统启动时运行shell是非常简单的,只需要一个 注册表项.The following extract from the registry shows how the standard shell (explorer.exe is loaded): [HKEY_LOCAL_MACHINE\init]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00
内核初始化之后,将扫描Init key 寻找"LaunchXX"形式的key,然后以数字顺序装载列在里面的应用程序.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. Note The 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下装载的应用程序都必须调用函数SignalStarted(),并把命令行参数转换为一个长整数传进去: SignalStarted(_wtol(lpCmdLine));
这个调用告诉操作系统:程序已经自身初始化到了可以被其他应用程序放心调用的地方了。 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. 首先, 使用文章顶部的连接下载这个工程的源码IESHELL.exe. The IESAMPLE application is located in _WINCEROOT\public\Internet Explorer\oak\IESAMPLE. 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, _WINCEROOT\MyDevice\IESHELL). 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.)
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.
Next, click the stdafx.cpp file in the tree view to alter its settings to generate the pre-compiled header information through precomp.h. ...... 更多内容请点击查看原文: |