How to read another app's MSFlexGrid's contents?

Since almost anything's possible, I'm going to assume this CAN be done.  But, HOW?

I can easily get the handle of the MSFlexGrid's window, but how can I create an object from that?  Since MSFlexGrid is an ocx, the instance running is actually loaded in the other app's addressing space.  Perhaps this can't be done after all ....

Please, someone, set me straight!
gsoAsked:
Who is Participating?
 
MirkwoodConnect With a Mentor Commented:
I'm very sure it is not possible using the msflexgrid control.
You cannot get from a window handle to an Iunknown  in any standard way. You have to know something about the implementation.
It is possible if the Microsoft data bound grid control was used.

I'm sorry
0
 
blackeagleCommented:
You could make one exe a activeX EXE and have a class that returns the msflexgrid as a object.


ActiveX EXE - ClassTest
private withevents myGrid as new msflexgrid

public property set ClientGrid(gridclient as object)

       set gridclient = mygrid

end property

In the activeX EXE you can pout code to modify the grid and react to the grids events


Hopes this helps

0
 
gsoAuthor Commented:
I'm sorry, I should have mentioned that the .exe whose MSFlexGrid I want to access is a 3rd-party executable.  I have no way to change it at all..

After doing some more thinking on this problem, I do not believe it is solvable after all.  But if someone knows otherwise, I would love to hear about it.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
tomookCommented:
When you wrote you can get a handle to the window, I assume you mean a handle to the window of the control container, not the application? If so, you might be able to get a reference to the contained control, if you know what kind of container it is or it supports IDispatch. If all those problems can be solved, you only have one left: VB does not allow marshalling object references across process boundaries. If you consult the documentation, it states this is by design. If this can be done, you must do it in something other than VB.
0
 
gsoAuthor Commented:
Time to fess up - I'm an experienced C++ programmer, but new to both VB and COM/ActiveX.  So, if some of what I say doesn't make sense, that's why.

I can get the handle to the MSFlexGrid (container, I assume) simply by using the Dev Studio Spy utility, and pointing at that window.  So, I have the handle (manually), which I could easily input to my app, but I do not know how to get a reference to the control from that handle.  I can use C++ rather than VB if I have to, so I could do the marshalling, if I could get the object reference.
0
 
tomookCommented:
If you know what kind of container it is, find the property which points to the contained control (often it is "Object"). This should give you either an IUnknown* or IDispatch* (which is an IUnknown* as well). Since I believe the new FlexGrid supports a regular interface, use the IUnknown->QueryInterface to get a reference to the interface you want. This would be simpler if you knew the type library for the container. I have done some ActiveX hacking between VB and C (not what you are trying, though), and would be happy to work with you on this. It sound interesting.
0
 
gsoAuthor Commented:
tomook,

The container's an .exe - that's ALL I know about it.  I don't know how to find anything about its contained controls, given that. :-(
0
 
tomookCommented:
I played around a little with this, but I have not gotten anywhere. It might be possible to read the visible data by snooping in the window, but I do not know what else to try.
0
 
gsoAuthor Commented:
Thanks anyway - I do appreciate your trying!
0
 
tomookCommented:
No problem. I always appreciate a challenge.
0
 
sirigereCommented:
you can solve this by creating a activex exe providing a server object.
The main intension being establish communication between two applications.
when you create a object from the activex exe you create a refrence to that object by placing it in a collection of your own defined type.

eg. You got a standard module and a class called class1 in your activex exe.
Standard module code
global MyCollection as new collection
dim num

sub PutMeIncollection(ObjectToPlace as class1)
mycollection.add objecttoplace,cstr(num)
num =num + 1
end sub

function GetValue(Index as integer) as string
getvalue = mycollection(Index).valueTobeGiven
end function


Class module declaration

public valueToBeGiven as string

function FetchValue(WhichObject as integer)
fetchvalue = getvalue(WhichObject)
end function

sub class1_intialize
PutMeIncollection me
end sub

in the above program you will be creating class1 object at both the applications. when you create the object the reference of both the objects will be placed in the collection. Now you can communicate with the other application by refering with the index of the object in the collection. Now both of them exchange the data placed in valuetobegiven property of the object
by writing appropriat methods and property you can tranfer the content of the fley grid to other application

Need any clrificcation let me know

0
 
tomookCommented:
sirigere, perhaps you did not read all the comments. gso does not "own" the source to this application. He wants to read the contents of a flexgrid in someone else's application. I agree that if you could get a handle to the object, you could do it. How do you get a handle to the object if you have only the EXE?
0
 
gsoAuthor Commented:
tomook beat me to it (I've been away from my computer for a few days).  I'd like to change the description of the original question, or remove it altogether, but I don't know how to do either one.

I'm sorry if I wasted your time. :-(

Ken
0
 
tomookCommented:
Never a waste of time. Questions like these help us determine the limits, and perhaps push out the edge of the envelope.
0
 
gsoAuthor Commented:
I wish I could divide the points among everyone who took a shot at this (esp. tomook), but, alas, I cannot.

Thanks for the definite answer, Mirkwood.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.