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
Solved

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

Posted on 1998-09-22
15
376 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 60
MsgBox 2 59
Recommendation vb6 to vb.net or others 14 174
Export PDF Form fields to Access  or Excel  in Tab order 16 74
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

789 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