A Conversation for (Visual Basic Tip) Inter process communication using Sendmessage
What to do if your window title is constantly changing?
Researcher 198336 Started conversation Jul 11, 2002
I am developing an application who main form title keeps changing. How can I adapt the sendmessage api to account for this?
What to do if your window title is constantly changing?
Is mise Duncan Posted Jul 12, 2002
There are two possibilities....
First you can use FindWindow() to return the window handle if you know it's caption, or it's class name :
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
hwndRet = FindWindow("OpusApp",vbNullString)
will find the first MS Word window...
Or you can write your server application so that it responds to a particular message by returning it's window handle. Then when a client starts up they broadcats a "where are you" message which the server responds to with an "I am here" message.
Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&
Call SendMessage(HWND_BROADCAST, RegisterWindowmessage("WM_WhereAreYou"), Me.hwnd, 0)
Then when the server recieves it....
If wMsg = RegisterWindowmessage("WM_WhereAreYou") Then
SendMessage(wParam, RegisterWindowMessage("WM_IAmHere"), Me.hwnd, 0)
Hope this helps,
Duncan
Key: Complain about this post
What to do if your window title is constantly changing?
More Conversations for (Visual Basic Tip) Inter process communication using Sendmessage
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."