- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've checked every post i could find in this forum. Some of them helped, but now I'm stucked.
I'm creating a Toolbar, and adding some buttons, everthing works fine. Then I'm setting the bitmaps for these buttons. And the bitmaps are in the resource, the are embeded with the plugin. When i launch the AutoCad from the Visual Studio the buttons has the bitmaps as icons, just as I expected. But runnig a release version of the plugin I get only the "Cloud with questin mark" icon for my buttons. I've got that during the debug AutoCad was geting the bitmaps in the path were all the sources and files are, and is set as working directory. Here is a piece of my code:
void defineToolbar()
{
//CAcModuleResourceOverride resOverride;
AutoCAD::IAcadApplication *pAcad;
AutoCAD::IAcadMenuGroups *pMenuGroups;
AutoCAD::IAcadMenuGroup *pMenuGroup;
AutoCAD::IAcadToolbars *pToolbars;
AutoCAD::IAcadToolbar *pToolbar;
AutoCAD::IAcadToolbarItem *pToolbarItem;
HRESULT hr = NOERROR;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication, (void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
pAcad->put_Visible(true);
pAcad->get_MenuGroups(&pMenuGroups);
pAcad->Release();
VARIANT index;
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
VARIANT flyoutButton;
VariantInit(&flyoutButton);
V_VT(&flyoutButton) = VT_BOOL;
V_BOOL(&flyoutButton) = 0;
pMenuGroups->Item(index, &pMenuGroup);
pMenuGroups->Release();
pMenuGroup->get_Toolbars(&pToolbars);
pMenuGroup->Release();
CString toolbarNameTmp;
toolbarNameTmp.Format(_T("%s Toolbar"), PLUGIN_NAME);
BSTR toolbarName = SysAllocString(toolbarNameTmp.AllocSysString());
HRESULT resultToolbar = pToolbars->Add(toolbarNameTmp, &pToolbar);
if (SUCCEEDED(resultToolbar))
{
VariantInit(&index);
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
BSTR bstrMenuItemMacro = _T("dosomething");
BSTR bstrMenuItemName = _T("Do something");
BSTR iconName = _T("TEST.BMP");
pToolbar->AddToolbarButton(index, bstrMenuItemName, NULL, bstrMenuItemMacro, flyoutButton, &pToolbarItem);
if(pToolbarItem != NULL)
{
pToolbarItem->SetBitmaps(iconName, iconName);
pToolbarItem->Release();
}
pToolbar->Release();
}
pToolbars->Release();
SysFreeString(toolbarName);
}
In the resource (.rc) I have
///////////////////////////////////////////////////////////////////////////// // // Bitmap // "TEST" BITMAP "TEST.bmp"
I read in some post that the ID from the Resource should be sorrunded with " so this is one of my attempts.
I tried:
BSTR iconName = _T("TEST"); // without the .bmp to match the resource ID
And I've confirmed that the resource is packed in the arx:
plugin.arx\.rsrc\1046\BITMAP\TEST.BMP
I think I tryied all that I found in the forums and the docs (including the VB documentation, as suggested on the posts)
Solved! Go to Solution.