MFC ActiveX控件,属性页如何重载Apply函数

gaoxiaowei 2012-03-28 04:50:52
我做的MFC ActiveX控件,属性页中需要在用户点击Apply按钮时,控件相应的做一些操作,可是我始终不知道应该怎样重载Apply函数。

贴上源代码,

//.h STDMETHODIMP CNormalPropPage::XPropertyPage::QueryInterface(REFIID iid, LPVOID FAR* ppvObj)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.QueryInterface(iid,ppvObj);
return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj) ;
//*ppvObj=this;
return S_OK;
}
STDMETHODIMP_(ULONG) CNormalPropPage::XPropertyPage::AddRef(void)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
return (HRESULT)pThis->ExternalAddRef() ;
//return pThis->m_xPropertyPage.AddRef();
return 1;

}
STDMETHODIMP_(ULONG) CNormalPropPage::XPropertyPage::Release(void)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
return (HRESULT)pThis->ExternalRelease() ;
// return pThis->m_xPropertyPage.Release();
return 0;
}

STDMETHODIMP CNormalPropPage::XPropertyPage::SetPageSite(
IPropertyPageSite *pPageSite)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
// return pThis->m_xPropertyPage.SetPageSite(pPageSite);
// IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
// return p->SetPageSite(pPageSite);
COlePropertyPage::XPropertyPage::SetPageSite(pPageSite);
return S_OK;
}

STDMETHODIMP CNormalPropPage::XPropertyPage:: Activate(
HWND hWndParent,
LPCRECT pRect,
BOOL bModal)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
// return pThis->m_xPropertyPage.Activate(hWndParent,pRect,bModal);
// IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
// return p->Activate(hWndParent,pRect,bModal);
COlePropertyPage::XPropertyPage::Activate(hWndParent,pRect,bModal);
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::Deactivate( void)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
// return pThis->m_xPropertyPage.Deactivate();
// IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->Deactivate();
return S_OK;
}

STDMETHODIMP CNormalPropPage::XPropertyPage:: GetPageInfo(
PROPPAGEINFO *pPageInfo)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.GetPageInfo(pPageInfo);
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->GetPageInfo(pPageInfo);
return S_OK;
}


STDMETHODIMP CNormalPropPage::XPropertyPage:: SetObjects(
ULONG cObjects,
IUnknown **ppUnk)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.SetObjects(cObjects,ppUnk);
// IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
// return p->SetObjects(cObjects,ppUnk);
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::Show(
/* [in] */ UINT nCmdShow)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.Show(nCmdShow);
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->Show(nCmdShow);
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::Move(
LPCRECT pRect)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.Move(pRect);
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->Move(pRect);
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::IsPageDirty( void)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.IsPageDirty();
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->IsPageDirty();
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::Apply( void)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.Apply();

//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->Apply();
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::Help(
LPCOLESTR pszHelpDir)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.Help(pszHelpDir);
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->Help(pszHelpDir);
return S_OK;
}

STDMETHODIMP CNormalPropPage:: XPropertyPage::TranslateAccelerator(
MSG *pMsg)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
//return pThis->m_xPropertyPage.TranslateAccelerator(pMsg);
//IPropertyPagePtr p = _getInterface(IID_IPropertyPage, pThis, pThis->GetInterfaceMap());
//return p->TranslateAccelerator(pMsg);
return S_OK;
}
STDMETHODIMP CNormalPropPage:: XPropertyPage::EditProperty(DISPID)
{
METHOD_MANAGE_STATE(CNormalPropPage, PropertyPage)
ASSERT_VALID(pThis);
return S_OK;
}
class CNormalPropPage : public COlePropertyPage
{
DECLARE_DYNCREATE(CNormalPropPage)
DECLARE_OLECREATE_EX(CNormalPropPage)

// Constructors
public:
CNormalPropPage();

// Dialog Data
//{{AFX_DATA(CNormalPropPage)
enum { IDD = IDD_PROPAGE_NORMAL };

//}}AFX_DATA
CButton m_btnGrid;
CButton m_btnCursor;
CButton m_btnAutoRange;
CComboBox m_cbFrame;
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support


// Message maps
protected:
void UpdateControls();
//{{AFX_MSG(CNormalPropPage)
afx_msg void OnCloseupComboFrame();
afx_msg void OnCheckShowgrid();
afx_msg void OnChangeCaption();
afx_msg void OnCheckShowCursor();
afx_msg void OnCheckAutoRange();

virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
BEGIN_INTERFACE_PART(PropertyPage, IPropertyPage2)
INIT_INTERFACE_PART(CNormalPropPage, PropertyPage)
STDMETHOD(SetPageSite)(LPPROPERTYPAGESITE);
STDMETHOD(Activate)(HWND, LPCRECT, BOOL);
STDMETHOD(Deactivate)();
STDMETHOD(GetPageInfo)(LPPROPPAGEINFO);
STDMETHOD(SetObjects)(ULONG, LPUNKNOWN*);
STDMETHOD(Show)(UINT);
STDMETHOD(Move)(LPCRECT);
STDMETHOD(IsPageDirty)();
STDMETHOD(Apply)();
STDMETHOD(Help)(LPCOLESTR);
STDMETHOD(TranslateAccelerator)(LPMSG);
STDMETHOD(EditProperty)(DISPID);
END_INTERFACE_PART(PropertyPage)
DECLARE_INTERFACE_MAP();
};
//.cpp

...全文
178 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaoxiaowei 2012-03-28
  • 打赏
  • 举报
回复
目前可以重载到Apply,但是属性页无法正常显示。因为我重载了别的IPropertyPage2的方法。如何实现IPropertyPage2的所有接口呢???

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧