On 27/09/2013 at 14:49, xxxxxxxx wrote:
Here's a bit more code for you to chew on.
It also shows how to toggle the lock image in a GeDialog plugin.
BTW: All of this code is in the plugin's .cpp file
enum
{
LOCKBUTTON = 1003, //The ID for the inline lock button
_dummy
};
class myDialog : public GeDialog
{
private:
Bool lockState; //Used to control things in any of the plugin's methods
BitmapButtonCustomGui *lockButton;
public:
myDialog(void);
virtual Bool CreateLayout(void);
//Other virtual methods here...
};
Bool myDialog::CreateLayout(void)
{
//This code loads things from a .res file if desired
Bool res = TRUE;
res = LoadDialogResource(IDS_RESDIALOG,NULL,0);
//This code block creates an inline button with the locked/unlocked icon on it
GroupBeginInMenuLine();
BaseContainer bc = GetCustomDataTypeDefault(CUSTOMGUI_BITMAPBUTTON);
bc = GetCustomDataTypeDefault(CUSTOMGUI_BITMAPBUTTON);
bc.SetBool(BITMAPBUTTON_BUTTON, TRUE);
bc.SetBool(BITMAPBUTTON_TOGGLE, TRUE);
if(lockState) bc.SetLong(BITMAPBUTTON_ICONID1, -12679); //Lock icon
if(!lockState) bc.SetLong(BITMAPBUTTON_ICONID1, 12679); //Unlock icon
lockButton = (BitmapButtonCustomGui* )AddCustomGui(LOCKBUTTON, CUSTOMGUI_BITMAPBUTTON,"", 0,0,0,bc);
GroupEnd();
return res;
}
Bool myDialog::Command(LONG id, const BaseContainer &msg)
{
switch (id)
{
case LOCKBUTTON:
{
//Toggle this class level variable true/false so we can control things with it
lockState = !lockState;
//Toggle the icon image
if(lockState) lockButton->SetImage(-12679, FALSE);
else lockButton->SetImage(12679, FALSE);
GePrint("LockState: " + LongToString(lockState));
}
break;
}
EventAdd();
return TRUE;
}
Hope that helps.
-ScottA