Solved

HWND of an other application !

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

Technology Partners: 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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