最近我遇到个问题,我自己下载了个DockBar作为控件,没用Acui的,但是还是存在首次Dock到CAD边界时候,高度不够,没有填充完整。
希望那位大哥解惑
// add the define
#include "StdAfx.h" #include "DockBar.h" #include "Resource.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
///////////////////////////////////////////////////////////////////////////// // CMyBar
CMyDockBar::CMyDockBar() { }
CMyDockBar::~CMyDockBar() { }
BEGIN_MESSAGE_MAP(CMyDockBar, baseCMyBar) //{{AFX_MSG_MAP(CMyDockBar) ON_WM_CREATE() ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnTcnSelchangeTab) ON_NOTIFY(NM_DBLCLK, IDC_TREE, OnNMDblclkTree) // ON_NOTIFY(WM_WINDOWPOSCHANGED,IDD_DOCKBAR,OnWindowPosChanging) END_MESSAGE_MAP()
//ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnTcnSelchangeTab)
///////////////////////////////////////////////////////////////////////////// // CMyDockBar message handlers
int CMyDockBar::OnCreate(LPCREATESTRUCT lpCreateStruct) {
CAcModuleResourceOverride resourceOverride ;
if (baseCMyBar::OnCreate(lpCreateStruct) == -1) return -1;
SetSCBStyle(GetSCBStyle() | SCBS_SIZECHILD);
//m_wndChild = new CChildDlg;
//m_wndChild->Create(IDD_DIALOG1,this); ////m_wndChild->OnInitDialog(); //m_wndChild->MoveWindow(0, 0, 100, 100, TRUE); /*if (!m_wndChild.Create(WS_CHILD|WS_VISIBLE| ES_MULTILINE|ES_WANTRETURN|ES_AUTOVSCROLL, CRect(0,0,0,0), this, 123)) return -1;*/ /*if (!m_wndIBTab.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP,CRect(0, 0, 0, 0), this, 100)) {
m_wndIBTab.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_wndIBTab.InsertItem(0,_T("隧道设计")); m_wndIBTab.InsertItem(1,_T("隧道监测")); m_wndIBTab.InsertItem(2,_T("隧道施工")); } m_wndIBTab.MoveWindow(0,0,200,600,TRUE);*/
//if (!m_wndIBTree.Create(WS_CHILD|WS_VISIBLE| // TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, // Trect, this, 100)) //{ // TRACE0("Failed to create instant bar child\n"); // return -1; // fail to create //}
//m_wndIBTree.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
//// populate the treectrl //HTREEITEM hti = m_wndIBTree.InsertItem(_T("Node 1")); //m_wndIBTree.InsertItem(_T("Node 2")); //m_wndIBTree.InsertItem(_T("SubNode 11"), hti); //m_wndIBTree.InsertItem(_T("SubNode 12"), hti); //m_wndIBTree.InsertItem(_T("SubNode 13"), hti); //m_wndIBTree.InsertItem(_T("SubNode 14"), hti); //m_wndIBTree.InsertItem(_T("SubNode 15"), hti); //m_wndIBTree.InsertItem(_T("SubNode 16"), hti); //m_wndIBTree.InsertItem(_T("SubNode 17"), hti); //m_wndIBTree.InsertItem(_T("SubNode 18"), hti); //m_wndIBTree.InsertItem(_T("SubNode 19"), hti); //m_wndIBTree.InsertItem(_T("SubNode 121"), hti); //m_wndIBTree.InsertItem(_T("SubNode 122"), hti);
//m_wndIBTree.MoveWindow(0,0,100,600,TRUE);
if (m_Tab.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,200,6000),this,IDC_TAB)) {
m_Tab.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
m_Tab.InsertItem(0,_T("隧道设计")); m_Tab.InsertItem(1,_T("隧道监测")); m_Tab.InsertItem(2,_T("隧道施工"));
//m_Tab.MoveWindow(0,0,200,600);
if (!m_wndIBTree.Create(WS_CHILD|WS_VISIBLE| TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, CRect(0,30,200,6000), &m_Tab, IDC_TREE)) { TRACE0("Failed to create instant bar child\n"); return -1; // fail to create }
m_wndIBTree.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
// populate the treectrl HTREEITEM hti = m_wndIBTree.InsertItem(_T("Node 1")); m_wndIBTree.InsertItem(_T("Node 2")); m_wndIBTree.InsertItem(_T("SubNode 11"), hti); m_wndIBTree.InsertItem(_T("SubNode 12"), hti); m_wndIBTree.InsertItem(_T("SubNode 13"), hti); m_wndIBTree.InsertItem(_T("SubNode 14"), hti); m_wndIBTree.InsertItem(_T("SubNode 15"), hti); m_wndIBTree.InsertItem(_T("SubNode 16"), hti); m_wndIBTree.InsertItem(_T("SubNode 17"), hti); m_wndIBTree.InsertItem(_T("SubNode 18"), hti); m_wndIBTree.InsertItem(_T("SubNode 19"), hti); m_wndIBTree.InsertItem(_T("SubNode 121"), hti); m_wndIBTree.InsertItem(_T("SubNode 122"), hti);
m_wndIBTree.MoveWindow(0,30,200,600,TRUE);
}
// --- end instant bar creation and child setup ---
//m_wndChild.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
//// older versions of Windows* (NT 3.51 for instance) //// fail with DEFAULT_GUI_FONT //if (!m_font.CreateStockObject(DEFAULT_GUI_FONT)) // if (!m_font.CreatePointFont(80, _T("MS Sans Serif"))) // return -1;
//m_wndChild.SetFont(&m_font);
return 0; }
void CMyDockBar::OnTcnSelchangeTab(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: Add your control notification handler code here if (m_Tab.GetCurSel()==0) { m_wndIBTree.ShowWindow(SW_SHOW); } if (m_Tab.GetCurSel()==1) { m_wndIBTree.ShowWindow(SW_HIDE);
} if (m_Tab.GetCurSel()==2) { m_wndIBTree.ShowWindow(SW_HIDE);
}
}
void CMyDockBar::OnNMDblclkTree(NMHDR *pNMHDR, LRESULT *pResult) { // TODO: Add your control notification handler code here NMTVDISPINFO* pNMTreeView = (NMTVDISPINFO*)pNMHDR;
CString szText; HTREEITEM Item2;
Item2 = m_wndIBTree.GetSelectedItem(); szText = m_wndIBTree.GetItemText(Item2); if (szText==_T("SubNode 11")) { CChildDlgII dlg1; dlg1.DoModal(); }
if (szText==_T("SubNode 12")) { CChildDlgII Dlg2; Dlg2.DoModal(); }
*pResult = 0; }
void CMyDockBar::OnLButtonUp(UINT nFlags, CPoint point) { if (m_bTracking) StopTracking();
baseCMyBar::OnLButtonUp(nFlags, point);
MoveWindow(0,0,200,600); }
void CMyDockBar::OnSize(UINT nType, int cx, int cy) { baseCMyBar::OnSize(nType, cx, cy);
SetWindowPos(acedGetAcadFrame(),0,0,200,600,TRUE); }
//////////////////////////////////////////////////////////////////////////
BOOL InitApp() { CMyDockBar *m_wndInstantBar = NULL; //CTreeCtrl m_wndIBTree; //HTREEITEM TreeItem;
CAcModuleResourceOverride res;
// --- instant bar ---
if ( !m_wndInstantBar) { m_wndInstantBar = new CMyDockBar;
if (!m_wndInstantBar->Create(_T("Instant Bar"), acedGetAcadFrame(), IDD_DOCKBAR,WS_CHILD|WS_VISIBLE|CBRS_ALIGN_LEFT|CBRS_SIZE_DYNAMIC)) { TRACE0("Failed to create instant bar\n"); return -1; // fail to create } m_wndInstantBar->SetSCBStyle(m_wndInstantBar->GetSCBStyle() | SCBS_SIZECHILD);
acedGetAcadFrame()->EnableAutomation();
//if (!m_wndIBTree.Create(WS_CHILD|WS_VISIBLE| // TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, // CRect(0, 0, 0, 0), m_wndInstantBar, 100)) //{ // TRACE0("Failed to create instant bar child\n"); // return -1; // fail to create //} //m_wndIBTree.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
// //// populate the treectrl //HTREEITEM hti = m_wndIBTree.InsertItem(_T("Node 1")); //m_wndIBTree.InsertItem(_T("Node 2")); //m_wndIBTree.InsertItem(_T("SubNode 11"), hti); //m_wndIBTree.InsertItem(_T("SubNode 12"), hti); // --- end instant bar creation and child setup ---
m_wndInstantBar->SetBarStyle(m_wndInstantBar->GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY );
m_wndInstantBar->EnableAutomation();
//m_wndInstantBar.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT); m_wndInstantBar->EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT|CBRS_ALIGN_TOP);
// //#ifdef _SCB_REPLACE_MINIFRAME // m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); // // //#endif //_SCB_REPLACE_MINIFRAME AFX_IDW_DOCKBAR_LEFT
//acedGetAcadFrame()->DockControlBar(m_wndInstantBar,AFX_IDW_DOCKBAR_TOP,NULL);
acedGetAcadFrame()->FloatControlBar (m_wndInstantBar, CPoint(100, 100), CBRS_ALIGN_LEFT|CBRS_ALIGN_TOP|CBRS_ALIGN_RIGHT); acedGetAcadFrame ()->ShowControlBar (m_wndInstantBar, !m_wndInstantBar->IsVisible(), TRUE); //acedGetAcadFrame()->FloatControlBar (m_wndInstantBar, CPoint(100, 100), CBRS_ALIGN_LEFT|CBRS_ALIGN_TOP|CBRS_ALIGN_RIGHT);
//RestoreControlBar(AFX_IDW_DOCKBAR_LEFT , lpRect); acedGetAcadFrame()->RecalcLayout(TRUE); }
if(!m_wndInstantBar->IsVisible()) { acedGetAcadFrame ()->ShowControlBar (m_wndInstantBar, !m_wndInstantBar->IsVisible(), TRUE); } //DockControlBar(&m_wndInstantBar, AFX_IDW_DOCKBAR_LEFT); //ShowControlBar(&m_wndInstantBar, !m_wndInstantBar.IsVisible(), FALSE);
return TRUE;
}
|