reeset
Jul 31st, 2001, 03:01 PM
I have a quick question. In the General forum, Megatron had made mention of the RegisterWindowMessage API as an option for passing data between two programs. Since I had never used this little nugget, I tried setting up my own message, and then using SendMessage to pass a string variable through the lParam and the string's length through the wParam. In the project, I was able to successfuly create the message, detect the message, and use the SendMessage to pass a pointer to a string, but I am having difficulty reading the value that the pointer addresses. Anyway, here is the message from the post. I realize that it is addressed to Megatron, but I'm looking for anyone that can offer a little light on this subject.
--Thanks
Megatron:
I have a quick question since you suggested it. I've never created my own windows messages before, so I setup up a quick example, and found the message setup very easy. However, I run into problems when I try to pass information, well namely strings, back to the callback. Using the SendMessage API, I call the message, and add length of a string in wparam, and the strptr in lparam
SendMessage HWND_BROADCAST, WM_MYMESSAGE, LENB(cmdline), StrPtr(cmdline)
Now in the callback, I try to do the following:
Case WM_MYMESSAGE
Dim a as string
a=Space(wParam)
CopyMemory Byval StrPtr(a), VarPtr(lParam), wParam
msgbox a
End Select
The event fires, but the string I'm getting is just random characters, so I'm guessing that the wrong address is being read. Do you have any suggestions. I though about using WM_COPYDATA, but again, I couldn't get the data to format correctly.
Thanks
--Thanks
Megatron:
I have a quick question since you suggested it. I've never created my own windows messages before, so I setup up a quick example, and found the message setup very easy. However, I run into problems when I try to pass information, well namely strings, back to the callback. Using the SendMessage API, I call the message, and add length of a string in wparam, and the strptr in lparam
SendMessage HWND_BROADCAST, WM_MYMESSAGE, LENB(cmdline), StrPtr(cmdline)
Now in the callback, I try to do the following:
Case WM_MYMESSAGE
Dim a as string
a=Space(wParam)
CopyMemory Byval StrPtr(a), VarPtr(lParam), wParam
msgbox a
End Select
The event fires, but the string I'm getting is just random characters, so I'm guessing that the wrong address is being read. Do you have any suggestions. I though about using WM_COPYDATA, but again, I couldn't get the data to format correctly.
Thanks