Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(

Status
Not open for further replies.

conor0callaghan

Programmer
Mar 18, 2002
20
0
0
IE
I'm trying to write an application which will listen to applications running in windows.
Things I need to achieve this.

1 Get the name of the application focused or being worked on. ( I've this part done using GetForeGroundWindow());

2 Now that I have the CWnd I convert it to a CFrameWnd so
I can get objects representing the CDocument and Cview
(I've this part done by casting the CWnd * to a CFrameWnd *


3. Now I need to get the name of the child window being worked on in the application. I.e the CDocument object.

Now create the CDocument object but the program crashes each time when I try to get the title or address of the File represented using the CDocument.]

Any Ideas what to do ? Am I going the right way about it?
 
The CDocument object is not a window. Also, this won't work for applications not written in MFC, or even applications written in MFC but using a different version of MFC.

When you called GetForegroundWindow, it returns a temporary CWnd object. You can't just type-cast it to CFrameWnd and expect it to work. The temporary CWnd object is just a wrapper around the HWND (window handle) for the window.

The actual CWnd object for the window in the other application, even if there is one (there isn't if the application is not using MFC), is still not accessible from the other application, because different applications have their own separate memory spaces.

You're trying to listen to other applications, but what do you mean by listen? You want to know what documents they have open? This is different very every application. If you know how a particular application is written, maybe you can determine what file it has open, but this method of finding out probably won't work for any other type of application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top