📄 appwinzardapictl.cpp
字号:
// AppWinzardApiCtl.cpp : Implementation of the CAppWinzardApiCtrl ActiveX Control class.
#include "stdafx.h"
#include "AppWinzardApi.h"
#include "AppWinzardApiCtl.h"
#include "AppWinzardApiPpg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CAppWinzardApiCtrl, COleControl)
/////////////////////////////////////////////////////////////////////////////
// Message map
BEGIN_MESSAGE_MAP(CAppWinzardApiCtrl, COleControl)
//{{AFX_MSG_MAP(CAppWinzardApiCtrl)
// NOTE - ClassWizard will add and remove message map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG_MAP
ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dispatch map
BEGIN_DISPATCH_MAP(CAppWinzardApiCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CAppWinzardApiCtrl)
DISP_FUNCTION(CAppWinzardApiCtrl, "ALTQApi", ALTQApi, VT_I2, VTS_NONE)
DISP_FUNCTION(CAppWinzardApiCtrl, "CTLQApi", CTLQApi, VT_I2, VTS_NONE)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CAppWinzardApiCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
/////////////////////////////////////////////////////////////////////////////
// Event map
BEGIN_EVENT_MAP(CAppWinzardApiCtrl, COleControl)
//{{AFX_EVENT_MAP(CAppWinzardApiCtrl)
// NOTE - ClassWizard will add and remove event map entries
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_EVENT_MAP
END_EVENT_MAP()
/////////////////////////////////////////////////////////////////////////////
// Property pages
// TODO: Add more property pages as needed. Remember to increase the count!
BEGIN_PROPPAGEIDS(CAppWinzardApiCtrl, 1)
PROPPAGEID(CAppWinzardApiPropPage::guid)
END_PROPPAGEIDS(CAppWinzardApiCtrl)
/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CAppWinzardApiCtrl, "APPWINZARDAPI.AppWinzardApiCtrl.1",
0x15d2cbb8, 0x2f18, 0x4008, 0x89, 0x9a, 0xfe, 0x45, 0x2d, 0x1e, 0x55, 0xae)
/////////////////////////////////////////////////////////////////////////////
// Type library ID and version
IMPLEMENT_OLETYPELIB(CAppWinzardApiCtrl, _tlid, _wVerMajor, _wVerMinor)
/////////////////////////////////////////////////////////////////////////////
// Interface IDs
const IID BASED_CODE IID_DAppWinzardApi =
{ 0x49b9e417, 0x70a3, 0x45be, { 0x92, 0xcd, 0x57, 0xbd, 0x50, 0xa1, 0xf1, 0xe3 } };
const IID BASED_CODE IID_DAppWinzardApiEvents =
{ 0x36964267, 0x4495, 0x478a, { 0xa9, 0x1, 0x93, 0xd1, 0xcd, 0x3d, 0xdb, 0x72 } };
/////////////////////////////////////////////////////////////////////////////
// Control type information
static const DWORD BASED_CODE _dwAppWinzardApiOleMisc =
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CAppWinzardApiCtrl, IDS_APPWINZARDAPI, _dwAppWinzardApiOleMisc)
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::CAppWinzardApiCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CAppWinzardApiCtrl
BOOL CAppWinzardApiCtrl::CAppWinzardApiCtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0.
if (bRegister)
return AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_APPWINZARDAPI,
IDB_APPWINZARDAPI,
afxRegApartmentThreading,
_dwAppWinzardApiOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::CAppWinzardApiCtrl - Constructor
CAppWinzardApiCtrl::CAppWinzardApiCtrl()
{
InitializeIIDs(&IID_DAppWinzardApi, &IID_DAppWinzardApiEvents);
// TODO: Initialize your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::~CAppWinzardApiCtrl - Destructor
CAppWinzardApiCtrl::~CAppWinzardApiCtrl()
{
// TODO: Cleanup your control's instance data here.
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::OnDraw - Drawing function
void CAppWinzardApiCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
pdc->Ellipse(rcBounds);
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::DoPropExchange - Persistence support
void CAppWinzardApiCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::OnResetState - Reset control to default state
void CAppWinzardApiCtrl::OnResetState()
{
COleControl::OnResetState(); // Resets defaults found in DoPropExchange
// TODO: Reset any other control state here.
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl::AboutBox - Display an "About" box to the user
void CAppWinzardApiCtrl::AboutBox()
{
CDialog dlgAbout(IDD_ABOUTBOX_APPWINZARDAPI);
dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CAppWinzardApiCtrl message handlers
short CAppWinzardApiCtrl::ALTQApi()
{
// TODO: Add your dispatch handler code here
keybd_event( VK_MENU, 0, 0, 0 ); // ALT key down
keybd_event( 0x51, 0, 0, 0 ); // Q key down
keybd_event( 0x51, 0, KEYEVENTF_KEYUP, 0 ); // Q key up
keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, 0 ); // CONTROL key up
return 0;
}
short CAppWinzardApiCtrl::CTLQApi()
{
// TODO: Add your dispatch handler code here
keybd_event( VK_CONTROL, 0, 0, 0 ); // CONTROL key down
keybd_event( 0x51, 0, 0, 0 ); // Q key down
keybd_event( 0x51, 0, KEYEVENTF_KEYUP, 0 ); // Q key up
keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0 ); // CONTROL key up
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -