Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Apr : Message response lost
| Subject: | Message response lost |
| Posted by: | "John Schmidt" (j.schmi..@npkelektro.com) |
| Date: | Tue, 3 Apr 2007 08:50:14 |
Hello,
If I'm sending a message by SendMessage() to a kind of server which responds
with handshake message. This works if I send the message from the
application's main form directly. If I do the same from a subform, sending a
'mediating' message to the main form which triggers a method which sends
then the message to the server, then I don't get any answer message back.
I have checked the source handle (Application.MainForm.Handle) it's the same
every time. So the server knows where to send back the answer. The used
method is below and the message to be returned is WM_COPYDATA too.
Why does this work when sent directly from the main form and not, if sent by
a 'mediating' message launched by a subform?
var
ACopyData: TCopyDataStruct;
HSrv: HWnd;
Data: string;
begin
HSrv := FindWindow(PChar(SRVClass), PChar(SRVWnd));
if HSrv <> 0 then
begin
Data := SRVWnd + ' ' + IntToStr(Application.MainForm.Handle) + ' ' +
{some data string};
ACopyData.dwData := 0;
ACopyData.cbData := Length(Data) + 1;
ACopyData.lpData := PChar(Data);
SendMessage(HSrv, WM_COPYDATA, Longint(Application.MainForm.Handle),
Longint(@ACopyData));
end;
end;