|
-
Aug 21st, 2000, 11:22 AM
#1
Thread Starter
Junior Member
I am writing a vb program that utilizes two separate applications. One is the user interface and display the other is for data acquisition through usb. To communicate between the two applications I would like to use the PostMessage() API.
I am having trouble understanding how the application interprets the message. I read an article for closing an application that had the sample code below:
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Sub CloseProgram()
Dim winHwnd As Long
Dim RetVal As Long
Const WM_CLOSE = &H10
winHwnd = FindWindow(vbNullString, "Calculator")
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
End If
End Sub
So here is the question. The Const WM_CLOSE = &H10, how do you come up with &H10? Are the standard WM_ values defined somewhere? I am not interested specifically the WM_CLOSE but all of the WM_ messages.
Also is there a way to define your own WM_ and have the other application respond.
Anyone have any answers.
-
Aug 21st, 2000, 11:34 AM
#2
Messages, Constants and Structures (called Types in VB) are listed in the API Text Viewer.
Start > Programs > Microsoft Visual Basic > API Text Viewer.
Once you are in it, go to File > Load TextFile and select Win32API.txt. In the API Type ComboBox, select Constants and you'll be given a list of constants.
-
Aug 21st, 2000, 11:52 AM
#3
Thread Starter
Junior Member
What about defining your own WM_? Say I wanted to pause a timer in another application. How could I
RetVal = PostMessage(winHwnd, WM_PauseTimer1, 0&, 0&)?
-
Aug 21st, 2000, 12:09 PM
#4
WM_? are just constants for different messages. To write your own, you would have to define the constant in a DLL file and write it's prodecure up yourself.
-
Aug 21st, 2000, 01:08 PM
#5
transcendental analytic
Yep, i think you can define whatever messages you want, it's only the number that will be passed, not the WM_...
Code:
WM_MessageToBluelocust=&H1000000
The problems is that you have to find a number that does not interfer with the window messages, for instance WM_CLOSE.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|