Click here to Skip to main content
Click here to Skip to main content

Creating a Config Panel Applet

, 11 Oct 2002
Rate this:
Please Sign up or sign in to vote.
Step by step creation of a control panel applet

I've tried to explain the creation of the control Panel applet in one of the simplest way.

Create a new project of .dll type from the template wizard. Let's name it as ConfigPanel

Project Type

Select regular dll using MFC in the second step.

Dll Type

following classes would be generated by the template.

ConfigPanel

A class derived from CWinApp.

ConfigPanel.def

export definition file showing the symbols that are exported.

Add the CPlApplet function. This function is the entry point of this CPL (control panel application).

LRESULT APIENTRY CPlApplet
(
    HWND    aHwndCPL_in,    // Handle to Configuration Panel window.
    UINT    aUMsg_in,        // CPL message.
    LPARAM    aLParam1_in,    // First message parameter.
    LPARAM  aLParam2_in    // Second message parameter.
) 

aUMsg_in

This parameter is filled with the CPL related messages like..

//                       | Return            | Return
//    CPL message        | if successfully   | if not successfully
//    -------------------+-------------------+--------------------
//    CPL_INIT           | nonzero           | zero
//    CPL_GETCOUNT       | nonzero           | zero
//    CPL_NEWINQUIRE     | zero              | nonzero
//    CPL_SELECT         | zero              | nonzero
//    CPL_DBLCLK         | zero              | nonzero
//    CPL_STOP           | zero              | nonzero
//    CPL_EXIT           | zero              | nonzero

CPL_INIT

The CPL_INIT message is sent to a Control Panel application to prompt it to perform global initialization, especially memory allocation.

Return Values: If initialization succeeds, a Control Panel application should return nonzero. Otherwise, it should return zero. If the application returns zero, the controlling application ends communication and releases the DLL containing the Control Panel application.

Remarks: Because this is the only way a Control Panel application can signal an error condition, the application should allocate memory in response to this message. This message is sent immediately after the DLL containing the application is loaded via LoadLibrary().

CPL_GETCOUNT

The The CPL_GETCOUNT message is sent to a Control Panel application to retrieve the number of dialog boxes supported by the application.

Return Values: A Control Panel application should return the number of dialog boxes it supports.

Remarks: This message is sent immediately after the CPL_INIT message.

CPL_NEWINQUIRE

The CPL_NEWINQUIRE message is sent to a Control Panel application to request information about a dialog box that the application supports.

Parameters: Value of aLParam1_in. Specifies the dialog box number. Value of aLParam2_in. Specifies the address of a NEWCPLINFO structure. The Control Panel application should fill this structure with information about the dialog box.

Return Values: If a Control Panel application processes this message successfully, it should return zero.

Remarks: This message is sent once for each dialog box supported by the application. It is sent immediately after the CPL_GETCOUNT message. Upon receiving this message, the application can initialize the dialog box. If the application must allocate memory, it should do so in response to the CPL_INIT message.

CPL_SELECT

The CPL_SELECT message is sent to a Control Panel application when the user selects the icon of a dialog box supported by the application. Value of aLParam1_in. Specifies the dialog box number. Value of aLParam2_in. Specifies the value that the Control Panel application loaded into the lData member of the CPLINFO or NEWCPLINFO structure for the dialog box. The application loads the lData member in response to the CPL_INQUIRE or CPL_NEWINQUIRE message.

Return Values: If a Control Panel application processes this message successfully, it should return zero.

CPL_DBLCLK

The CPL_DBLCLK message is sent to a Control Panel application when the user double-clicks the icon of a dialog box supported by the application.

Parameters: Value of aLParam1_in. Specifies the dialog box number. Value of aLParam2_in. Specifies the value that the Control Panel application loaded into the lData member of the CPLINFO or NEWCPLINFO structure for the dialog box. The application loads lData member in response to the CPL_INQUIRE or CPL_NEWINQUIRE message.

Return Values: If a Control Panel application processes this message successfully, it should return zero.

Remarks: In response to this message, a Control Panel application must display the corresponding dialog box.

CPL_STOP

The CPL_STOP message is sent once for each dialog box when the application controlling the Control Panel application closes.

Parameters: Value of aLParam1_in. Specifies the dialog box number. Value of aLParam2_in. Specifies the value that the Control Panel application loaded into the lData member of the CPLINFO or NEWCPLINFO structure for the dialog box. The application loads lData member in response to the CPL_INQUIRE or CPL_NEWINQUIRE message.

Return Values: A Control Panel application should return the number of dialog boxes it supports.

Remarks: In response to this message, a Control Panel application must perform cleanup for the given dialog box.

CPL_EXIT

The CPL_EXIT message is sent once to a Control Panel application before the controlling application releases the DLL containing the application.

Return Values: A Control Panel application should return the number of dialog boxes it supports.

Remarks: This message is sent after the last CPL_STOP message is sent. In response to this message, a Control Panel application must free any memory that it has allocated and perform global-level cleanup.

That's it now you application is ready, but before that don't forget to add CPlApplet PRIVATE in the export definition file, otherwise the callback would not be called. Smile | :)

The output that you would get after compilation would be of .dll kind rename this file to .cpl and copy it to windows directory and you would see your application in the config panel.

The demo project opens the notepad.exe when double clicked, you can either run any exe from there by giving the path or you can create dialogs as the part of the .cpl itself

There is a MakeCpl.bat in the source directory this would copy the .dll to System32 directory and also rename it to .cpl

Hope the topic would have helped you....

Mail me back in case of any comments or suggestion for the same.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Nilesh K.
Web Developer
India India
No Biography provided

Comments and Discussions

 
Questioncan open .cpl file in other dir. except system32 dir. Pinmemberwanrue9-Jul-12 21:54 
GeneralIcon problem Pinmemberr4dius2-Mar-07 9:49 
GeneralRe: Icon problem PinmemberNilesh K.5-Mar-07 17:07 
GeneralWon't show up in control panel Pinmembermalignant5-Jan-06 11:08 
Generaldelete the control panel item in WIN2k system PinmemberYM32310-Jul-05 17:43 
GeneralRe: delete the control panel item in WIN2k system PinmemberNilesh K.11-Jul-05 1:47 
Loading and unloading of cpl files in XP is different from win2k.

 


- Nilesh
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
GeneralRe: delete the control panel item in WIN2k system Pinmemberym32321-Jul-05 21:21 
GeneralRe: delete the control panel item in WIN2k system PinmemberNilesh K.21-Jul-05 23:18 
GeneralRe: delete the control panel item in WIN2k system PinmemberCandseeme4-Jan-06 1:56 
GeneralDebugging Control Panel Applets PinmemberStuart Hart29-Aug-03 6:22 
GeneralRe: Debugging Control Panel Applets PinmemberIgor Mladenovic20-Jul-06 9:55 
GeneralEnumerating Control Panel Applets PinsussSireesh Tripurari31-Dec-02 1:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 12 Oct 2002
Article Copyright 2002 by Nilesh K.
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid