我想在我的属性表中模拟模态diaolg的行为,以便它始终保持在顶部,并且在关闭该表之前,无法执行该属性表中的其他任何操作。 我具有以下类结构;
class ViewPSheet : public CView
{
protected:
ViewPSheet();
DECLARE_DYNCREATE(ViewPSheet)
// Overrides
public:
virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual void OnInitialUpdate(); // called first time after construct
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
virtual void OnActivateFrame(UINT nState, CFrameWnd* /*pFrameWnd*/);
// Generated message map functions
protected:
afx_msg void OnDestroy();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
DECLARE_MESSAGE_MAP()
};
class SheetDim : public ViewPSheet
{
protected:
SheetDim(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(SheetDim)
// Operations
public:
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
protected:
virtual ~SheetDim();
public:
void OnApplyNow();
void OnCancel();
void OnOK();
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
SheetDimclass充当属性页的持有者,并在OnInitialUpdate()中添加了几个CPropertyPage类。 我尝试使用以下方法将属性表置顶,包括尝试注释行。
void SheetDim::OnActivateView(
BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
ViewPSheet::OnActivateView(bActivate, pActivateView, pDeactiveView);
if (bActivate == WA_INACTIVE)
{
::SetWindowPos( this->GetParent()->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE );
//::SetWindowPos( this->GetParent()->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
//::SetWindowPos( this->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
}
但是无法使属性表像无模式对话框一样工作。有没有一种方法可以实现而无需更改ViewPSheet父类?