HWND of an other application !

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.
mike_marquetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MikeP090797Commented:
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
Tommy HuiEngineerCommented:
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
mike_marquetAuthor Commented:
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
jtwine100697Commented:
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
galkinCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.