iCustomGui: Fake a Command message
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2004 at 00:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.207
Platform: Windows ;
Language(s) : C++ ;---------
The only example for a customgui is the MSA example posted in the forum. There, in the command function they check if the user modified something. To let the framework know that the value has to be stored in the container, they call:
BaseContainer m( msg );
m.SetLong(BFM_ACTION_ID, GetId());
m.RemoveData(BFM_ACTION_VALUE);
m.SetData(BFM_ACTION_VALUE, GetData().GetValue());
SendParentMessage(m);
Where msg is the contianer of the command message they received. My problem is, that the modification I do ( drag and drop ) is not received in the command but in the message function. But if I use the msg of the message to build this parent message, it doesnt work. I tried to save the container of the command message in a member variable and use it in the message function to build the parent message, this works fine. Unfortunally this member variable will only be initialized after the first command call, so drag and drop only works after the user did at least one manual change at the gui....
Unfortunaly the documentation about the command message container ends after the words: The original message container. Contains the following values:
And here the documentations ends. Which values in the container are set in a command message? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2004 at 15:31, xxxxxxxx wrote:
You need to send a BFM_ACTION message. Here's a sample from a custom GUI for the string datatype, that includes a rudimentary drag and drop:
#include "c4d.h" const LONG MY_STRING_GUI_ID = 1016814; static LONG restypetable[] = { DA_STRING }; class MyStringGUIDialog : public iCustomGui { INSTANCEOF(MyStringGUIDialog, iCustomGui) private: BaseContainer m_settings; String m_str; Bool m_tristate; public: MyStringGUIDialog(const BaseContainer &settings, CUSTOMGUIPLUGIN *plugin) : iCustomGui(settings, plugin), m_str("[default"), m_tristate(false), m_settings(settings) { } virtual Bool CreateLayout (void) { GroupBegin(1002, BFH_SCALEFIT, 2, 1, "", 0); { AddStaticText(1001, BFH_FIT, 0, 0, "Test:", 0); AddEditText(1000, BFH_SCALEFIT, 20, SizeChr(1)); } GroupEnd(); return TRUE; } virtual Bool InitValues() { SetString(1000, m_str, m_tristate); // We cannot look at the return value from SetString() since it's broken in 8.503 return TRUE; } virtual LONG Message(const BaseContainer& msg, BaseContainer& result) { switch(msg.GetId()) { case BFM_DRAGRECEIVE: { if (msg.GetLong(BFM_DRAG_FINISHED) && CheckDropArea(1000, msg, TRUE, TRUE)) { LONG type = 0; void *object = NULL; GetDragObject(msg, &type, &object); if (object && type == DRAGTYPE_ATOMARRAY) // DRAGTYPE_OBJECT { AtomArray* array = static_cast<AtomArray*>(object); Atom* atom = array->GetPreferred(); if (atom && atom->IsInstanceOf(Obase)) { BaseObject* obj = static_cast<BaseObject*>(atom); SetString(1000, obj->GetName()); BaseContainer actionmsg(BFM_ACTION), actionresult; actionmsg.SetLong(BFM_ACTION_ID, 1000); SUPER::Message(actionmsg, actionresult); } } } else SetDragDestination(CheckDropArea(1000, msg, TRUE, TRUE) ? MOUSE_POINT_HAND : MOUSE_FORBIDDEN); } return TRUE; } return SUPER::Message(msg, result); } virtual Bool Command(LONG id, const BaseContainer& msg) { switch (id) { case 1000: { BaseContainer m(msg); m.SetLong(BFM_ACTION_ID, GetId()); m.RemoveData(BFM_ACTION_VALUE); m.SetData(BFM_ACTION_VALUE, GetData().GetValue()); SendParentMessage(m); break; } } return TRUE; } virtual Bool SetData(const TriState<GeData> &tristate) { m_str = tristate.GetValue().GetString(); m_tristate = tristate.GetTri(); return InitValues(); } virtual TriState<GeData> GetData() { GetString(1000, m_str); return m_str; } }; class MyStringGUI : public CustomGuiData { public: virtual LONG GetId() { return MY_STRING_GUI_ID; } virtual CDialog* Alloc(const BaseContainer &settings) { MyStringGUIDialog* dlg = gNew MyStringGUIDialog(settings, GetPlugin()); if (!dlg) return NULL; CDialog *cdlg = dlg->Get(); if (!cdlg) return NULL; return cdlg; } virtual void Free(CDialog *dlg, void *userdata) { if (!dlg || !userdata) return; MyStringGUIDialog *sub = static_cast<MyStringGUIDialog*>(userdata); gDelete(sub); } virtual CHAR *GetResourceSym() { return "MY_STRING_GUI"; } virtual LONG GetResourceDataType(LONG *&table) { table = restypetable; return sizeof(restypetable)/sizeof(LONG); } }; Bool RegisterStringGUI() { static BaseCustomGuiLib mylib; ClearMem(&mylib,sizeof(mylib)); FillBaseCustomGui(mylib); return InstallLibrary(MY_STRING_GUI_ID, &mylib, 1000, sizeof(mylib)) && RegisterCustomGuiPlugin("My String GUI", 0*PLUGINFLAG_HIDE, gNew MyStringGUI); }