Solved

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

Posted on 1998-09-22
15
369 Views
Last Modified: 2013-12-25
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!
0
Comment
Question by:gso
15 Comments
 

Expert Comment

by:blackeagle
Comment Utility
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
 

Author Comment

by:gso
Comment Utility
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
 
LVL 4

Expert Comment

by:tomook
Comment Utility
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
 

Author Comment

by:gso
Comment Utility
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
 
LVL 4

Expert Comment

by:tomook
Comment Utility
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
 

Author Comment

by:gso
Comment Utility
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
 
LVL 4

Expert Comment

by:tomook
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:gso
Comment Utility
Thanks anyway - I do appreciate your trying!
0
 
LVL 4

Expert Comment

by:tomook
Comment Utility
No problem. I always appreciate a challenge.
0
 
LVL 1

Expert Comment

by:sirigere
Comment Utility
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
 
LVL 4

Expert Comment

by:tomook
Comment Utility
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
 

Author Comment

by:gso
Comment Utility
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
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
Comment Utility
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
 
LVL 4

Expert Comment

by:tomook
Comment Utility
Never a waste of time. Questions like these help us determine the limits, and perhaps push out the edge of the envelope.
0
 

Author Comment

by:gso
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now