Creating Control Panel Applications

Although a Control Panel application may support more than one dialog box, it processes all requests through the single CPlApplet function. In the following example, the Control Panel application supports three dialog boxes that let the user set preferences for a component stereo system attached to the computer. The example uses an application-defined StereoApplets array that contains three structures, each corresponding to one of the dialog boxes. Each structure contains all the information required by the CPL_INQUIRE message, as well as the dialog box template and dialog box procedure required by the CPL_DBLCLK message. The code demonstrates how to fill the structures in the StereoApplets array.

#define NUM_APPLETS 3

typedef struct tagApplets

{

int icon; // icon resource identifier

int namestring; // name-string resource identifier

int descstring; // description-string resource identifier

int dlgtemplate; // dialog box template resource identifier

DLGPROC dlgfn; // dialog box procedure

} APPLETS;

APPLETS StereoApplets[NUM_APPLETS] =

{

AMP_ICON, AMP_NAME, AMP_DESC, AMP_DLG, AmpDlgProc,

TUNER_ICON, TUNER_NAME, TUNER_DESC, TUNER_DLG, TunerDlgProc,

TAPE_ICON, TAPE_NAME, TAPE_DESC, TAPE_DLG, TapeDlgProc,

};

HANDLE hinst = NULL;

LONG CALLBACK CPlApplet(hwndCPL, uMsg, lParam1, lParam2)

HWND hwndCPL; // handle of Control Panel window

UINT uMsg; // message

LPARAM lParam1; // first message parameter

LPARAM lParam2; // second message parameter

{

int i;

LPCPLINFO lpCPlInfo;

i = (int) lParam1;

switch (uMsg) {

case CPL_INIT: // first message, sent once

hinst = GetModuleHandle("ecp.cpl");

return TRUE;

case CPL_GETCOUNT: // second message, sent once

return NUM_APPLETS;

break;

case CPL_INQUIRE: // third message, sent once per application

lpCPlInfo = (LPCPLINFO) lParam2;

lpCPlInfo->lData = 0;

lpCPlInfo->idIcon = StereoApplets[i].icon;

lpCPlInfo->idName = StereoApplets[i].namestring;

lpCPlInfo->idInfo = StereoApplets[i].descstring;

break;

case CPL_DBLCLK: // application icon double-clicked

DialogBox(hinst,

MAKEINTRESOURCE(StereoApplets[i].dlgtemplate),

hwndCPL, StereoApplets[i].dlgfn);

break;

case CPL_STOP: // sent once per application before CPL_EXIT

break;

case CPL_EXIT: // sent once before FreeLibrary is called

break;

default:

break;

}

return 0;

}

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database