Object Plugin Container

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Imagine Programming
    Indigo Rose Customer
    • Apr 2007
    • 4252

    #16
    Thank you very much Reteset, I'm going to check this out tonight!
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment

    • RizlaUK
      Indigo Rose Customer
      • May 2006
      • 5552

      #17
      one thing i noticed in the sample, when creating multiple objects there is junk text caption in one of the buttons
      Embrace change in your life, you never know, it could all work out for the best

      Comment

      • reteset
        Indigo Rose Customer
        • May 2006
        • 1692

        #18
        Originally posted by RizlaUK View Post
        one thing i noticed in the sample, when creating multiple objects there is junk text caption in one of the buttons
        sorry it is my mistake ,in sample project
        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;
        }; 
        should be

        PHP Code:
        struct OBJECT_INSTANCE
        {
            
        OBJECT_INSTANCE()
            {
              
        hObjectWnd NULL;
              
        ClassID = -1;
              
        strText NULL;
            }
             ~
        OBJECT_INSTANCE()
            {
              
        delete[] strText;
            }
            
        HWND    hObjectWnd;
            
        long    ClassID;
            
        LPCTSTR strText;
        }; 
        amsplugins.com Is Closed.

        Facebook Page

        Comment

        • Imagine Programming
          Indigo Rose Customer
          • Apr 2007
          • 4252

          #19
          Hmm, translating it to PB is gonna be a pain, but well worth it.

          The OBJECT_INSTANCE structure, what do OBJECT_INSTANCE() and ~OBJECT_INSTANCE() mean?
          Is one of those a union?
          Bas Groothedde
          Imagine Programming :: Blog

          AMS8 Plugins
          IMXLH Compiler

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5552

            #20
            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.
            im sure we can manage it Bas :yes
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            • Imagine Programming
              Indigo Rose Customer
              • Apr 2007
              • 4252

              #21
              Sure we can, however 2 unions?
              Bas Groothedde
              Imagine Programming :: Blog

              AMS8 Plugins
              IMXLH Compiler

              Comment

              • RizlaUK
                Indigo Rose Customer
                • May 2006
                • 5552

                #22
                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

                • reteset
                  Indigo Rose Customer
                  • May 2006
                  • 1692

                  #23
                  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
                  amsplugins.com Is Closed.

                  Facebook Page

                  Comment

                  • Imagine Programming
                    Indigo Rose Customer
                    • Apr 2007
                    • 4252

                    #24
                    Oh I never knew that was possible in C++ haha! Very nice
                    Thanks for that information Reteset
                    Bas Groothedde
                    Imagine Programming :: Blog

                    AMS8 Plugins
                    IMXLH Compiler

                    Comment

                    • RizlaUK
                      Indigo Rose Customer
                      • May 2006
                      • 5552

                      #25
                      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

                      • reteset
                        Indigo Rose Customer
                        • May 2006
                        • 1692

                        #26
                        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
                        amsplugins.com Is Closed.

                        Facebook Page

                        Comment

                        • reteset
                          Indigo Rose Customer
                          • May 2006
                          • 1692

                          #27
                          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
                             
                          }

                          amsplugins.com Is Closed.

                          Facebook Page

                          Comment

                          • Imagine Programming
                            Indigo Rose Customer
                            • Apr 2007
                            • 4252

                            #28
                            Ahh yeah, nice!
                            Bas Groothedde
                            Imagine Programming :: Blog

                            AMS8 Plugins
                            IMXLH Compiler

                            Comment

                            • RizlaUK
                              Indigo Rose Customer
                              • May 2006
                              • 5552

                              #29
                              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, 01:41 PM.
                              Embrace change in your life, you never know, it could all work out for the best

                              Comment

                              • Imagine Programming
                                Indigo Rose Customer
                                • Apr 2007
                                • 4252

                                #30
                                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
                                Bas Groothedde
                                Imagine Programming :: Blog

                                AMS8 Plugins
                                IMXLH Compiler

                                Comment

                                Working...
                                X