KLOPEKS
asked on
Control panel application
How is it possible in Delphi to make a .cpl file? and how could you make your standard Delphi program run with that extension?
You got Delphi pro? Don't you just do "New" and choose 'Control Panel appliction' of the 'Other' options somewhere?
andrewjb is right. Use File|New|Control Panel Application
When you create a new CPL project, you get a TAppletModule which is a kind of data module with special events to support a control panel. You can even add more of those panels if you like. Control Panel Applications have a special entry point called "CPlApplet" which is required.
Let's quote cpl.pas:
--------Start quote
General rules for being installed in the Control Panel:
1) The DLL must export a function named CPlApplet which will handle the messages discussed below.
2) If the applet needs to save information in CONTROL.INI minimize clutter by using the application name [MMCPL.appletname].
3) If the applet is refrenced in CONTROL.INI under [MMCPL] use the following form:
...
[MMCPL]
uniqueName=c:\mydir\myappl et.dll
...
The order applet DLL's are loaded by CONTROL.EXE is:
1) MAIN.CPL is loaded from the windows system directory.
2) Installable drivers that are loaded and export the CplApplet() routine.
3) DLL's specified in the [MMCPL] section of CONTROL.INI.
4) DLL's named *.CPL from windows system directory.
CONTROL.EXE will answer this message and launch an applet
WM_CPL_LAUNCH
wParam - window handle of calling app
lParam - LPTSTR of name of applet to launch
WM_CPL_LAUNCHED
wParam - TRUE/FALSE if applet was launched
lParam - NULL
CONTROL.EXE will post this message to the caller when the applet returns (ie., when wParam is a valid window handle)
--------End quote
In Delphi, the related units are CPL and CtlPanel. It is possible to make an executable that runs both as stand-alone exe and as CPL application but in general it's better to split this functionality. But if you really want to do this, create a CPlApplet according to above syntax and export it. Rename the exe to .cpl or include {$E cpl} in your project source.
When you create a new CPL project, you get a TAppletModule which is a kind of data module with special events to support a control panel. You can even add more of those panels if you like. Control Panel Applications have a special entry point called "CPlApplet" which is required.
Let's quote cpl.pas:
--------Start quote
General rules for being installed in the Control Panel:
1) The DLL must export a function named CPlApplet which will handle the messages discussed below.
2) If the applet needs to save information in CONTROL.INI minimize clutter by using the application name [MMCPL.appletname].
3) If the applet is refrenced in CONTROL.INI under [MMCPL] use the following form:
...
[MMCPL]
uniqueName=c:\mydir\myappl
...
The order applet DLL's are loaded by CONTROL.EXE is:
1) MAIN.CPL is loaded from the windows system directory.
2) Installable drivers that are loaded and export the CplApplet() routine.
3) DLL's specified in the [MMCPL] section of CONTROL.INI.
4) DLL's named *.CPL from windows system directory.
CONTROL.EXE will answer this message and launch an applet
WM_CPL_LAUNCH
wParam - window handle of calling app
lParam - LPTSTR of name of applet to launch
WM_CPL_LAUNCHED
wParam - TRUE/FALSE if applet was launched
lParam - NULL
CONTROL.EXE will post this message to the caller when the applet returns (ie., when wParam is a valid window handle)
--------End quote
In Delphi, the related units are CPL and CtlPanel. It is possible to make an executable that runs both as stand-alone exe and as CPL application but in general it's better to split this functionality. But if you really want to do this, create a CPlApplet according to above syntax and export it. Rename the exe to .cpl or include {$E cpl} in your project source.
ASKER
I'm not to familiar with Control Panel Application, but i have an existing program that i would like to run as one, so do i make a dll, or add my current code to a CPlApplet ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.