i am trying to add a menu in AutoCAD through the coding done in VC++ for ARX object.
what i need to do is: the menu should be added to the menu bar as soon as i load the arx object in AutoCAD and not after i enter a command at the prompt...
i will be really thankful if anyone can help me out in this.
i have done the programming, but at present the menu is added after writing the command at the prompt. where exactly should i write the code so tht the above query is solved ?
thank you all for reading this query,
Gaurav Shah...
Just one line is required to insert your menu at POP10.
(menucmd "P10=+MyMenuGroup.POP10")
"Gaurav" <nos...@address.withheld> wrote in message
news:15400008.1074678752872.JavaMail.javamailuser@localhost...
thanks a lot for ur reply.
but i dont want to add the menu manually in the txt file, this process should take place through coding. kindly reply if u have any idea for it.
again thanks a lot for your kind attention.
regards,
Gaurav..
"Calling acedMenuCmd() and passing "P1=test.numeric" assigns POP menu 12 to
POP menu 2, assuming that the following menu file definitions exist. "
"Gaurav" <nos...@address.withheld> wrote in message
news:8219993.107468171...@jiveforum1.autodesk.com...
void addMenuThroughCom()
{
AutoCAD::IAcadApplication *pAcad;
AutoCAD::IAcadMenuBar *pMenuBar;
AutoCAD::IAcadMenuGroups *pMenuGroups;
AutoCAD::IAcadMenuGroup *pMenuGroup;
AutoCAD::IAcadPopupMenus *pPopUpMenus;
AutoCAD::IAcadPopupMenu *pPopUpMenu;
AutoCAD::IAcadPopupMenuItem *pPopUpMenuItem;
HRESULT hr = NOERROR;
CLSID clsid;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = NULL;
hr = ::CLSIDFromProgID(L"AutoCAD.Application", &clsid);
if (SUCCEEDED(hr))
{
if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK)
{
if (pUnk->QueryInterface(IID_IDispatch, (LPVOID*)
&pAcadDisp) != S_OK)
return;
pUnk->Release();
}
}
if (SUCCEEDED(pAcadDisp->QueryInterface
(AutoCAD::IID_IAcadApplication,(void**)&pAcad))) {
pAcad->put_Visible(true);
}
else
{
acutPrintf("\nQueryInterface trouble.");
return;
}
pAcad->get_MenuBar(&pMenuBar);
pAcad->get_MenuGroups(&pMenuGroups);
pAcad->Release();
long numberOfMenus;
pMenuBar->get_Count(&numberOfMenus);
pMenuBar->Release();
VARIANT index;
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
pMenuGroups->Item(index, &pMenuGroup);
pMenuGroups->Release();
pMenuGroup->get_Menus(&pPopUpMenus);
pMenuGroup->Release();
WCHAR wstrMenuName[256];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, "AsdkComAccess",
-1, wstrMenuName, 256);
if (!bIsMenuLoaded) {
pPopUpMenus->Add(wstrMenuName, &pPopUpMenu);
if (pPopUpMenu != NULL) {
pPopUpMenu->put_Name(wstrMenuName);
WCHAR wstrMenuItemName[256];
MultiByteToWideChar(CP_ACP, 0,"&Add A ComCircle",
-1, wstrMenuItemName, 256);
WCHAR wstrMenuItemMacro[256];
MultiByteToWideChar(CP_ACP, 0, "AsdkComCircle ",
-1, wstrMenuItemMacro, 256);
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
pPopUpMenu->AddMenuItem(index, wstrMenuItemName,
wstrMenuItemMacro, &pPopUpMenuItem);
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 1;
pPopUpMenu->AddSeparator(index,&pPopUpMenuItem);
MultiByteToWideChar(CP_ACP, 0,"Auto&LISP Example", -1,
wstrMenuItemName, 256);
MultiByteToWideChar(CP_ACP, 0,"(prin1 \"Hello\") ", -1,
wstrMenuItemMacro, 256);
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 2;
pPopUpMenu->AddMenuItem(index, wstrMenuItemName,
wstrMenuItemMacro, &pPopUpMenuItem);
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = numberOfMenus - 2;;
pPopUpMenu->InsertInMenuBar(index);
pPopUpMenu->Release();
pPopUpMenuItem->Release();
bIsMenuLoaded = true;
} else {
acutPrintf("\nMenu not created.");
}
} else {
VariantInit(&index);
V_VT(&index) = VT_BSTR;
V_BSTR(&index) = wstrMenuName;
pPopUpMenus->RemoveMenuFromMenuBar(index);
bIsMenuLoaded = false;
}
pPopUpMenus->Release();
}
regards
M Ram Kumar.
Chennai.
"Zatopek" <zat...@viasys.se> wrote in message news:<400e5936_3@newsprd01>...
i tried doing the process using acedMenuCmd().
but its not working. can u suggest any other method for adding the menu into the menu bar as soon as i load my ARX. it shud not get added when i start AutoCAD, but only after i load my ARX object.
thanks a lot for ur kind attension.
Gaurav
IAcadMenuGroup *mnuGrp = NULL;
if (!getAcadMenuGroup(&mnuGrp)) return ;
//now get all the popup menus
IAcadPopupMenus *mnus = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Menus(&mnus);
long cnt;
VARIANT vtIndex2;
IAcadPopupMenu *polyMnu2 = NULL;
hr = mnus->Add(L"My menu", &polyMnu2);
mnus->get_Count(&cnt);
vtIndex2.lVal = cnt;
vtIndex2 = 10; //menu number - but it didn't worked...don't now why it
apears as 1st menu
mnus->InsertMenuInMenuBar(L"My menu", vtIndex2 );
mnuGrp->Release();
mnus->Release();
Anyway, see Polysamp example!
QUESTION: Does someone know how can I insert my bitmap on a Toolbar from
some resource inside my prroject? (Without calling ->Set), or how can I make
a bitmap resource dll?
Vladdygo.
Have fun,
Helio Santana
"Gaurav" <nos...@address.withheld> escribió en el mensaje
news:15400008.1074678752872.JavaMail.javamailuser@localhost...
thankz a lot for ur help...
i got a clue from it and did the required job...
now i am facing a new problem, i have added the menu in AutoCAD through ObjectARX code in VC++ but now i need to add a submenu items to one of the option in the menu, for which i dont have any clue....can anyone please help me out from this ? thanks a lot to everyone for readng this query.
waiting for a clue,
Gaurav.
SEE "polysamp" sample !!!!
But, my advice : create a *.mnu file - it may contain all menus & toolbars
you want, including bitmaps for toolbars (wich reside in an external bitmap
resource dll. The dll must be named exactly the same with mnu file name, &
<Ing Bernd Cuder helped me on that> bitmap names must be like
"mybitmap16" -where mybitmap16 is your res bmp name).
This metod is easyer. If yo want to build your toolbars from arx : surprise
: you CAN'T put bitmaps on them (except bmp's on hdd...). With menus it
works.
"Gaurav" <nos...@address.withheld> wrote in message
news:32724102.107518297...@jiveforum1.autodesk.com...