用CAcUiDockControlBar向CAD中加入自己的ControlBar出现问题,请各位高手急救!
我创建了一个基于CAcUiDockControlBar的类,在类中创建自己的控件。加载到CAD后,让其自己停靠,但是停靠后的工具条高度无法所到。另外加载后CAD出现不停闪烁现象,请高手出招!
class CLayerDockControlBar : public CAcUiDockControlBar { DECLARE_DYNAMIC(CLayerDockControlBar) public: CLayerDockControlBar(); public: virtual BOOL Create(CWnd* pParent, LPCSTR lpszTitle); protected: afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); DECLARE_MESSAGE_MAP() virtual void SizeChanged(CRect *lpRect, BOOL bFloating, int flags); public: CLayerManageBar *m_pWndLayerBar; };
IMPLEMENT_DYNAMIC(CLayerDockControlBar, CAcUiDockControlBar)
BEGIN_MESSAGE_MAP(CLayerDockControlBar, CAcUiDockControlBar) //{{AFX_MSG_MAP(CLayerDockControlBar) ON_WM_CREATE() ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP()
static CLSID clsCLayerDockControlBar ={ 0x45d8e5de, 0xaa69, 0x4611, { 0x8f, 0xeb, 0xb2, 0xa6, 0xbe, 0xe8, 0xfb, 0x47 } } ;
CLayerDockControlBar::CLayerDockControlBar() : CAcUiDockControlBar() { m_pWndLayerBar = NULL; }
BOOL CLayerDockControlBar::Create(CWnd* pParent, LPCSTR lpszTitle) { CString strWndClass; strWndClass = AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW)); CRect rect (0, 0, 158, 300); if ( !CAcUiDockControlBar::Create( strWndClass, lpszTitle, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, rect, pParent, IDC_TOOLBAR_LAYERMANAGER )) return (FALSE); SetToolID (&clsCLayerDockControlBar) ; return (TRUE); }
int CLayerDockControlBar::OnCreate (LPCREATESTRUCT lpCreateStruct) { if ( CAcUiDockControlBar::OnCreate (lpCreateStruct) == -1 ) return (-1); CAcModuleResourceOverride resourceOverride; m_pWndLayerBar = new CLayerManageBar; if (!m_pWndLayerBar->Create(_T("Layer Manager"), this, CSize(200,300),TRUE,123)) { return -1; } m_pWndLayerBar->SetBarStyle(m_pWndLayerBar->GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_pWndLayerBar->AddView(RUNTIME_CLASS(CWndSliderView));
((CWndSliderView *)m_pWndLayerBar->GetActiveView())->CreateView("0 LayView", RUNTIME_CLASS(CLayerManagerView), NULL); ((CWndSliderView *)m_pWndLayerBar->GetActiveView())->CreateView("1 LayView", RUNTIME_CLASS(CLayerManagerView), NULL);
return (0); }
void CLayerDockControlBar::OnSize(UINT nType, int cx, int cy) { CAcUiDockControlBar::OnSize(nType, cx, cy); if(m_pWndLayerBar) { if(!IsFloating()) m_pWndLayerBar->MoveWindow(0, 20, cx, cy-20); } }
void CLayerDockControlBar::SizeChanged(CRect *lpRect, BOOL bFloating, int flags) { CAcModuleResourceOverride resourceOverride; if (m_pWndLayerBar != NULL) { m_pWndLayerBar->MoveWindow(0,20,lpRect->right, lpRect->bottom-20); } }
以下为调用部份。
static CLayerDockControlBar *dockBar = NULL;
void LayerManager() { CAcModuleResourceOverride res; if (dockBar == NULL) { dockBar = new CLayerDockControlBar; dockBar->Create(acedGetAcadFrame(), "MyDockBar"); dockBar->SetWindowText( _T("HELLO")); } dockBar->EnableDocking(CBRS_ALIGN_ANY); acedGetAcadFrame()->EnableDocking(CBRS_ALIGN_ANY); acedGetAcadFrame()->DockControlBar(dockBar, AFX_IDW_DOCKBAR_LEFT); acedGetAcadFrame()->ShowControlBar(dockBar, TRUE, TRUE); SetActiveWindow(acedGetAcadFrame()->m_hWnd); } |