On 28/01/2016 at 15:15, xxxxxxxx wrote:
This is an example of toggling between two different registered icon images on a GeDialog bitmap button.
#include "c4d.h"
#include "c4d_symbols.h"
#define PLUGIN_ID 1000006 //Testing ID!!
enum
{
MY_BITMAP_BUTTON1 = 10001
};
class MyDialog : public GeDialog
{
private:
BitmapButtonCustomGui *myButton; //The button with an image on it
Bool btnState = false; //The state of the toggle button
MyDialog *dlg;
public:
MyDialog(void);
~MyDialog(void);
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(LONG id,const BaseContainer &msg);
};
Bool MyDialog::CreateLayout(void)
{
Bool res = TRUE;
res = LoadDialogResource(IDS_RESDIALOG,NULL,0);
//This is an example of creating a custom button locally(not in the .res file) with AddCustomGui()
GroupBegin(0,BFH_LEFT,2,0,"MyButtonGroup",0);
{
BaseContainer bbc; //Create a container to hold our custom button gizmo
//bbc.SetBool(BITMAPBUTTON_BUTTON, true); //Animates the pressed state of the button if desired
bbc.SetBool(BITMAPBUTTON_TOGGLE, true);
bbc.SetString(BITMAPBUTTON_TOOLTIP, "Click Me!");
bbc.SetLong(BITMAPBUTTON_ICONID1, RESOURCEIMAGE_ROTATE);
bbc.SetLong(BITMAPBUTTON_ICONID2, RESOURCEIMAGE_MOVE);
myButton = (BitmapButtonCustomGui* )AddCustomGui(MY_BITMAP_BUTTON1, CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", BFH_SCALEFIT | BFH_SCALEFIT, 130, 30, bbc);
}
GroupEnd();
return res;
}
Bool MyDialog::InitValues(void)
{
if(!GeDialog::InitValues()) return FALSE;
return TRUE;
}
Bool MyDialog::Command(LONG id,const BaseContainer &msg)
{
switch (id)
{
case MY_BITMAP_BUTTON1:
GePrint("Bitmap Button1 Was Pressed");
btnState = !btnState; //Makes the variable toggle true / false
myButton->SetToggleState(btnState); //Toggles the button image
break;
}
EventAdd();
return TRUE;
}
//...CommandData code stuff here...
-ScottA