📄 atlcontrolwinppg.h
字号:
// ATLControlWinPPG.h : Declaration of the CATLControlWinPPG
#ifndef __ATLCONTROLWINPPG_H_
#define __ATLCONTROLWINPPG_H_
#include "resource.h" // main symbols
#include "alignmentenums.h"
#include "ATLControl.h"
EXTERN_C const CLSID CLSID_ATLControlWinPPG;
/////////////////////////////////////////////////////////////////////////////
// CATLControlWinPPG
class ATL_NO_VTABLE CATLControlWinPPG :
public CComObjectRootEx<CComObjectThreadModel>,
public CComCoClass<CATLControlWinPPG, &CLSID_ATLControlWinPPG>,
public IPropertyPageImpl<CATLControlWinPPG>,
public CDialogImpl<CATLControlWinPPG>
{
public:
CATLControlWinPPG()
{
m_dwTitleID = IDS_TITLEATLControlWinPPG;
m_dwHelpFileID = IDS_HELPFILEATLControlWinPPG;
m_dwDocStringID = IDS_DOCSTRINGATLControlWinPPG;
}
enum {IDD = IDD_ATLCONTROLWINPPG};
DECLARE_REGISTRY_RESOURCEID(IDR_ATLCONTROLWINPPG)
BEGIN_COM_MAP(CATLControlWinPPG)
COM_INTERFACE_ENTRY_IMPL(IPropertyPage)
END_COM_MAP()
BEGIN_MSG_MAP(CATLControlWinPPG)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_ALIGNMENTCOMBO, CBN_SELCHANGE, OnAlignmentComboSelChange)
CHAIN_MSG_MAP(IPropertyPageImpl<CATLControlWinPPG>)
END_MSG_MAP()
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled)
{
// get the window handle of the combobox control
HWND hTempWnd = ::GetDlgItem(m_hWnd, IDC_ALIGNMENTCOMBO);
// make sure that the control is empty
::SendMessage(hTempWnd, CB_RESETCONTENT, 0, 0);
// set the selection strings in the control - it is important that the control
// be unsorted since the entries index will relate to the property setting
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_LEFT_TEXT);
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_CENTER_TEXT);
::SendMessage(hTempWnd, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR) EALIGN_RIGHT_TEXT);
// see if the object supports the interface we need
CComQIPtr<IATLControlWin, &IID_IATLControlWin>pControl(m_ppUnk[0]);
long lAlignment;
// set the control with the new value and if it failed
pControl->get_Alignment(&lAlignment);
// get the current selection in the listbox
::SendMessage(::GetDlgItem(m_hWnd, IDC_ALIGNMENTCOMBO), CB_SETCURSEL, lAlignment, 0);
return TRUE;
}
LRESULT OnAlignmentComboSelChange(WORD wNotify, WORD wID, HWND hWnd, BOOL& bHandled)
{
SetDirty(TRUE);
return FALSE;
}
STDMETHOD(Apply)(void)
{
USES_CONVERSION;
ATLTRACE(_T("CATLControlWinPPG::Apply\n"));
for (UINT i = 0; i < m_nObjects; i++)
{
// see if the object supports the interface we need
CComQIPtr<IATLControlWin, &IID_IATLControlWin> pControl(m_ppUnk[i]);
// get the current selection in the listbox
long lAlignment = (long) ::SendMessage(::GetDlgItem(m_hWnd, IDC_ALIGNMENTCOMBO), CB_GETCURSEL, 0, 0);
// set the control with the new value and if it failed
if FAILED(pControl->put_Alignment(lAlignment))
{
// generate an error message
CComPtr<IErrorInfo> pError;
CComBSTR strError;
GetErrorInfo(0, &pError);
pError->GetDescription(&strError);
MessageBox(OLE2T(strError), _T("Error"), MB_ICONEXCLAMATION);
return E_FAIL;
}
}
m_bDirty = FALSE;
return S_OK;
}
};
#endif //__ATLCONTROLWINPPG_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -