Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Implementing Control Panel Applets

Implementing Control Panel Applets

As mentioned, a Control Panel applet is a configuration tool for a system component or user application implemented in form of a .cpl file and located in the Windows folder on the target device. Essentially, a .cpl file is a DLL that implements the CPlApplet API. A single .cpl file can contain multiple Control Panel applications, yet a single applet cannot span multiple .cpl files. Because all .cpl files implement the CPlApplet API, it is a straightforward process for Control.exe to obtain detailed info about the implemented applets at startup in order to display the set of available applets in the user interface. Control.exe only needs to enumerate all .cpl files in the Windows folder and to call the CPlApplet function in each file.

According to the DLL nature and CPlApplet API requirements, .cpl files must implement the following two public entry points:

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) Used to initialize the DLL. The system calls DllMain to load the DLL. The DLL returns true if initialization succeeded or false if initialization failed.

LONG CALLBACK CPlApplet(HWND hwndCPL, UINT message, LPARAM lParam1, LPARAM lParam2) A callback function that serves as the entry point for the Control Panel to perform actions on the applet.

NOTE

DLL entry points

You must export the DllMain and CPlApplet entry points so that the Control Panel application can access these functions. Non-exported functions are private to the DLL. Make sure the function definitions are in export "C" { } blocks to export the C interface.

The Control Panel calls the CPlApplet function to initialize the applet, obtain information, provide information about user actions, and to unload the applet. The applet must support several Control Panel messages, listed in Table 3-6, to implement a fully functional CPlApplet interface:

Table 3-6 Control Panel messages

Control Panel Message Description
CPL_INIT The Control Panel sends this message to perform global initialization of the applet. Memory initialization is a typical task performed at this step.
CPL_GETCOUNT The Control Panel sends this message to determine the number of Control Panel applications implemented in the .cpl file.
CPL_NEWINQUIRE The Control Panel sends this message for all the Control Panel applications specified by CPL_GETCOUNT. At this step each Control Panel application must return a NEWCPLINFO structure to specify the icon and title to display in the Control Panel user interface.
CPL_DBLCLK The Control Panel sends this message when the user double-clicks on an icon of the applet in the Control Panel user interface.
CPL_STOP The Control Panel sends this message once for each instance specified by CPL_GETCOUNT.
CPL_EXIT The Control Panel sends this message once for the applet before the system releases the DLL.

NOTE

NEWCPLINFO information

Store the NEWCPLINFO information for each Control Panel application that you implement in a Control Panel applet in a resource embedded in the .cpl file. This facilitates the localization of icons, names, and applet descriptions returned in response to CPL_NEWINQUIRE messages.

Оглавление книги


Генерация: 1.134. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз