明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2062|回复: 0

用CAcUiDockControlBar向CAD中加入自己的ControlBar出现问题,请各位高手急救!

[复制链接]
发表于 2005-8-15 16:23:00 | 显示全部楼层 |阅读模式

我创建了一个基于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);
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:30 , Processed in 0.161053 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表