Solved

HWND of an other application !

Posted on 1998-02-13
5
293 Views
Last Modified: 2013-11-20
How is it possible to retrieve the HWND of an other application
when I don't know his title.
The title of the other application is changing.

I wan't to use SendMessage in one application to send messages to
the second application.

APPLICATION 1  <---> (WM_USER + x) <---> APPLICATION 2

The title of both application are changing.
I can't use (FindWindow).

Can some one give me an example to do this ?

Thanks.
0
Comment
Question by:mike_marquet
5 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1316152
You must have some information on the app - it's proccess id or something. If you don't know anything, you can use EnumWindows to get all existing windows and pick the one you need.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1316153
You can use FindWindow if the classname of the window remains the same. It is highly unlikely that the classname of the window to change constantly.

If the classname is not unique, then you will have to use EnumWindows to find it.
0
 

Author Comment

by:mike_marquet
ID: 1316154
Ok but I have a problem with the FindWindow function. This function takes 2 parameters :
 ::FindWindow(<Class name>, <Title name>)
When I use this syntax : FindWindow(NULL,"TITLE") OK
but I don't know how to use the 'Class name'. What is it.
Is the first parameter the name of the class of the other application from which I wan't to have the HWND ?

class MyDlg : public CDialog
 {
  ...
 }

Must I write this : FindWindow("MyDlg", NULL); ?
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316155
If you have control over both applications, then you can set the WNDCLASS of the applications window(s).  

The "ClassName" is the "Class" of the window.  For example, the common Edit Control has a classname of "Edit".  You can set the classname when you register a new window class. (Take a look at AfxRegisterClass(...).)

Another thing you can do, although not the most effecient, is to enumerate all windows, and send them each (or only specific ones) a custom window message, expecting a magic nunber as a return.  When you get the proper reply, you have found your window.  This does, however, require that you can add code to the application(s) that you are looking for.

-=- James.
0
 
LVL 7

Accepted Solution

by:
galkin earned 20 total points
ID: 1316156
To retreive class name of specific window use GetClassName(Ex). If you are programming with MFC remember MFC generates unique class name for each mainframe window( if you have dialog application your dialog window class will have also unique name). This name is generated from MFC class AfxFrameOrView42 and handle of cursor and icon since they are actually class and not window attributes. So you cannot rely on specific class name to use in FindWindow. Other way, inpite of it being rahter not trivial and complicated is to register your own class with your predefined name but which would have the same attribute as if it were MFC class. Then knowing class name you can use it in Findwindow
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

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

10 Experts available now in Live!

Get 1:1 Help Now