本文整理汇总了C++中IAcadMenuGroup::get_Toolbars方法的典型用法代码示例。如果您正苦于以下问题:C++ IAcadMenuGroup::get_Toolbars方法的具体用法?C++ IAcadMenuGroup::get_Toolbars怎么用?C++ IAcadMenuGroup::get_Toolbars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAcadMenuGroup
的用法示例。
在下文中一共展示了IAcadMenuGroup::get_Toolbars方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateToolbars
void CreateToolbars()
{
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp))
return ;
//now get all the popup menus
IAcadToolbars *tlbrs = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Toolbars(&tlbrs);
mnuGrp->Release();
//let us create toolbars for polysamp
IAcadToolbar *tlbr = NULL;
hr = tlbrs->Add(L"POLYSAMP APPLICATION", &tlbr);
if FAILED(hr)
return;
tlbrs->Release();
//now add toolbar buttons
IAcadToolbarItem *button1 = NULL;
IAcadToolbarItem *button2 = NULL;
IAcadToolbarItem *button3 = NULL;
IAcadToolbarItem *button4, *button5, *button6, *button7, *button8 = NULL;
VARIANT index;
index.vt = VT_I4;
index.lVal = 100l;
VARIANT vtFalse;
vtFalse.vt = VT_BOOL;
vtFalse.boolVal = VARIANT_FALSE;
hr = tlbr->AddToolbarButton(index, L"POLY", L"Creates poly entity", L"_poly ", vtFalse, &button1);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"DRAGPOLY", L"Creates poly entity using dragging", L"_dragpoly ", vtFalse, &button2);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"POLYEDIT", L"Edits poly entity", L"_POLYEDIT ", vtFalse, &button3);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"TRANSACT", L"Test Transaction on poly entity", L"_TRANSACT ", vtFalse, &button4);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"HILITPOLY", L"Hilight poly entity", L"_HILITPOLY ", vtFalse, &button5);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"HILITSOLID", L"Hilight solid entity", L"_HILITSOLID ", vtFalse, &button1);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"CREATEINSERT", L"Creates inserted entity", L"_CREATEINSERT ", vtFalse, &button6);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"HILITINSERT", L"Highlight inserted entity", L"_HILITINSERT ", vtFalse, &button7);
button1->Release();
hr = tlbr->AddToolbarButton(index, L"USEDRAGDATA", L"Test user dragging mechanism", L"_USEDRAGDATA ", vtFalse, &button8);
button1->Release();
tlbr->Dock(acToolbarDockLeft);
tlbr->Release();
return;
}
示例2: GetAcadToolBar
bool ArxToolBar::GetAcadToolBar( IAcadToolbar** pVal, LPCTSTR menuname )
{
// 获取主菜单组
IAcadMenuGroup* mnuGrp = NULL;
if ( !GetAcadMenuGroup( &mnuGrp ) )
return false;
//得到所有工具栏
HRESULT hr = S_OK;
IAcadToolbars* acToolbars = NULL;
hr = mnuGrp->get_Toolbars( &acToolbars );
if ( FAILED( hr ) )
{
mnuGrp->Release();
return false;
}
long cnt = 0;
hr = acToolbars->get_Count( &cnt );
//得到菜单组
IAcadToolbar* acToolbar = NULL;
VARIANT vtName;
vtName.vt = VT_I4;
BSTR toolBarName;
bool found = false ;
for ( long i = 0; i < cnt; i++ )
{
vtName.lVal = i;
hr = acToolbars->Item( vtName, &acToolbar );
if ( FAILED( hr ) )
{
acToolbars->Release();
return false;
}
acToolbar->get_Name( &toolBarName );
acToolbar->Release();
CString sToolBarName( toolBarName );
SysFreeString( toolBarName );
if( sToolBarName.CompareNoCase( menuname ) == 0 )
{
found = true;
*pVal = acToolbar;
break;
}
}
acToolbars->Release();
mnuGrp->Release();
return found;
}
示例3: CleanToolbars
void CleanToolbars()
{
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp))
return ;
IAcadToolbars *tlbrs = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Toolbars(&tlbrs);
mnuGrp->Release();
long cnt = 0;
hr = tlbrs->get_Count(&cnt);
IAcadToolbar *polyTlbr = NULL;
BSTR tempName;
VARIANT vtName;
for (long i = cnt-1; i >0 ; i--)
{
vtName.vt = VT_I4;
vtName.lVal = i;
hr = tlbrs->Item(vtName, &polyTlbr);
hr = polyTlbr->get_Name(&tempName);
CString tlbrName(tempName);
SysFreeString(tempName);
OutputDebugString(tlbrName);
BOOL bFind = FALSE;
for (int j = 0; j < Glb_toolbarArray.GetSize(); j++)
{
if (tlbrName.CompareNoCase(Glb_toolbarArray.GetAt(j))==0)
{
bFind = TRUE;
polyTlbr->Delete();
break;
}
}
if (!bFind)
polyTlbr->Release();
}
tlbrs->Release();
Glb_toolbarArray.RemoveAll();
return;
}
示例4: CleanUpToolbars
void CleanUpToolbars()
{
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp))
return ;
IAcadToolbars *tlbrs = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Toolbars(&tlbrs);
mnuGrp->Release();
long cnt = 0;
hr = tlbrs->get_Count(&cnt);
IAcadToolbar *polyTlbr = NULL;
BSTR tempName;
VARIANT vtName;
for ( long i=0; i < cnt; i++)
{
vtName.vt = VT_I4;
vtName.lVal = i;
hr = tlbrs->Item(vtName, &polyTlbr);
hr = polyTlbr->get_Name(&tempName);
CString tlbrName(tempName);
SysFreeString(tempName);
if(tlbrName.CompareNoCase("POLYSAMP APPLICATION")==0)
{
polyTlbr->Delete();
//can not call following because delete has already removed it.
// polyTlbr->Release();
break;
}
else
polyTlbr->Release();
}
tlbrs->Release();
return;
}
示例5: CreateToolbars
void CreateToolbars()
{
if (Glb_toolbarArray.GetCount() > 0)
return;
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp))
return ;
IAcadToolbars *tlbrs = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Toolbars(&tlbrs);
mnuGrp->Release();
// 得到arx所在路径
TCHAR lpPath[MAX_PATH] = {0};
GetModuleFileName(GetModuleHandle("DistToolBar.arx"), lpPath, MAX_PATH);
PathRemoveFileSpec(lpPath);
PathAddBackslash(lpPath);
CString strXmlFile = lpPath;
strXmlFile += "toolbar.xml";
// 得到icon路径
PathAppend(lpPath, "icon");
PathAddBackslash(lpPath);
MSXML2::IXMLDOMDocumentPtr lpDocument;
hr = lpDocument.CreateInstance(__uuidof(DOMDocument));
if ( FAILED(hr) )
_com_raise_error(hr);
VARIANT_BOOL isSuccessful;
// 装载XML字符串
if (!lpDocument->load(_variant_t(strXmlFile)))
{
OutputDebugString("LoadXML failed!");
return;
}
MSXML2::IXMLDOMElementPtr lpDocElement = NULL;
lpDocument->get_documentElement(&lpDocElement);
// toolbar list
MSXML2::IXMLDOMNodeListPtr lpToolbarList = lpDocElement->getElementsByTagName(_bstr_t("toolbar"));
MSXML2::IXMLDOMNodePtr lpToolbar = NULL;
for ( ; (lpToolbar = lpToolbarList->nextNode()) != NULL ; )
{
MSXML2::IXMLDOMNodePtr lpCaptionNode = lpToolbar->attributes->getNamedItem("caption");
CString strCaption = (char*)lpCaptionNode->text;
OutputDebugString(strCaption);
// 添加工具条
IAcadToolbar *tlbr = NULL;
hr = tlbrs->Add(CComBSTR(strCaption), &tlbr);
if FAILED(hr)
continue;
Glb_toolbarArray.Add(strCaption);
// button list
MSXML2::IXMLDOMNodeListPtr lpButtonList = lpToolbar->GetchildNodes();
MSXML2::IXMLDOMNodePtr lpButton = NULL;
for ( ; (lpButton = lpButtonList->nextNode()) != NULL ; )
{
MSXML2::IXMLDOMNodePtr lpToolTipNode = lpButton->attributes->getNamedItem("tooltip");
CString strToolTip = (char*)lpToolTipNode->text;
MSXML2::IXMLDOMNodePtr lpCommandNode = lpButton->attributes->getNamedItem("command");
CString strCommand = (char*)lpCommandNode->text;
strCommand += " ";
MSXML2::IXMLDOMNodePtr lpIconNode = lpButton->attributes->getNamedItem("icon");
CString strIcon = (char*)lpIconNode->text;
OutputDebugStringX("tooltip=%s, command=%s, icon=%s", strToolTip, strCommand, strIcon);
// 添加工具按钮
IAcadToolbarItem *button=NULL;
VARIANT index;
index.vt = VT_I4;
index.lVal = 100l;
VARIANT vtFalse;
vtFalse.vt = VT_BOOL;
vtFalse.boolVal = VARIANT_FALSE;
CString strIconFile = lpPath;
strIconFile += strIcon;
//.........这里部分代码省略.........
示例6: CreateToolBars
void ArxToolBar::CreateToolBars( const TCHAR* bmpDir )
{
CMDIFrameWnd* pMainFrame = acedGetAcadFrame();
pMainFrame->LockWindowUpdate();
// 获取主菜单组
IAcadMenuGroup* mnuGrp = NULL;
if ( !GetAcadMenuGroup( &mnuGrp ) )
return ;
//得到所有菜单组
HRESULT hr = S_OK;
IAcadToolbars* acToolbars = NULL;
hr = mnuGrp->get_Toolbars( &acToolbars );
// 如果bmpDir路径没有反斜杠(\),则添加一个反斜杠
CString path( bmpDir );
// 取最后一个字符
if( path.Right( 1 ) != _T( "\\" ) )
{
path.Format( _T( "%s\\" ), bmpDir );
}
VARIANT index;
VariantInit( &index );
V_VT( &index ) = VT_I4;
TCHAR MenuName[256];
int delta = 30; // 工具栏间距
int top = 200, left = 200;
for ( int i = 0; i < m_menuCount; i++ )
{
IAcadToolbar* acToolbar = NULL;
_tcscpy( MenuName, m_TopMenuNames[i] );
hr = acToolbars->Add( MenuName, &acToolbar );
acToolbar->put_Visible( true );
acToolbar->Dock( acToolbarFloating );
acToolbar->Float( top + i * delta, left, 1 );
CCADToolButtonArray* Menus = m_menus[i];
COleVariant flyOutButton;
for ( int j = 0; j < Menus->GetSize(); j++ )
{
// 添加按钮
V_I4( &index ) = ( long )j;
CADToolButton* btn = Menus->GetAt( j );
IAcadToolbarItem* acToolbarItem = NULL;
if( _tcscmp( _T( "--" ), btn->name ) == 0 )
{
hr = acToolbar->AddSeparator( index, &acToolbarItem );
}
else
{
hr = acToolbar->AddToolbarButton( index, btn->name, btn->help, btn->order, flyOutButton, &acToolbarItem );
TCHAR szBmpFile[256];
_stprintf( szBmpFile, _T( "%s%s" ), path, btn->bmp );
//acutPrintf(_T("\n路径:%s"), szBmpFile);
hr = acToolbarItem->SetBitmaps( szBmpFile, szBmpFile );
}
}
//acToolbarItem->Release();
acToolbar->Release();
}
acToolbars->Release();
mnuGrp->Release();
pMainFrame->UnlockWindowUpdate();
//stcMyToolBarNames.Copy(m_TopMenuNames); //将工具栏名称存入静态数组中,卸载时使用
}
示例7: CreateToolbars
void CreateToolbars()
{
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp))
return ;
//now get all the popup menus
IAcadToolbars *tlbrs = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Toolbars(&tlbrs);
mnuGrp->Release();
//let us create toolbars for polysamp
IAcadToolbar *tlbr = NULL;
hr = tlbrs->Add(L"POLYSAMP APPLICATION", &tlbr);
if FAILED(hr)
return;
tlbrs->Release();
//now add toolbar buttons
IAcadToolbarItem *button=NULL;
VARIANT index;
index.vt = VT_I4;
index.lVal = 100l;
VARIANT vtFalse;
vtFalse.vt = VT_BOOL;
vtFalse.boolVal = VARIANT_FALSE;
TCHAR szFileName[MAX_PATH];
GetModuleFileName(GetModuleHandle(_T("asdkPolyUi.arx")),szFileName,MAX_PATH);
CString csPath(szFileName);
csPath=csPath.Left(csPath.ReverseFind(_T('\\')));
//x64 binaries are created within x64\ folder
#if defined(_WIN64) || defined(_AC64)
csPath=csPath.Left(csPath.ReverseFind(_T('\\')));
#endif
csPath=csPath.Left(csPath.ReverseFind(_T('\\'))+1);
hr = tlbr->AddToolbarButton(index, L"POLY", L"Creates poly entity", L"_poly ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly1.ico")),CComBSTR(csPath+_T("1_Poly1.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"DRAGPOLY", L"Creates poly entity using dragging", L"_dragpoly ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly2.ico")),CComBSTR(csPath+_T("1_Poly2.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"POLYEDIT", L"Edits poly entity", L"_POLYEDIT ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly3.ico")),CComBSTR(csPath+_T("1_Poly3.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"TRANSACT", L"Test Transaction on poly entity", L"_TRANSACT ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly4.ico")),CComBSTR(csPath+_T("1_Poly4.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"HILITPOLY", L"Hilight poly entity", L"_HILITPOLY ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly5.ico")),CComBSTR(csPath+_T("1_Poly5.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"HILITSOLID", L"Hilight solid entity", L"_HILITSOLID ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly6.ico")),CComBSTR(csPath+_T("1_Poly6.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"CREATEINSERT", L"Creates inserted entity", L"_CREATEINSERT ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly7.ico")),CComBSTR(csPath+_T("1_Poly7.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"HILITINSERT", L"Highlight inserted entity", L"_HILITINSERT ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly8.ico")),CComBSTR(csPath+_T("1_Poly8.ico")));
button->Release();
hr = tlbr->AddToolbarButton(index, L"USEDRAGDATA", L"Test user dragging mechanism", L"_USEDRAGDATA ", vtFalse, &button);
hr=button->SetBitmaps(CComBSTR(csPath+_T("1_Poly1.ico")),CComBSTR(csPath+_T("1_Poly1.ico")));
button->Release();
tlbr->Dock(acToolbarDockLeft);
tlbr->Release();
return;
}
示例8: CreateToolBars
void AppToolBar::CreateToolBars()
{
CMDIFrameWnd* pMainFrame = acedGetAcadFrame();
pMainFrame->LockWindowUpdate();
// 获取主菜单组
IAcadMenuGroup* mnuGrp = NULL;
if ( !GetAcadMenuGroup( &mnuGrp ) )
return ;
//得到所有菜单组
HRESULT hr = S_OK;
IAcadToolbars* acToolbars = NULL;
hr = mnuGrp->get_Toolbars( &acToolbars );
CString appFileName = acedGetAppName(); //取出完整的应用程序名称,含路径
TCHAR dir[_MAX_DIR], drive[_MAX_DRIVE], path[_MAX_PATH];
_tsplitpath( appFileName, drive, dir, NULL, NULL );
_tmakepath( path, drive, dir, NULL, NULL );
VARIANT index;
VariantInit( &index );
V_VT( &index ) = VT_I4;
TCHAR MenuName[256];
int delta = 30; // 工具栏间距
int top = 200, left = 200;
for ( int i = 0; i < m_menuCount; i++ )
{
IAcadToolbar* acToolbar = NULL;
_tcscpy( MenuName, m_TopMenuNames[i] );
hr = acToolbars->Add( MenuName, &acToolbar );
acToolbar->put_Visible( true );
acToolbar->Dock( acToolbarFloating );
acToolbar->Float( top + i * delta, left, 1 );
CCADToolButtonArray* Menus = m_menus[i];
COleVariant flyOutButton;
for ( int j = 0; j < Menus->GetSize(); j++ )
{
// 添加按钮
V_I4( &index ) = ( long )j;
CADToolButton* btn = Menus->GetAt( j );
IAcadToolbarItem* acToolbarItem = NULL;
if( _tcscmp( _T( "--" ), btn->name ) == 0 )
{
hr = acToolbar->AddSeparator( index, &acToolbarItem );
}
else
{
hr = acToolbar->AddToolbarButton( index, btn->name, btn->help, btn->order, flyOutButton, &acToolbarItem );
CString bmpFile;
bmpFile.Format( _T( "%s%s\\%s" ), path, BMP_DIR, btn->bmp );
TCHAR szBmpFile[256];
_tcscpy( szBmpFile, bmpFile );
//acutPrintf(_T("\n路径:%s"), szBmpFile);
hr = acToolbarItem->SetBitmaps( szBmpFile, szBmpFile );
}
}
//acToolbarItem->Release();
acToolbar->Release();
}
acToolbars->Release();
mnuGrp->Release();
pMainFrame->UnlockWindowUpdate();
stcMyToolBarNames.Copy( m_TopMenuNames ); //将工具栏名称存入静态数组中,卸载时使用
}