Click here to Skip to main content
15,889,874 members
Articles / Desktop Programming / MFC
Article

CPL++ v1.1 - Control Panel Applets

Rate me:
Please Sign up or sign in to vote.
4.09/5 (6 votes)
3 Mar 2000 109K   1.4K   36   17
A freeware MFC class framework for developing Control Panel Applets.
  • Download source files - 14 Kb
  • Introduction

    Welcome to CPL++ v1.1, An MFC class framework to encapsulate developing Control Panel Applets.

    History
    Usage
    Contacting the Author


    History

    V1.0 (18 July 1999)
    • Initial public release.

    V1.1 (20 November 1999)

    • Now fully supports CPL_INQUIRE as well as CPL_NEWINQUIRE messages.
    • Now supports a document template approach to creating applets. This means that you can easily support multiple applets per dll using the CPL++ framework.
    • Demo program now supports demo'ing both static and dynamic applets.
    • Control panel applet now always output as a ".cpl" file instead of a ".dll" file.
    • Now supports displaying the specified property page (via the CPL_STARTWPARMS message) when a control panel applet is called via the rundll32 command line.


    Usage

    To use CPL++ in your applets all you need to do is:

    • Ensure your DLL has a DEF file and exports the sole function CPlApplet. Note: You do not need to write this function as it is provided internally by the CPL++ code.
    • Include cpl_pp.h and cpl_pp.h in your project (configured to produce a standard DLL including MFC either dynamically or statically).
    • Derive a class from CControlPanelApp and override its OnInit() function. In it call AddApplet() to add each applet you want. Normally, you would do this just once, but for demonstration purposes, the sample creates two applets.
    • Each applet you add should be an instance of the class CControlPanelApplet. It should be created on the heap. See CApp::OnInit() for an example. Depending on which constructor you call, you will have created an dynamic (responds to CPL_NEWINQUIRE) or static (responds to CPL_INQUIRE) control panel applet.
    • The code is UNICODE enabled and UNICODE build configurations are provided for the test applet.
    • For further information on developing and debugging control panel applets, please refer to the MSDN.


    Contacting the Author

    PJ Naughter
    Email: pjn@indigo..ie
    Web: http://www.naughter.com
    20 November 1999


    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


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralProblem on Win2k with ALL MFC Control Panel Apps Pin
    Bababooey31-Aug-04 22:42
    Bababooey31-Aug-04 22:42 
    GeneralRe: Problem on Win2k with ALL MFC Control Panel Apps Pin
    pjnaughter1-Sep-04 1:39
    pjnaughter1-Sep-04 1:39 
    GeneralRe: Problem on Win2k with ALL MFC Control Panel Apps Pin
    Bababooey1-Sep-04 11:17
    Bababooey1-Sep-04 11:17 
    Generalapplet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    Vijay Chegu2-Jun-03 5:01
    Vijay Chegu2-Jun-03 5:01 
    GeneralRe: applet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    pjnaughter2-Jun-03 5:20
    pjnaughter2-Jun-03 5:20 
    GeneralRe: applet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    Vijay Chegu2-Jun-03 18:38
    Vijay Chegu2-Jun-03 18:38 
    GeneralRe: applet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    Vijay Chegu3-Jun-03 6:11
    Vijay Chegu3-Jun-03 6:11 
    OK, got it.

    The problem was that when we get double click notification, system passes us the HWND. We need to create a dialog box with this hwnd as the parent. When this is done, our dialog box pops up if an instance is already existing.

    Infact u have added a comment also at the place that as CDialog::m_pParentWnd is protected member variable, you are not using it.

    I made a few changes and it works.
    Unfortunately these changes will break the polymorphism u have used.

    here is the method i changed.

    ofcourse we need to do a
    #include "DemoDlg.h" in cpl_pp.cpp and

    change the constructor to
    CDemoDlg(CWnd *pParent = NULL);
    in demodlg.h and demodlg.cpp

    <br />
    LRESULT CControlPanelApplet::OnRun(CWnd* pParentWnd)<br />
    {<br />
       LRESULT lResult = 1; //Assume failure<br />
    <br />
        if (_tcscmp(m_pUIClass->m_lpszClassName, _T("CDemoDlg")) == 0 ){<br />
            <br />
            CDialog* pDialog = new CDemoDlg(pParentWnd);<br />
    <br />
            if (pDialog) {<br />
                pDialog->DoModal();<br />
                delete pDialog;<br />
            }<br />
            lResult = 0;<br />
    <br />
        } else {<br />
    <br />
            CWnd *pWnd = (CWnd*) m_pUIClass->CreateObject(); <br />
            if (pWnd) {<br />
                lResult = 0; //Success;<br />
                if (pWnd->IsKindOf(RUNTIME_CLASS(CPropertySheet)))<br />
                {<br />
                    CPropertySheet* pSheet = (CPropertySheet*) pWnd;<br />
                    pSheet->Construct(m_sName, pParentWnd, m_nPageNumber);<br />
                    pSheet->DoModal();<br />
                }<br />
            }<br />
            //Don't forget to tidy up the memory used<br />
            delete pWnd;<br />
        }<br />
        return lResult;<br />
    }<br />


    Excuse me if u dont like my tinkering with ur code.
    GeneralRe: applet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    pjnaughter3-Jun-03 23:33
    pjnaughter3-Jun-03 23:33 
    GeneralRe: applet 1 in demo doesnt get focus when double click on its icon in control panel Pin
    Vijay Chegu11-Jun-03 1:44
    Vijay Chegu11-Jun-03 1:44 
    GeneralSuggestion Pin
    Armen Hakobyan29-Jul-02 12:20
    professionalArmen Hakobyan29-Jul-02 12:20 
    GeneralRe: Suggestion Pin
    pjnaughter8-Aug-02 4:05
    pjnaughter8-Aug-02 4:05 
    GeneralVery good work Pin
    Armen Hakobyan29-Jul-02 11:12
    professionalArmen Hakobyan29-Jul-02 11:12 
    QuestionHow to remove the Applet? Pin
    21-Feb-02 17:05
    suss21-Feb-02 17:05 
    AnswerRe: How to remove the Applet? Pin
    18-Mar-02 9:52
    suss18-Mar-02 9:52 
    GeneralMaking Changes Pin
    7-Dec-01 3:00
    suss7-Dec-01 3:00 
    GeneralRe: Making Changes Pin
    18-Mar-02 10:31
    suss18-Mar-02 10:31 
    GeneralRe: Making Changes Pin
    pjnaughter8-Aug-02 4:07
    pjnaughter8-Aug-02 4:07 

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

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