I have written a program in C++ & a program in VB4 (16-bit).
The VB program need to sendmessage to the C++ program whenever a
command button is click.
My solution is to use FindWindow() to get the window handler of the
C++ Program("My Program"). Then using the handler to sendmessage()
from VB program.
------------------------
'Constant & Declaration
Global wndMyProgram As Integer
Global Const WM_USER=&H400
Global Const WM_USER1= WM_USER +1
Declare Function FindWindow Lib "User"(ByVal lpClassName As Any,
ByVal lpWindowName As Any) As Integer
Declare SendMessage Lib "User"(ByVal hwnd As Integer,ByVal wMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Any)As Long
Sub Form_Load()
wndMyProgram = FindWindow(NULL, "My Program")
End Sub
Sub cmdButton1_Click()
Dim ret As Integer
ret = SendMessage(wndMy, WM_USER1, 0, 0)
End Sub
----------------------------------------------
My Problem:
Why is it that wndMyProgram is always 0(Using debug to watch) ?
"My Program" don't received the message.
Where is my mistake ?
Any comment and advice will be appreciated.
Thanks very much.
LOW PS