Important alert: (current site time 7/16/2013 3:26:49 AM EDT)
 

winzip icon

A true plugin model / Expose your app's objects

Email
Submitted on: 10/27/2000 3:13:12 AM
By: BDCSoftware  
Level: Advanced
User Rating: By 26 Users
Compatibility: VB 6.0
Views: 45056
(About the author)
 
     Expose your app's objects / A true plugin model. This sample will teach you how to expose classes from an ActiveX EXE to other Applications. I felt that a Main App / Plugin relationship (like in Photoshop) will be best suited to showcase this cool solution.

This is how it works:
When an object gets created based on a class from an ActiveX Exe it gets created in its own memory area (Multiple objects based on the same class cannot share their data). In C++ that object registers itself with the ROT (Running Object Table) so that anybody who needs to, can access that instance of the object. For instance Excel. When Excel is running you can refer to the running instance from VBA/VB, and access any data that's present in the spread sheet. However VB based objects lack that functionality. Activex EXE created in VB will NOT get registered in the ROT! (That's why you can't use GetObject on VB made ActiveX's ;-) )

Anyhow, here is a solution that will register your ActiveX EXE in the ROT, and you will be able to reference the running instance of your object from any other application.

Please use this sample as follows:

  1. Extract Files from Zip (use folder names checked)
  2. run MainApp.EXE (ActiveX EXE)
  3. click on the OPEN icon
  4. load the supplied BMP
  5. wait for a few sec....(sorry the image handling is awfully slow, I didn't wanted to deal with DIB's for simplicity reasons)
  6. plugin Button should be enabled by now (this calls a ShellExecute and runs a regular EXE (our plugin)
  7. In the plugin click on GetData (this will transfer the image from the main app)
  8. click on modify image (thanx Rog3r)
  9. click on Close Plugin & Transfer data (this will transfer the modified image back to the main app)
  10. Voila

The benefits: If you expose your app's objects up front, you can later on create any plugins/addons you want without modifying the original app.

This is my first contribution to planet-source-code. Please let me know what you think (bad/good, anything is welcome) and like always VOTE.

Thanx
Raf



 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

10/27/2000 10:02:06 AMRang3r

=) you're using a really nice antialias effect there =)
thanx for mentioning me..


(If this comment was disrespectful, please report it.)

 
12/22/2000 7:39:22 PMTTFN7677

i noticed when the MainApp loses focus the picture disapears. Why is that?
(If this comment was disrespectful, please report it.)

 
12/22/2000 7:59:40 PMRaf

Autoredraw, setting on the MainApps picturebox, should be set to true. Or you could redraw the picturebox whenever the form refreshes...
(If this comment was disrespectful, please report it.)

 
1/26/2001 1:31:34 PMJoe

I was excited to see this code! It can solve a long time problem for me. I had trouble using it in my Webbrowser project, though, because VB6 keeps telling me the class object cannot be public 'in this type of project'. I've tried to research it, but can't solve the problem. I would appreciate any suggestions. thanks, Joe
(If this comment was disrespectful, please report it.)

 
1/26/2001 1:36:49 PMJoe

I was very happy to see your code but when I tried to use it in my WebBrowser project, VB6 keept telling me the class object cannot be public 'in this type of project'. I've tried to research it but need any suggestions you might have to help. Thanks for your code, Joe
(If this comment was disrespectful, please report it.)

 
1/26/2001 2:38:58 PMraf

Your project might be a Standard EXE. Standard EXE cannot expose objects to the public....
(If this comment was disrespectful, please report it.)

 
2/9/2001 1:43:33 PMJohnny

Very nice. If I load more than one picture, the plugin seems to still use the first one. Why is that?
(If this comment was disrespectful, please report it.)

 
2/9/2001 1:51:35 PMRaf

Johny: I am not sure why, I have not been working with the code for a while now. I will check it tonight though....
(If this comment was disrespectful, please report it.)

 
1/31/2002 9:53:55 AMM. Highlander

good but complex, check my very simple code!
(If this comment was disrespectful, please report it.)

 
7/11/2002 12:14:26 PMJames Kelly Jr.

Love it! Might use it in a professional edition of one of my gfx progs!! -THNX SO MUCH. 5 from me.
(If this comment was disrespectful, please report it.)

 
2/3/2003 10:22:28 PMJames J. Kelly Jr.

Nice plugin. I bet that greyscale would make a very intresting terrian with some modification.
(If this comment was disrespectful, please report it.)

 
8/13/2003 8:15:20 AM

Works great on my machine, however how do I get the client to work if it is sitting on a different machine.
(If this comment was disrespectful, please report it.)

 
3/27/2004 4:34:48 PMgurpreetsingh

Very Nice. I didnt thought Plugin was even possible in VB. But You did really great work. Thanks for sharing it with All of Us.
Regards
Er. Gurpreet Singh

(If this comment was disrespectful, please report it.)

 
1/15/2005 1:51:52 AMSPY-3

Great code i did not think you could make plugins a exe. Ive tryed to use dll's and i always get the cannot create object but this code may work perfect for it thanks for sharing this code. 5 Globes!
(If this comment was disrespectful, please report it.)

 
1/22/2006 4:57:29 AMGioclone

thank you, i was looking for a solution to some of my problems....
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.