THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/10/2011 at 09:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13
Platform: Windows ;
Language(s) : C++ ;
---------
Hey Guys,
I try to create a Dialog (RenameDialog) in a Dialog (MainDialog).
The first time open the RenameDialog works, but when I start the dialog a secound time, the dialog will not create his layout.
Dialog.h
#define ID_DIALOG 123456789
class RenameDialog : public GeDialog
{
private:
String name;
public:
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(LONG id, const BaseContainer& msg);
Bool SetName(String name);
String GetName();
};
class MainDialog : public GeDialog
{
private:
RenameDialog dlg;
public:
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool CoreMessage(LONG id, const BaseContainer& msg);
virtual Bool Command(LONG id, const BaseContainer& msg);
};
class Dialog : public CommandData
{
private:
MainDialog dlg;
public:
virtual Bool Execute(BaseDocument *doc);
virtual Bool RestoreLayout(void *secret);
};
Dialog.cpp
//Headers from c4d
#include "c4d.h"
//Headers from Plugin
#include "Dialog.h"
//////////////////////////////////////////////////////////////////////////////
//
// RenameDialog - GeDialog
//
//////////////////////////////////////////////////////////////////////////////
// GeDialog.CreateLayout
//*---------------------------------------------------------------------------*
Bool RenameDialog::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 RenameDialog::InitValues(void)
//*---------------------------------------------------------------------------*
{
SetString(500, name);
return TRUE;
}
// GeDialog.Command
//*---------------------------------------------------------------------------*
Bool RenameDialog::Command(LONG id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
switch(id)
{
case 1000:
{
GetString(500,name);
SpecialEventAdd(101010101);
Close();
}
case 1001:
{
Close();
}
}
return TRUE;
}
//*---------------------------------------------------------------------------*
Bool RenameDialog::SetName(String name)
//*---------------------------------------------------------------------------*
{
this->name = name;
return TRUE;
}
//*---------------------------------------------------------------------------*
String RenameDialog::GetName()
//*---------------------------------------------------------------------------*
{
return name;
}
//////////////////////////////////////////////////////////////////////////////
//
// MainDialog - GeDialog
//
//////////////////////////////////////////////////////////////////////////////
// GeDialog.CreateLayout
//*---------------------------------------------------------------------------*
Bool MainDialog::CreateLayout(void)
//*---------------------------------------------------------------------------*
{
SetTitle("Test");
AddButton(1000,0,0,0,"Start");
return TRUE;
}
//*---------------------------------------------------------------------------*
// GeDialog.CoreMessage
//*---------------------------------------------------------------------------*
Bool MainDialog::CoreMessage(LONG id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
GePrint(LongToString(id));
if(id==101010101)
{
GePrint(dlg.GetName());
}
return TRUE;
}
// GeDialog.Command
//*---------------------------------------------------------------------------*
Bool MainDialog::Command(LONG id, const BaseContainer& msg)
//*---------------------------------------------------------------------------*
{
if(id==1000)
{
dlg.SetName("test string");
dlg.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(),gNew Dialog);
}