gso
asked on
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!
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!
ASKER
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.
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.
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.
ASKER
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.
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.
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.
ASKER
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. :-(
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. :-(
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.
ASKER
Thanks anyway - I do appreciate your trying!
No problem. I always appreciate a challenge.
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(ObjectTo Place as class1)
mycollection.add objecttoplace,cstr(num)
num =num + 1
end sub
function GetValue(Index as integer) as string
getvalue = mycollection(Index).valueT obeGiven
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
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(ObjectTo
mycollection.add objecttoplace,cstr(num)
num =num + 1
end sub
function GetValue(Index as integer) as string
getvalue = mycollection(Index).valueT
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
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?
ASKER
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
I'm sorry if I wasted your time. :-(
Ken
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Never a waste of time. Questions like these help us determine the limits, and perhaps push out the edge of the envelope.
ASKER
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.
Thanks for the definite answer, Mirkwood.
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