MSG_DESCRIPTION_GETBITMAP is not triggered
-
On 01/09/2017 at 03:08, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R18
Platform: Windows ;
Language(s) : C++ ;---------
Hello.I need to change the image of a BitmapButton in a NodeData description.
Here is how I handle the bitmap button in the description:
const DescID* single_id = description->GetSingleDescID(); DescID custom_button = DescLevel(TEST_BUTTON_ID, CUSTOMDATATYPE_BITMAPBUTTON, 0); if (!single_id || custom_button.IsPartOf(*single_id, NULL)) { BaseContainer cont = GetCustomDataTypeDefault(CUSTOMDATATYPE_BITMAPBUTTON); cont.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON); cont.SetBool(BITMAPBUTTON_BUTTON, true); cont.SetInt32(BITMAPBUTTON_BORDER, BORDER_BLACK); description->SetParameter(custom_button, cont, BUTTON_GROUP ); }
And here is in Message:
case MSG_DESCRIPTION_GETBITMAP: { DescriptionGetBitmap* desc_bitmap = static_cast<DescriptionGetBitmap*>(data); LONG param_id = desc_bitmap->id[0].id; if (param_id == TEST_BUTTON_ID) { BaseBitmap* bitmap = BaseBitmap::Alloc(); bitmap->Init(filename); desc_bitmap->bmp = bitmap; //desc will free it } }
The problem is that message never enters in MSG_DESCRIPTION_GETBITMAP.
If I add cont.SetInt32(BITMAPBUTTON_ICONID1, RESOURCEIMAGE_ARROWDOWN); in description, the image is shown correctly. I need toa dd my own image.
What else do I have to do ?Thank you for your time.
-
On 04/09/2017 at 10:31, xxxxxxxx wrote:
Hi,
this basically comes down to the "dirty" member of BitmapButtonStruct.
You'll need to implement GetDParameter() and it could look like so:Bool GetDParameter(GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags) { switch (id[0].id) { case TEST_BITMAP_BUTTON: { BitmapButtonStruct bbs(static_cast<BaseList2D*>(node), id, m_dirty); t_data = GeData(CUSTOMDATATYPE_BITMAPBUTTON, bbs); flags |= DESCFLAGS_GET_PARAM_GET; break; } } return SUPER::GetDParameter(node, id, t_data, flags); }
The important part is the m_dirty passed to the BitmapButtonStruct. In this example a member variable. For a constantly updating BitmapButton, you could increment it right here inside of GetDParameter(), but that's probably not what you want. You rather want to change the dirty count, when something changed that causes the need for a new image, in which case you want to do something like this:
// Force update of BitmapButton ++m_dirty; BitmapButtonStruct bbs(static_cast<BaseList2D*>(node), id, m_dirty); node->SetParameter(id, GeData(CUSTOMDATATYPE_BITMAPBUTTON, bbs), DESCFLAGS_SET_0);