THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/08/2011 at 11:59, xxxxxxxx wrote:
Thanks Steve.
I have SetImage() working now. So the next thing I need to know is how to change the image on the button when the button is clicked.
Matthias once told me that Buttons should be used in the Message method. So I tried to do that. But it's not working.
define PLUGIN_ID 1000006 // TESTING ID!!!! be sure to use a unique ID obtained from www.plugincafe.com
#include "c4d.h"
#include "gui.h"
#include "c4d_symbols.h"
#include "lib_browser.h"
#include "customgui_datetime.h"
#include "customgui_bitmapbutton.h"
#include "../../resource/_api/c4d_customgui/customgui_bitmapbutton.h"
class myDialog : public GeDialog
{
private:
DateTimeControl *dt;
BitmapButtonCustomGui *myButton;
public:
myDialog(void);
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(LONG id,const BaseContainer &msg);
virtual LONG Message(const BaseContainer &msg, BaseContainer &result);
};
myDialog::myDialog(void) // The Constructor
{
//Not used in this example
}
Bool myDialog::CreateLayout(void)
{
SetTitle("Custom GUI Example");
GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,0,1,String(),0);
BaseContainer dtc, bbc; // Create the containers for the dateTime & BitmapButton GUI's
dt = (DateTimeControl* )AddCustomGui(10000,DATETIME_GUI,String(),BFH_SCALEFIT|BFV_SCALEFIT,0,0,dtc); // Adds the DateTime GUI to the dialog
GroupEnd();
GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,0,1,String(),0);
bbc.SetLong(BITMAPBUTTON_BORDER, BORDER_OUT);
bbc.SetBool(BITMAPBUTTON_BUTTON, TRUE);
myButton = (BitmapButtonCustomGui* )AddCustomGui(10001,CUSTOMGUI_BITMAPBUTTON,"MY BUTTON", 0L,120,120,bbc); //Adds the BitmapButton GUI to the dialog
Filename file1 = Filename("C:\\Users\\user\\Desktop\\image1.jpg"); //The file path to the initial button image
myButton->SetImage(file1, FALSE);
GroupEnd();
return TRUE;
}
Bool myDialog::InitValues(void){
if (!GeDialog::InitValues()) return FALSE;
//Not used
return TRUE;
}
Bool myDialog::Command(LONG id,const BaseContainer &msg)
{
//Not used
return TRUE;
}
LONG myDialog::Message(const BaseContainer &msg,BaseContainer &result)
{
///////////////This is not working!!!//////////
switch (msg.GetId())
{
case 10001:
GePrint("Button was Pushed");
Filename file1 = Filename("C:\\Users\\user\\Desktop\\image2.jpg"); //swap the button's image with this one
break;
}
return GeDialog::Message(msg,result);
}
class MyDateTime : public CommandData // MyDateTime is the class name that needs to be listed in the main.cpp to register it properly
{
private:
myDialog dlg;
public:
virtual Bool Execute(BaseDocument *doc);
virtual Bool RestoreLayout(void *secret);
};
Bool MyDateTime::Execute(BaseDocument *doc)
{
//return dlg.Open(DLG_TYPE_ASYNC_FULLSCREEN_MONITOR,ID_PLUGIN,0,0); // use for full screen if desired
return dlg.Open(DLG_TYPE_ASYNC,PLUGIN_ID, -1, -1, 300,150);
}
Bool MyDateTime::RestoreLayout(void *secret)
{
return dlg.RestoreLayout(PLUGIN_ID,0,secret);
}
Bool RegisterMyDateTime(void)
{
return RegisterCommandPlugin(PLUGIN_ID,GeLoadString(IDS_DateTime),0,AutoBitmap("icon.tif"),String("Date/Time Example"),gNew MyDateTime);
}
Any idea what I'm doing wrong in my message method?
-ScottA