// ----- zhfzhftool._dttk command (do not rename) static void zhfzhftool_dttk(void) { // Add your code for command zhfzhftool._dttk here if (g_bIsTukuFirst) { InitApplication() ; } else { CMDIFrameWnd* pAcadFrame = acedGetAcadFrame(); if (g_pArrayZhfPaletteSet.GetCount()>1) { CZhfPaletteSet* pSet = g_pArrayZhfPaletteSet.GetAt(1) ; if (pSet->IsWindowVisible()) { pAcadFrame->ShowControlBar(pSet, FALSE, FALSE); } else { pAcadFrame->ShowControlBar(pSet, TRUE, FALSE); } } else { acutPrintf(_T("\n图库面板没有创建或创建失败,无法显示!")) ; } } }
BOOL CLayerManager::ShowDockPane(BOOL bShow /*= TRUE*/) { CMDIFrameWnd *pAcadFrame = acedGetAcadFrame(); if (pAcadFrame) { pAcadFrame->ShowControlBar(this, bShow, FALSE); return TRUE; } return FALSE; }
void ArxCtrlBarShowSwitch::ShowParentControlBar( CWnd* pWnd, BOOL bShow ) { CAcModuleResourceOverride myResources; CControlBar* pBar = reinterpret_cast<CControlBar*>( pWnd->GetParent() ); if( pBar == 0 ) return; CMDIFrameWnd* pAcadFrame = acedGetAcadFrame(); if( pAcadFrame == 0 ) return; pAcadFrame->ShowControlBar( pBar, bShow, FALSE ); }
int CSpeechFrm::OnCreate(LPCREATESTRUCT lpCreateStruct) { CMDIFrameWnd *mainWnd; // Register the doc templates we provide to the app CWinApp* pApp = AfxGetApp(); ASSERT(pApp != NULL); mainWnd = DYNAMIC_DOWNCAST(CMDIFrameWnd, pApp->m_pMainWnd); // get the apps instance handle for loading resources m_AppInst = AfxGetResourceHandle(); // now tell the application to look in dll for resources AfxSetResourceHandle(ObjectSpeechDLL.hModule); if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_SpeechToolPal.CreateEx(mainWnd, TBSTYLE_FLAT | TBSTYLE_WRAPABLE , WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED, CRect(0, 2, 2, 4)) || !m_SpeechToolPal.LoadToolBar(IDR_Speech_TOOL_PALETTE)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } m_SpeechToolPal.SetBorders(2, 2, 2, 2); m_SpeechToolPal.EnableDocking(CBRS_ORIENT_VERT); // make control bar notify us. mainWnd->DockControlBar(&m_SpeechToolPal); CRect tcRect; m_SpeechToolPal.GetToolBarCtrl().SetRows(1, FALSE, tcRect); int iconWidth; int iconHeight; int nRows; iconWidth = tcRect.Width()/NUMICONS; iconHeight = tcRect.Height(); nRows = (NUMICONS / NICONSWIDE) + (((NUMICONS % NICONSWIDE) == 0) ? 0 : 1); tcRect.SetRect(0, 0, iconWidth * NICONSWIDE, (iconHeight * nRows)); // Set the window size m_SpeechToolPal.SetWindowPos(NULL, 0, 0, tcRect.Width(), tcRect.Height(), SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW); mainWnd->ShowControlBar(&m_SpeechToolPal, FALSE, FALSE); AfxSetResourceHandle(m_AppInst); return 0; }
AcRx::AppRetCode CzhftoolApp::On_kUnloadDwgMsg(void * pkt) { CMDIFrameWnd* pAcadFrame = acedGetAcadFrame(); AcApDocManager *pDocMgr = acDocManager ; int iDocCount = pDocMgr->documentCount() ; if (iDocCount==1) { for (int i=0; i<g_pArrayZhfPaletteSet.GetCount(); i++) { CZhfPaletteSet* pSet = g_pArrayZhfPaletteSet.GetAt(i) ; if (pSet->IsWindowVisible()) { pAcadFrame->ShowControlBar(pSet, FALSE, FALSE); } } } AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadDwgMsg (pkt) ; return (retCode) ; }
void CzhftoolApp::InitApplication(void) { CMDIFrameWnd* pAcadFrame = acedGetAcadFrame(); CString strPaletteSetNames[] = {_T("平面图库"), _T("地铁图库")} ; for (int iIndexSet=0; iIndexSet<2; iIndexSet++) { CZhfPaletteSet* pSet = new CZhfPaletteSet ; CRect rect(0, 0, 320, 300); pSet->Create(strPaletteSetNames[iIndexSet], WS_OVERLAPPED|WS_DLGFRAME, rect, pAcadFrame, PSS_EDIT_NAME | PSS_PROPERTIES_MENU | PSS_AUTO_ROLLUP | PSS_CLOSE_BUTTON) ; if (iIndexSet==0) { CString strFolds[] = {_T("xhj\\lj"), _T("xhj\\lf"), _T("xhj\\lfn"), _T("xhj\\dc"), _T("xhj\\yg"), _T("xhj\\tg"), _T("xhj\\fs"), _T("xhj\\dt"), _T("dc"), _T("jyj"), _T("box"), _T("dltb"), _T("jdq"), _T("sign"), _T("bg"), _T("dz"), _T("conti"), _T("pmt")} ; CString strPaletteNames[] = {_T("接车"), _T("发车"), _T("发车2"), _T("调车"), _T("预告"), _T("通过"), _T("复示"), _T("地铁"), _T("道岔"), _T("绝缘节"), _T("箱盒"), _T("电路"), _T("继电器"), _T("签字栏"), _T("表格"), _T("端子"), _T("连接符"), _T("其他")} ; int iFilterModes[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0} ; for (int i=0; i<18; i++) { CZhfPalette* pZhfPalette = new CZhfPalette() ; pZhfPalette->m_iFilterMode = iFilterModes[i] ; CString strFilePath ; CStringArray strArrayFile ; strFilePath.Format(_T("%s\\support\\%s"), g_strBasePath, strFolds[i]) ; CBlkUtility::FindFile(strFilePath, _T("dwg"), strArrayFile, 1) ; CBlkUtility::SortStringArray(strArrayFile) ; if (i==8)//将转辙机图形加入道岔项里面 { strFilePath.Format(_T("%s\\support\\zzj"), g_strBasePath) ; CStringArray strArrayPlus ; CBlkUtility::FindFile(strFilePath, _T("dwg"), strArrayPlus, 1) ; strArrayFile.Append(strArrayPlus) ; } if (i==12) { CStringArray strArrayFileNew ; for (int iJqdIndex=0; iJqdIndex<strArrayFile.GetCount(); iJqdIndex++) { if (strArrayFile.GetAt(iJqdIndex).Find(_T("Bold"))==-1) { strArrayFileNew.Add(strArrayFile.GetAt(iJqdIndex)) ; } } strArrayFile.RemoveAll() ; strArrayFile.Copy(strArrayFileNew) ; } pZhfPalette->m_strArrayFile.Copy(strArrayFile) ; CString strFileName ; for (int j=0; j<strArrayFile.GetCount(); j++) { CBlkUtility::GetFileName(strArrayFile.GetAt(j), strFileName) ; if (i<7) { CStringArray strArrayText ; CBlkUtility::DivideString(strFileName, _T("_"), strArrayText) ; strFileName.Format(_T("%s_%s"), strArrayText.GetAt(1), strArrayText.GetAt(2)) ; } pZhfPalette->m_strArrayFileName.Add(strFileName) ; } //if (i==1) { pZhfPalette->m_iCtrlWidth=80 ; pZhfPalette->m_iCtrlHeight = 80 ; } pZhfPalette->Create(WS_CHILD | WS_VISIBLE|WS_VSCROLL,strPaletteNames[i], pSet, PS_EDIT_NAME); //pZhfPalette->AddControls() ; pSet->AddPalette(pZhfPalette) ; } // Finally show the palette set pSet->EnableDocking(CBRS_ALIGN_ANY); pSet->RestoreControlBar(); } else if (iIndexSet==1) { CString strFolds[] = {_T("dt")} ; CString strPaletteNames[] = {_T("地铁")} ; int iFilterModes[] = {0} ; for (int i=0; i<1; i++) { CZhfPalette* pZhfPalette = new CZhfPalette() ; pZhfPalette->m_iFilterMode = iFilterModes[i] ; CString strFilePath ; CStringArray strArrayFile ; strFilePath.Format(_T("%s\\support\\%s"), g_strBasePath, strFolds[i]) ; CBlkUtility::FindFile(strFilePath, _T("dwg"), strArrayFile, 1) ; CBlkUtility::SortStringArray(strArrayFile) ; pZhfPalette->m_strArrayFile.Copy(strArrayFile) ; CString strFileName ; for (int j=0; j<strArrayFile.GetCount(); j++) { CBlkUtility::GetFileName(strArrayFile.GetAt(j), strFileName) ; // if (i<7) // { // CStringArray strArrayText ; // CBlkUtility::DivideString(strFileName, _T("_"), strArrayText) ; // strFileName.Format(_T("%s_%s"), strArrayText.GetAt(1), strArrayText.GetAt(2)) ; // } pZhfPalette->m_strArrayFileName.Add(strFileName) ; } //if (i==1) { pZhfPalette->m_iCtrlWidth=80 ; pZhfPalette->m_iCtrlHeight = 80 ; } pZhfPalette->Create(WS_CHILD | WS_VISIBLE|WS_VSCROLL,strPaletteNames[i], pSet, PS_EDIT_NAME); pSet->AddPalette(pZhfPalette) ; } // Finally show the palette set pSet->EnableDocking(CBRS_ALIGN_ANY); pSet->RestoreControlBar(); } pAcadFrame->ShowControlBar(pSet, FALSE, FALSE); g_pArrayZhfPaletteSet.Add(pSet) ; } g_bIsTukuFirst = false ; //插入信号机时是否加绝缘节 DWORD iAddJyj = 1 ; CBlkUtility::QueryValueReg(_T("ZHFTOOLS"), _T("AddJyjWhenInsertXhj"), iAddJyj) ; g_bAddJyjWhenInsertXhj = (iAddJyj==1?true:false) ; }
void CDynToolBar::LoadState(char* pFilename) { CProfINIFile PF(pFilename); CMDIFrameWnd* pM = pTBMngr->pMainFrame; Strng Section; Section.Set("ToolBar_%d", iWindowID); Strng NewTitle = PF.RdStr(Section(), "Title", (char*)(const char*)sTitle); if (NewTitle.Length()!=sTitle.GetLength() || strcmp(NewTitle(), (const char*)sTitle)!=0) { SetWindowText(NewTitle()); sTitle = NewTitle(); } DWORD BarStyle = GetBarStyle(); DWORD Style = GetStyle(); BarStyle = PF.RdLong(Section(), "BarStyle", BarStyle); BarStyle &= CBRS_ALL; //CNM Prevent an ASSERT SetBarStyle(BarStyle); if (bCanConfigure) { CToolBarCtrl& bc = GetToolBarCtrl(); int Cnt = bc.GetButtonCount(); Cnt = PF.RdInt(Section(), "ButtonIDCount", Cnt); BOOL Chngd = (Cnt!=bc.GetButtonCount()); UINT* NewIDs = new UINT[Cnt]; Strng Item; for (int i=0; i<Cnt; i++) { Item.Set("ID_%d", i); int Cmd = (i<(int)iLen ? BtnIDs[i] : ID_SEPARATOR); Cmd = PF.RdInt(Section(), Item(), Cmd); NewIDs[i] = (UINT)Cmd; Chngd = (Chngd || (NewIDs[i]!=BtnIDs[i])); } if (Chngd) ChangeButtons(NewIDs, Cnt); delete []NewIDs; } flag Visible = ((Style & WS_VISIBLE) != 0); Visible = PF.RdInt(Section(), "Visible", Visible); pM->ShowControlBar(this, Visible, FALSE); pM->RecalcLayout(); //get MFC to adjust the dimensions of all docked ToolBars so that GetWindowRect will be accurate CRect Rect; CWnd* pWnd = GetParent(); if (BarStyle & CBRS_FLOATING) { if (pWnd && pWnd->GetParent()) { if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.OffsetRect(L-Rect.left, T-Rect.top); Rect.OffsetRect(+MRect.left, +MRect.top); } else { pWnd->GetParent()->GetWindowRect(&Rect); Location.x = PF.RdInt(Section(), "Left", Rect.left); Location.y = PF.RdInt(Section(), "Top", Rect.top); } pM->FloatControlBar(this, Location); } } else { GetWindowRect(&Rect); if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.OffsetRect(L-Rect.left, T-Rect.top); Rect.OffsetRect(+MRect.left, +MRect.top); } else { //Rect.left = PF.RdInt(Section(), "Left", Rect.left); //Rect.top = PF.RdInt(Section(), "Top", Rect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.right += L-Rect.left; Rect.bottom += T-Rect.top; Rect.left += L-Rect.left; Rect.top += T-Rect.top; } //Rect.top = PF.RdInt(Section(), "Top", Rect.top); UINT n = 0; if (BarStyle & CBRS_ALIGN_TOP) { Rect.top -= 1; Rect.bottom -= 1; n = AFX_IDW_DOCKBAR_TOP; } if (n==0 && BarStyle & CBRS_ALIGN_BOTTOM) { Rect.top += 1; Rect.bottom += 1; n = AFX_IDW_DOCKBAR_BOTTOM; } if (n==0 && BarStyle & CBRS_ALIGN_LEFT) { Rect.left -= 1; Rect.right -= 1; n = AFX_IDW_DOCKBAR_LEFT; } if (n==0 && BarStyle & CBRS_ALIGN_RIGHT) { Rect.left += 1; Rect.right += 1; n = AFX_IDW_DOCKBAR_RIGHT; } pM->DockControlBar(this, n, &Rect); } pM->RecalcLayout(); }