// CircProps.h : Declaration of the CCircProps // // This is a part of the Active Template Library. // Copyright (C) 1996-1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Active Template Library product. #include "resource.h" // main symbols #include #include #include "circprres.h" #include "circ.h" #define IID_DEFINED #include "circ_i.c" extern const GUID CLSID_CCircProps; template class CCircPropertyPageDlg : public IPropertyPageImpl, public CDialogImpl { public: typedef CCircPropertyPageDlg className; CCircPropertyPageDlg() { lstrcpy(m_szTitle, _T("OldMotherHubbard")); } enum {IDD = IDD_CIRCPROPS}; BEGIN_MSG_MAP(CCircPropertyPageDlg< T >) COMMAND_ID_HANDLER(IDC_SETTEXT, OnSetText) MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit) CHAIN_MSG_MAP(IPropertyPageImpl) END_MSG_MAP() TCHAR m_szTitle[_MAX_PATH]; LRESULT OnSetText(WORD wNotify, WORD wID, HWND hWnd, BOOL& bHandled) { SendDlgItemMessage(IDC_EDIT1, EM_GETLINE, 0, (LPARAM)m_szTitle); SetDirty(TRUE); return 0; } LRESULT OnCtlColorEdit(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ::SetTextColor((HDC)wParam, RGB(255,255,0)); ::SetBkMode((HDC)wParam, TRANSPARENT); return (LRESULT)::GetStockObject(BLACK_BRUSH); } LRESULT OnPagePropMsg(UINT, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { ATLTRACE(_T("Recieved Page Prop Message\n")); return 0; } }; ///////////////////////////////////////////////////////////////////////////// // circ class CCircProps : public CComObjectRoot, public CComCoClass, public CCircPropertyPageDlg { public: CCircProps() { m_dwTitleID = IDS_TITLE; m_dwHelpFileID = IDS_HELPFILE; m_dwDocStringID = IDS_DOCSTRING; } STDMETHOD(Apply)(void) { ICircCtl* pCirc; ATLTRACE(_T("CCircProps::Apply\n")); for (UINT i = 0; i < m_nObjects; i++) { m_ppUnk[i]->QueryInterface(IID_ICircCtl, (void**)&pCirc); pCirc->put_Caption(CComBSTR(m_szTitle)); pCirc->Release(); } m_bDirty = FALSE; return S_OK; } STDMETHOD(GetPageInfo)(PROPPAGEINFO *pPageInfo) { ATLTRACE(_T("CCircProps::GetPageInfo\n")); LONG cDlgBaseUnits = GetDialogBaseUnits(); m_size.cx = (LOWORD(cDlgBaseUnits) * 188) / 4; m_size.cy = (HIWORD(cDlgBaseUnits) * 97) / 8; return CCircPropertyPageDlg::GetPageInfo(pPageInfo); } STDMETHOD(SetObjects)(ULONG nObjects, IUnknown **ppUnk) { HRESULT hr = IPropertyPageImpl::SetObjects(nObjects, ppUnk); if (SUCCEEDED(hr)) { CComPtr pCirc; m_ppUnk[0]->QueryInterface(IID_ICircCtl, (void**)&pCirc); if (pCirc != NULL) { USES_CONVERSION; BSTR bstrTitle; pCirc->get_Caption(&bstrTitle); lstrcpy(m_szTitle, OLE2T(bstrTitle)); } } return hr; } BEGIN_COM_MAP(CCircProps) COM_INTERFACE_ENTRY_IMPL(IPropertyPage) END_COM_MAP() DECLARE_GET_CONTROLLING_UNKNOWN() DECLARE_REGISTRY_RESOURCEID(IDR_CircProps) };