On 19/03/2014 at 02:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R15
Platform: Windows ;
Language(s) : C++ ;
---------
I have a command plugin with a dialog.
In this dialog I start up another thread._<_o:_<_o:p_>_o:p>
To monitor the progress, I want – in the thread – to update a slider in my dialog.
Thus, I want to use – again in my thread – followi_<_o:_<_o:p_>_
d = Float(pctDone) / 100.0;
msg.SetBool(BFM_STATUSBAR_PROGRESSON, TRUE);
msg.SetFloat(BFM_STATUSBAR_PROGRESS, d);
dlg->SendMessage(1002, msg); //send message to dialog with progress info
However, how to pass the dlg, the pointer to the dialog, to the thread?
Here some snippets of the code
class DownloadProgress : public CkHttpProgress
{
public:
DownloadProgress(void);
virtual ~DownloadProgress(void);
void PercentDone(int pctDone, bool *abort);
static Bool downloadAsynchrone(void);
};
void DownloadProgress::PercentDone(int pctDone, bool *abort)
{
BaseContainer msg(BFM_SETSTATUSBAR);
Float d = Float(pctDone) / 100.0;
msg.SetBool(BFM_STATUSBAR_PROGRESSON, TRUE);
msg.SetFloat(BFM_STATUSBAR_PROGRESS, d);
dlg->SendMessage(1002, msg);
EventAdd(EVENT_FORCEREDRAW);
}
Bool DownloadProgress::downloadAsynchrone(void)
{
....
// start thread and monitor progress using DownloadProgress::PercentDone
...
return true;
}
class MainDialog : public GeDialog
{
public:
MainDialog(void);
virtual ~MainDialog(void);
virtual Bool CreateLayout(void);
virtual Bool InitValues(void);
virtual Bool Command(Int32 id, const BaseContainer& msg);
virtual Int32 Message(const BaseContainer& msg, BaseContainer& result);
};
Bool MainDialog::Command(Int32 id, const BaseContainer& msg)
{
switch (id)
{
case 1000: //do command
{
DownloadProgress::downloadAsynchrone();
break;
}
}
return true;
}
...
class MyPlugin : public CommandData
{
private:
MainDialog dlg;
public:
//static MainDialog dlg;
virtual Bool Execute(BaseDocument* doc);
virtual Bool RestoreLayout(void* secret);
};
Bool MyPlugin::Execute(BaseDocument* doc)
{
return dlg.Open(DLG_TYPE_ASYNC, ID_PIM, -1, -1);
}
Bool MyPlugin::RestoreLayout(void* secret)
{
return dlg.RestoreLayout(ID_PIM, 0, secret);
}
Bool RegisterMyPlugin(void)
{
return RegisterCommandPlugin(ID_PIM, "Dialog - Threading", 0, AutoBitmap("icon.tif"), String("Chilkat Threading"), NewObjClear(MyPlugin));
}
Thanks to Steve for his previous help on the threading part.