📄 chapter2_5.cpp
字号:
// chapter2_5.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "chapter2_5.h"
#include <cpl.h>
#include <Afxtempl.h>
#include "STControlPanelApplet.h"
#include "Applet1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
// CChapter2_5App
BEGIN_MESSAGE_MAP(CChapter2_5App, CWinApp)
//{{AFX_MSG_MAP(CChapter2_5App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChapter2_5App construction
CChapter2_5App::CChapter2_5App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CChapter2_5App object
CChapter2_5App theApp;
/////////////////////////////////////////////////////////////////////////////
// Control Panel Applet
CArray<CSTControlPanelApplet*,CSTControlPanelApplet*> applets;
LONG CplInit(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
applets.Add(new CApplet1());
return 1;
}
LONG CplGetCount(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
return applets.GetSize();
}
void sstrcpy(TCHAR* p1, const TCHAR *p2)
{
do {
*p1 = *p2;
p2 ++;
p1 ++;
} while (*p2!=0);
*p1 = 0;
}
LONG CplNewInquire(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
NEWCPLINFO *pInfo = (NEWCPLINFO*)lParam2;
CSTControlPanelApplet *pApplet = applets[lParam1];
if (pApplet) {
pInfo->dwSize = sizeof(NEWCPLINFO);
pInfo->hIcon = pApplet->GetIcon();
pInfo->lData = 0;
sstrcpy(pInfo->szName, (LPCTSTR)pApplet->GetName());
sstrcpy(pInfo->szInfo, (LPCTSTR)pApplet->GetInfo());
}
return 0;
}
LONG CplSelect(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
UINT uAppNum = (UINT)lParam1;
LONG lData = (LONG) lParam2;
CSTControlPanelApplet *pApplet = applets[uAppNum];
if (pApplet) {
pApplet->OnClick();
}
return 0;
}
LONG CplDblClick(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
UINT uAppNum = (UINT)lParam1;
LONG lData = (LONG) lParam2;
CSTControlPanelApplet *pApplet = applets[uAppNum];
if (pApplet) {
pApplet->OnClick();
}
return 0;
}
LONG CplIdName(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
return 1;
}
LONG CPlApplet(HWND hwndCpl, UINT msg, LONG lParam1, LONG lParam2)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
switch (msg) {
case CPL_INIT:
return CplInit(hwndCpl, msg, lParam1, lParam2);
case CPL_GETCOUNT:
return CplGetCount(hwndCpl, msg, lParam1, lParam2);
case CPL_SELECT:
return CplSelect(hwndCpl, msg, lParam1, lParam2);
case CPL_DBLCLK:
return CplDblClick(hwndCpl, msg, lParam1, lParam2);
case CPL_NEWINQUIRE:
return CplNewInquire(hwndCpl, msg, lParam1, lParam2);
case CPL_IDNAME:
return CplIdName(hwndCpl, msg, lParam1, lParam2);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -