On 17/11/2016 at 02:18, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16
Platform: Windows ;
Language(s) : C++ ;
---------
I have a command plugin that opens a second sub-dialog.
The first time this works, but the second time, the dialog will not create the layout.
This issue was already posted in Oct 2011
But I can not get it to work, even with the answers Robert provided.
Could someone provide an example?
Here my not working code (mostly copied from the old post).
H file.
#define ID_DIALOG 123456789
class RenameDialogTest : public GeDialog
{
private:
String name;
public:
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(Int32 id, const BaseContainer& msg);
Bool SetName(String name);
String GetName();
};
class MainDialog : public GeDialog
{
private:
RenameDialogTest dlgSub;
public:
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool CoreMessage(Int32 id, const BaseContainer& msg);
virtual Bool Command(Int32 id, const BaseContainer& msg);
};
class Dialog : public CommandData
{
private:
MainDialog dlg;
public:
virtual Bool Execute(BaseDocument *doc);
virtual Bool RestoreLayout(void *secret);
};
CPP file.
//Headers from c4d
#include "c4d.h"
//Headers from Plugin
#include "test subdialog.h"
//////////////////////////////////////////////////////////////////////////////
//
// RenameDialog - GeDialog
//
//////////////////////////////////////////////////////////////////////////////
// GeDialog.CreateLayout
//*---------------------------------------------------------------------------*
Bool RenameDialogTest::CreateLayout(void)
//*---------------------------------------------------------------------------*
{
AddEditText(500, BFH_LEFT, 150, 0);
AddButton(1000, BFH_LEFT, 0, 0, "OK");
AddButton(1001, BFH_LEFT, 0, 0, "Cancel");
return TRUE;
}
// GeDialog.InitValues
//*---------------------------------------------------------------------------*
Bool RenameDialogTest::InitValues(void)
//*---------------------------------------------------------------------------*
{
SetString(500, name);
return TRUE;
}
// GeDialog.Command
//*---------------------------------------------------------------------------*
Bool RenameDialogTest::Command(Int32 id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
switch(id)
{
case 1000:
{
GetString(500,name);
SpecialEventAdd(101010101);
Close();
}
case 1001:
{
Close();
}
}
return TRUE;
}
//*---------------------------------------------------------------------------*
Bool RenameDialogTest::SetName(String name)
//*---------------------------------------------------------------------------*
{
this->name = name;
return TRUE;
}
//*---------------------------------------------------------------------------*
String RenameDialogTest::GetName()
//*---------------------------------------------------------------------------*
{
return name;
}
//////////////////////////////////////////////////////////////////////////////
//
// MainDialog - GeDialog
//
//////////////////////////////////////////////////////////////////////////////
// GeDialog.InitValues
Bool MainDialog::InitValues(void)
{
return TRUE;
}
// GeDialog.CreateLayout
//*---------------------------------------------------------------------------*
Bool MainDialog::CreateLayout(void)
//*---------------------------------------------------------------------------*
{
SetTitle("Test");
AddButton(1000,0,0,0,"Start");
return TRUE;
}
//*---------------------------------------------------------------------------*
// GeDialog.CoreMessage
//*---------------------------------------------------------------------------*
Bool MainDialog::CoreMessage(Int32 id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
//GePrint(IntToString(id));
if(id==101010101)
{
GePrint(dlgSub.GetName());
}
return TRUE;
}
// GeDialog.Command
//*---------------------------------------------------------------------------*
Bool MainDialog::Command(Int32 id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
if(id==1000)
{
dlgSub.SetName("test string");
dlgSub.Open(DLG_TYPE_MODAL,ID_DIALOG);
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
//
// Dialog - CommandData
//
//////////////////////////////////////////////////////////////////////////////
// CommandData.Execute
//*---------------------------------------------------------------------------*
Bool Dialog::Execute(BaseDocument* doc)
//*---------------------------------------------------------------------------*
{
return dlg.Open(DLG_TYPE_MODAL,ID_DIALOG);
}
// CommandData.RestoreLayout
//*---------------------------------------------------------------------------*
Bool Dialog::RestoreLayout(void* secret)
//*---------------------------------------------------------------------------*
{
return dlg.RestoreLayout(ID_DIALOG,0,secret);
}
Bool RegisterDialog(void)
{
return RegisterCommandPlugin(ID_DIALOG,"Dialog",0,NULL,String(),NewObjClear(Dialog));
}