MsgHandler doesn't work
Posted: Thu Dec 15, 2011 7:19 am
Hello,
I work on Delphi 6 and try to make communication between 2 process with windows message. One of the process (Process1) is not a window so I use the MsgHandler to create an invisible windows. I create 2 handlers using AddMsgHandler and wait for messages from the other process (Process2).
Process2 send 2 different kinds of message, one is is a PostMessage with lparam containing an integer value (it works) but the second is a SendMessage with lparam containing TCopyDataStruct and here is the issue, Porcess1 never receive the messages.
Here is the method which send the unreceived message.
Here is the creation of messages handler, note that WM_ACKNACK is a home message but it's the message I can receive...
Is someone have an idea of what's happen?
Thanks.
I work on Delphi 6 and try to make communication between 2 process with windows message. One of the process (Process1) is not a window so I use the MsgHandler to create an invisible windows. I create 2 handlers using AddMsgHandler and wait for messages from the other process (Process2).
Process2 send 2 different kinds of message, one is is a PostMessage with lparam containing an integer value (it works) but the second is a SendMessage with lparam containing TCopyDataStruct and here is the issue, Porcess1 never receive the messages.
Code: Select all
procedure SendMessage(AReceiveStringList : TStringList);
var
LReceivedMsg : string;
LCopyDataStruct : TCopyDataStruct;
begin
if AReceiveStringList .Count > 0 then
begin
LReceivedMsg := ReceiveStringList.Strings[0];
LCopyDataStruct .dwData := hdr_ComAxe;
LCopyDataStruct .cbData := Length(LReceivedMsg ) + 1;
LCopyDataStruct .lpData := PChar(LReceivedMsg );
if (Pos('EB',ReceivedMsg) > 0) then
begin
Windows.SendMessage(Self.FCommunicationHandle, WM_COPYDATA, 0, Integer(@LCopyDataStruct ));
end;
end;
Code: Select all
constructor TSequencesLoader.Create(ALogger : TLogger);
begin
inherited Create();
// Allocation des MsgHandler pour la réception des réponses d'A_Com_Ax
madTools.AddMsgHandler(ManageCopyDataMessage, WM_COPYDATA);
madTools.AddMsgHandler(ManageAckNackMessage, WM_ACKNACK);
end;
Is someone have an idea of what's happen?
Thanks.