THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/06/2012 at 00:58, xxxxxxxx wrote:
Sorry, I can't reproduce this problem. My test code worked fine. Can you post some code where you pass strings to the functions?
here my test code, small async dialog:
#define ID_ASYNCTEST 1000955
#include "c4d.h"
#include "c4d_symbols.h"
class AsyncDialog : public GeDialog
{
private:
public:
AsyncDialog(void);
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(LONG id,const BaseContainer &msg);
};
enum
{
IDC_TEXT = 1000
};
AsyncDialog::AsyncDialog(void)
{
}
Bool AsyncDialog::CreateLayout(void)
{
// first call the parent instance
Bool res = GeDialog::CreateLayout();
SetTitle("GuiDemo C++");
GroupBegin(0,BFH_SCALEFIT,1,1,"",0);
{
GroupBorderSpace(4,4,4,4);
AddEditText(IDC_TEXT, BFH_SCALEFIT, 400, 0, 0);
}
GroupEnd();
return res;
}
Bool AsyncDialog::InitValues(void)
{
// first call the parent instance
if (!GeDialog::InitValues()) return FALSE;
//SetString(IDC_TEXT, String("hello"));
return TRUE;
}
Bool IsUsableCharacter(const String s)
{
if(s >= "a" && s <= "z") return TRUE;
if(s >= "A" && s <= "Z") return TRUE;
if(s >= "0" && s <= "9") return TRUE;
if(s == "_") return TRUE;
return FALSE;
}
Bool AsyncDialog::Command(LONG id,const BaseContainer &msg)
{
switch (id)
{
case IDC_TEXT:
String text;
GetString(IDC_TEXT, text);
LONG len = text.GetLength();
for (LONG i=0; i<len; i++)
{
String subtext = text.SubStr(i, 1);
if (IsUsableCharacter(subtext))
GePrint(subtext);
else
GePrint("fail");
}
break;
}
return TRUE;
}
class AsyncTest : public CommandData
{
private:
AsyncDialog dlg;
public:
virtual Bool Execute(BaseDocument *doc);
virtual LONG GetState(BaseDocument *doc);
virtual Bool RestoreLayout(void *secret);
};
LONG AsyncTest::GetState(BaseDocument *doc)
{
return CMD_ENABLED;
}
Bool AsyncTest::Execute(BaseDocument *doc)
{
return dlg.Open(DLG_TYPE_ASYNC, ID_ASYNCTEST, 0, 0);
}
Bool AsyncTest::RestoreLayout(void *secret)
{
return dlg.RestoreLayout(ID_ASYNCTEST,0,secret);
}
Bool RegisterAsyncTest(void)
{
return RegisterCommandPlugin(ID_ASYNCTEST,GeLoadString(IDS_ASYNCTEST),0,NULL,String("C++ SDK Menu Test Plugin"),gNew AsyncTest);
}
cheers,
Matthias