Introduction
The ControlPanel is a small application showing you how the Windows Control Panel application works.
The normal procedure is that when the application is launched it looks for .cpl files in the windows system
directory. The cpl files are simple dll's which exports the CPlApplet()
function. Control Panel now loads each
cpl file one by one and gets the address of its CPlApplet()
function. For each file it calls the CPlApplet()
function by passing it different messages such as CPL_INIT
, CPL_INQUIRE
etc. You can get help about
different messages in the MSDN. When control panel calls CPlApplet()
function with CPL_INQUIRE
message,
the cpl file returns a CPLINFO
structure which holds information about that perticular applet such as its name, icon, info tip
etc. When a control panel applet is double clicked control panel calls CPlApplet()
function with CPL_DBLCLK
message
to let the applet perform its work.
History
17 Nov 2002: Changed code. Now one can simply use the
class CControlItems
{
public:
CControlItems();
~CControlItems();
void ReadFiles ( HWND hWnd );
virtual void ProgressText ( char* pText );
virtual void AddCplDialog( char* pName, int i, int k );
BOOL CheckIndex ( int iCpl, int iDialog );
BOOL FindIndexByName ( const char* pName, int iCpl, int iDialog );
HICON GetIconByIndex ( int iCpl, int iDialog );
const char* GetToolTipByIndex ( int iCpl, int iDialog );
const char* GetToolTipByName ( char* pName );
BOOL StartByIndex ( HWND hWnd, int iCpl, int iDialog );
BOOL StartByName ( HWND hWnd, char* pName );
CCtrlPnlInfo* cpl_info;
};
By adding this class to a simple dialog which has a CListBox called m_list and a button which calls the ReadFiles
void CCPService::OnButtonReload()
{
m_list.ResetContent();
ReadFiles( GetSafeHwnd() );
m_list.UpdateWindow();
}
void CCPService::ProgressText ( char* pText )
{
CWnd* pButton = GetDlgItem ( IDC_BUTTON_RELOAD );
if ( pButton )
{
pButton->SetWindowText ( pText );
}
}
void CCPService::AddCplDialog( char* pName, int i, int k )
{
int iData = i << 16 | k;
int iNewItem = m_list.AddString((LPCTSTR) pName);
m_list.SetItemData( iNewItem,iData);
m_list.UpdateWindow();
}
void CCPService::OnSelchangeList1()
{
int index = m_list.GetCurSel();
if(index > -1)
{
int iData = m_list.GetItemData( index );
int i = iData >> 16;
int k = iData & 0xffff;
HICON hI = GetIconByIndex ( i, k );
const char* pT = GetToolTipByIndex( i, k );
if ( pT )
{
CWnd* pW = GetDlgItem ( IDC_TOOLTIP );
if ( pW )
{
pW->SetWindowText ( pT );
}
}
if ( hI )
{
m_icon.SetIcon ( hI );
}
}
}
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.