The CPlApplet function processes all messages sent to a control panel application by a controlling application. Messages sent to the function should be in a specific order. By the same token, the application requires the messages to be processed in a specific way.
First, the CPlApplet function receives the CPL_INIT message when the controlling application first loads the control panel application. The function should carry out any initialization, such as allocating memory, and return nonzero. If CPlApplet cannot complete the initialization, it must return 0, directing the controlling application to terminate communication and release the DLL.
Next, if the CPL_INIT message succeeds, the controlling application sends the CPL_GETCOUNT message. The function then must return the number of applications supported by the Control Panel application.
The CPlApplet function then receives one CPL_NEWINQUIRE message for each control panel application supported by Control Panel. The function fills in a LPCPLINFO structure with data about your application, such as its name, icon, and a descriptive string.
The CPlApplet function than receives a CPL_DBLCLK message as a notification that a user has chosen the icon representing the dialog box. The function may receive this message multiple times. The LOWORD of the lParam1 message includes the Control Panel application identifier and the HIWORD is the index of the starting tab. The function should display the corresponding Control Panel application and process subsequent user input. This function only returns when the user quits the Control Panel application.
Before the controlling application terminates, CPlApplet receives the CPL_STOP message once for each Control Panel application supported by the Control Panel application. The message includes the identifier for the Control Panel application. The function should free any memory that it allocated for the specified dialog box.
After the last CPL_STOP message, CPlApplet receives a CPL_EXIT message. The function should free all remaining allocated memory and deregister any private window classes that it previously registered. Immediately after the function returns from this message, the controlling application releases the Control Panel application by calling the FreeLibrary function.