Solved

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

Posted on 1998-09-22
15
391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 

Expert Comment

by:blackeagle
ID: 1487091
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
ID: 1487092
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
ID: 1487093
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gso
ID: 1487094
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
ID: 1487095
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
ID: 1487096
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
ID: 1487097
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
 

Author Comment

by:gso
ID: 1487098
Thanks anyway - I do appreciate your trying!
0
 
LVL 4

Expert Comment

by:tomook
ID: 1487099
No problem. I always appreciate a challenge.
0
 
LVL 1

Expert Comment

by:sirigere
ID: 1487100
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
ID: 1487101
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
ID: 1487102
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
ID: 1487103
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
ID: 1487104
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
ID: 1487105
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

729 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