Solved

Passing a picture object between an ActiveX exe and a regular exe.

Posted on 2004-08-18
13
247 Views
Last Modified: 2010-05-02
What I have right now is a standalone activex exe that acts as a server for programs to connect to using GetObject().  I am passing data between the programs, but I can't pass any VB pictures between them because I get an error

"Method of 'GetPicture' of object '_test' failed."

Where GetPicture is the function/property I am calling to get the picture and 'test' is the class module in the activex exe.  The activex exe project is here: http://www.vbforums.com/attachment.php?s=&postid=1765076

and then make a standard exe with this code:
----------------------------------------------------
Private Sub Form_Load()
Dim obj As Object

Set obj = GetObject(, "TestEXE.Test")
Set Me.Picture = obj.getpicture
End Sub
----------------------------------------------------

Compile the ActiveX exe and run it.  When you run the StandardEXE part, you will see the error.

Does anyone know of a way around this, or possibly another solution?
0
Comment
Question by:alexkwok
13 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11834086
0
 

Author Comment

by:alexkwok
ID: 11834385
I don't want to work with byte arrays unless I absolutely need to.
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 11838411
getobject has 2 parameters .. u r specifying the second parameter .. so no pathname is specified ..

This is what MSDN says ...
If PathName is a zero-length string (""), GetObject returns a new object instance of the specified type. If the PathName argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.

So my question is .. is ur activex exe running when u test from the client machine ..
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 26

Expert Comment

by:Rejojohny
ID: 11838417
one more question ... y not just use the "NEW" keyword and create a ne instance of the object instead of getobject??
0
 

Author Comment

by:alexkwok
ID: 11843236
This whole activex exe thing works right now.  I'm not trying to create a new instance, I am getting the current existing object so it can be used as a server for programs to GetObject() into.  I'm 100% sure that it is working as it should because it's only possible for the server to start once.

My problem isn't "ActiveX cannot create object" because I am not getting that error.
0
 

Author Comment

by:alexkwok
ID: 11843257
And I know you can just open another copy of the program, but I meant without doing that, the program will not spawn different copies of itself.
0
 

Author Comment

by:alexkwok
ID: 11845277
I did what I wanted to do in a different way, so I'll have my points refunded.
0
 

Author Comment

by:alexkwok
ID: 11849210
@Rejojohny

first post: Yes the activex exe is running.

for second post: I'm not trying or wanting to create a new instance.  I wanted a way to have a single program that acts as a server for many other "clients" to GetObject() into.
0
 

Author Comment

by:alexkwok
ID: 11849227
In any case, a bigger part of the project was taking an hIcon and converting it to a IPicture and sending that IPicture over to the client exe.  Sending only the hIcon didn't work because the hIcon was destroyed after use (from another program), so I just used DuplicateIcon() API to maintain a copy of it, and sent that copy over.  I didn't really send the picture over because that just wasn't possible (limitations with VB and threading) and byte arrays ruined the alpha bits of the icon, so sending the hIcon was a much better solution anyways.
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 11862578
is there a specific reason for u to use the getobject .. like some variables to be shared between multiple clients or something like that because the same can be acheived by specifying the instancing property of ur class as "Multiuse" .. the one instance of your object created would provide multiple objects to multiple client applications without duplication of resources or global data.
0
 

Author Comment

by:alexkwok
ID: 11867300
I made a C dll that hooks the system tray.  I made a program that took data from the dll and process it so that the icons etc can be accessible from another VB program that wants to.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11875745
Closed, 500 points refunded.
Netminder
Site Admin
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question