Hello,
I want to change the icon of my plugin object, depending on settings in the BaseContainer. It should be the normal icon of the object, with a little overlay in the corner. Sounds easy, and 'm sure I have done this years ago. But now, I can't get it to work.
The icon is set up with RegisterIcon during the register call. This works fine, the object does have the correct icon in the object manager.
Bool RegisterMyObject()
{
extern BaseBitmap * g_myIcons;
if (!RegisterIcon(ID_MYOBJECT, g_myIcons, 64, 0, 64, 64))
return false;
maxon::String name = GeLoadString(IDS_MYOBJECT);
return RegisterObjectPlugin(ID_MYOBJECT, name, OBJECT_GENERATOR, MyObject::Alloc, "omyobject", AutoBitmap(ID_MYOBJECT), 0);
}
Now I want to change the icon, so in MyObject::Message()
, I do:
Bool MyObject::Message(GeListNode *node, Int32 type, void *data)
{
switch (type)
{
case MSG_GETCUSTOMICON:
{
GetCustomIconData* const cid = static_cast<GetCustomIconData*>(data);
if (!cid)
return false;
// Let's see if the icon bitmap is there
BaseBitmap *iconBmp = cid->dat->bmp;
BaseBitmap *iconBmp2 = cid->dat->GetClonePart();
// What are the set flags?
ICONDATAFLAGS iconDataFlags = cid->dat->flags;
break;
}
}
return SUPER::Message(node, type, data);
}
Strangely, iconBmp
as well as iconBmp2
are correctly allocated, but are 0x0 pixels in size, and contain only black.
iconDataFlags
is ICONDATAFLAGS::NONE
.
Is that normal? I would have expected the bitmap to contain the icon of the object.
I also tried, just for a test, to simply write into the bitmap by copying an existing icon of another object (that icon was also registered with RegisterIcon()
):
BaseBitmap *originalIcon = AutoBitmap(ID_SOMEOTHEROBJECT);
originalIcon->CopyTo(cid->dat->bmp);
cid->filled = true;
But that simply makes my object's icon vanish, and now the object has no icon.
Also interesting, if I try to show any of the bitmaps (cid->dat->bmp
, or cid->dat->GetClonePart()
, or originalIcon
) in the Picture Viewer with ShowBitmap()
, I always get a 0x0 pixel black bitmap. Why is it empty? And why doesn't even the originalIcon
work?
Thanks for tips & advice!
Cheers,
Frank