Announcement

Collapse
No announcement yet.

Object Plugin Container

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RizlaUK
    replied
    the directly accepting a structure in the arguments?
    yes, the rect struct tells us the size of the host container, i can draw the object OK, but not at the right location as i can not access the struct, every time the object is moved or resized this function is called and we update our objects dimensions

    iv got the gurus at PB Forums on the case, if theres a solution, they will find it, but im guessing there going to tell me i need a pointer to the struct!

    Leave a comment:


  • Imagine Programming
    replied
    I prefer structures as well, keeps the code a bit more clean.
    Dean, what structure problem exactly? I couldn't quite understand
    your problem before, the directly accepting a structure in the arguments?

    Leave a comment:


  • RizlaUK
    replied
    Personally speaking, i would rather use the structure as i use them often in my code anyway and it keeps the whole thing a bit more native to my style of coding, but for other more novice users maybe flattening the struct's would be a good idea

    BTW, using the struct pointer in _GetDefaultSize i have no problems, i am able to set the default size without problems

    also, size of the dll does not bother me at all, considering the AMS runtime is a little over 5MB, 70+KB of dll makes no difference to me, but removing garbage is always a good idea, lol

    as for suggestions, i can not progress any further until i get this struct problem sorted, and ideas will only come to me as i progress with my framework and find things i would need or want added/changed

    Leave a comment:


  • reteset
    replied
    like i said before i can flatten structs to individual arguments
    Code:
    ProcedureCDLL.l _DrawDesign(ClassID ,HDC, hMainWnd, [B][COLOR="red"]left,top,right,bottom[/COLOR][/B], bVisible, bEnabled)
    i am also going to make _On** mouse events optional

    and this irPlg_Object_TranslateMessage as well

    i will try to build a MFCless version of proxy object
    so dll size will be smaller than current version , i will also remove some unnecessary garbage from it

    if you have requests or suggestions ,please write it here ,
    because in future i will do same steps for Delphi object plugins like you are doing now

    Leave a comment:


  • RizlaUK
    replied
    na, when i tried like that it just crashes the IDE upon object creation

    iv tried every trick i know, just cant access the structure!

    Do you need any help by the way?
    im pretty good for now, been waiting for this for so long, im enjoying working with it, and it will be a real sense of achievement to get this going myself, don't worry tho, i'll make my framework public source :yes

    Leave a comment:


  • Imagine Programming
    replied
    Dean,
    Code:
      ProcedureCDLL.l _DrawDesign(ClassID ,HDC, hMainWnd, *rcObRect.RECT, bVisible, bEnabled)
    receives it as a pointer to a structure, should work in our case. Do you need any help by the way?
    I didn't have time to translate things yet, however tonight I'm free

    Leave a comment:


  • RizlaUK
    replied
    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
    all structures must be defined in the source or else PB throws an error, and i can not directly asign the structure variable to my RECT as PB see's it as a value, we must work with pointers when it comes to structures

    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 overcome
    Last edited by RizlaUK; 12-21-2010, 02:41 PM.

    Leave a comment:


  • Imagine Programming
    replied
    Ahh yeah, nice!

    Leave a comment:


  • reteset
    replied
    Originally posted by RizlaUK View Post
    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
    actually ClassID has not to be 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=lengthof(array) ; i++)
    {
       if(array[
    i].ClassID == ClassID)
       {
         
    // do something with array[i].Text
       
    }

    Leave a comment:


  • reteset
    replied
    Originally posted by Imagine Programming View Post
    Oh I never knew that was possible in C++ haha! Very nice
    Thanks for that information Reteset
    In C++ , everything is possible

    Leave a comment:


  • RizlaUK
    replied
    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, 12:45 PM.

    Leave a comment:


  • Imagine Programming
    replied
    Oh I never knew that was possible in C++ haha! Very nice
    Thanks for that information Reteset

    Leave a comment:


  • reteset
    replied
    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;
    };
    for example you can initialize your variables like below

    Struct :

    Code:
    struct OBJECT_INSTANCE
    {
        HWND    hObjectWnd;
        LPCTSTR strText;
        long    ClassID;
        long    ProgressMin;
        long    ProgressMax;
        long    ProgressCurrentPos;
    };
    Initialization :

    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;
    }
    Delete :

    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
    			  
    		  }  
    	  }
    	}
    }
    the real aim is :
    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

    Leave a comment:


  • RizlaUK
    replied
    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)

    Leave a comment:


  • Imagine Programming
    replied
    Sure we can, however 2 unions?

    Leave a comment:

Working...
X