Solved

HWND of an other application !

Posted on 1998-02-13
5
311 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
[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
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

Independent Software Vendors: 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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

731 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