Thank you very much Reteset, I'm going to check this out tonight!
Object Plugin Container
Collapse
X
-
Originally posted by RizlaUK View Postone thing i noticed in the sample, when creating multiple objects there is junk text caption in one of the buttons
somehow my last modification on this struct was totally wrong
this happened when i really need to sleep
PHP Code:struct OBJECT_INSTANCE
{
OBJECT_INSTANCE()
{
hObjectWnd = NULL;
ClassID = -1;
delete[] strText;
}
HWND hObjectWnd;
long ClassID;
LPCTSTR strText;
};
PHP Code:struct OBJECT_INSTANCE
{
OBJECT_INSTANCE()
{
hObjectWnd = NULL;
ClassID = -1;
strText = NULL;
}
~OBJECT_INSTANCE()
{
delete[] strText;
}
HWND hObjectWnd;
long ClassID;
LPCTSTR strText;
};
Comment
-
-
constructor and destructor, im guessing we would need a union, i'll look into it later when i get home from work at about 1pm (06:40 now.... to early, lol)
Hmm, translating it to PB is gonna be a pain, but well worth it.Embrace change in your life, you never know, it could all work out for the best
Comment
-
-
no unions
remember, C++ is far more advanced than PB, we have to handle the constructor and destructor ourselves in irPlg_Object_CreateObject and irPlg_Object_DeleteObject
iv only just got in, had to sneak out and get the misses something extra special for Christmas (got a gorgeous diamond set ring, cost a fortune!!), i'll work on this framework after a cuppa (Brits and our Tea, huh!, lol)Embrace change in your life, you never know, it could all work out for the best
Comment
-
-
Ok, i'll show you what is that struct
this is a C++ struct but it is not a must have part of this proxy concept
you do not have to clone or create a similar thing in your language
it is a way that a choice to store plugin data , so it is only an example
you can use anything else in your programing language
like you can see below , this struct has a contructor and destructor
this struct can also be written without constuctor and destructor
i added a contructor to initialize member variables in struct
i also add a destructor to delete strText variable
this was a way to initialize and delete variables
again you do not have to do it so
Code:struct OBJECT_INSTANCE { OBJECT_INSTANCE() { hObjectWnd = NULL; ClassID = -1; strText = NULL; } ~OBJECT_INSTANCE() { delete[] strText; } HWND hObjectWnd; long ClassID; LPCTSTR strText; };
Struct :
Code:struct OBJECT_INSTANCE { HWND hObjectWnd; LPCTSTR strText; long ClassID; long ProgressMin; long ProgressMax; long ProgressCurrentPos; };
Code:OBJECT_INSTANCE * CreateNewInstance(long ClassID) { OBJECT_INSTANCE *pObject = new OBJECT_INSTANCE; pObject->strText = NULL; pObject->ClassID = ClassID; pObject->ProgressMin = 0; pObject->ProgressMax = 100; pObject->ProgressCurrentPos = 0; m_objectlist.push_back(pObject); return pObject; }
Code:void DeleteInstance(long ClassID) { for(size_t i=0; i<m_objectlist.size(); ++i) { OBJECT_INSTANCE *pObject = m_objectlist.at(i); if (pObject) { if(pObject->ClassID == ClassID) { if(::IsWindow(pObject->hObjectWnd)) { ::ShowWindow(pObject->hObjectWnd,SW_HIDE); ::DestroyWindow(pObject->hObjectWnd); } delete[] pObject->strText; delete pObject; m_objectlist.erase( m_objectlist.begin()+i ); return; // only for break } } } }
store each instance's data as separated from each other
for example when i call _GetCustomProperties with a ClassID from your dll, you must return properties of the instance indexed by the ClassID
if you do not do this you will return same properties to all objects on the AMS page,
to avoid this , you must store plugin specific data by ClassID and when AMS wants anything back , you will return it by its index
i used std::vector as the array style , you can use language specific array to index structs
much simple example could be with Lua (the language that we all know )
Code:tblPluginProperties ={} function Getsomething(classid) return tblPluginProperties[classid].Variable; end function Setsomething(classid,variable) tblPluginProperties[classid].Variable = variable; end
Comment
-
-
i read enough about C++ (from books) to establish the basic concepts of what the code is doing, i just cant manage to string it all together into something usable
i usually use a structure for object info and attach a pointer to the structure to the window with "SetProp", but i can see in this case it will not work as the ClassID is the key
Bas, its back to the dreaded LinkedList, but remember, dont access the list from a callback, we already know the downfalls of doing such
Maybe its time to look into Map's, we can create a single map for each plugin and each instance will have its own entry in the map array
OK, iv got my function framework in place, just need to fill the functions with some operational code and run some tests, when i have some results i'll post what iv got
How you doing Bas, any progress ?Last edited by RizlaUK; 12-21-2010, 11:45 AM.Embrace change in your life, you never know, it could all work out for the best
Comment
-
-
Originally posted by RizlaUK View Posti usually use a structure for object info and attach a pointer to the structure to the window with "SetProp", but i can see in this case it will not work as the ClassID is the key
you can use it as a member of struct and then make a comparision in a loop
see what i did in sample
PHP Code:for (i=0 ; i < lengthof(array) ; i++)
{
if(array[i].ClassID == ClassID)
{
// do something with array[i].Text
}
}
Comment
-
-
in which case i would still need a LinkedList to loop through, its not a problem, i just need to change my way of thinking when it comes to object management
however, i do have a problem i cant seem to overcome
in _DrawDesign and _DrawRuntime, i need the RECT argument to be a pointer to the structure, purebasic does not recognize the structure unless its defined in source
accessing rcObRect\X does not work, i need to assign the pointer to my own structure, like below
Code:ProcedureCDLL.l _DrawDesign(ClassID ,HDC, hMainWnd, *rcObRect, bVisible, bEnabled) Protected *rc.RECT=*rcObRect Protected X = *rc\left Protected Y = *rc\top Protected Width = *rc\right-*rc\left Protected Height = *rc\bottom-*rc\top
unless you have any ideas Bas ?
EDIT:
using predefined settings, i have a ListIcon drawing on the AMS page, just in the wrong location, lol
Bas, we are well on the way mate , just a few teething problems to overcomeLast edited by RizlaUK; 12-21-2010, 01:41 PM.Embrace change in your life, you never know, it could all work out for the best
Comment
-
Comment