From: Michael Schnell [mailto:[email protected]] Sent: 23 April 2010 14:39 > AFAIR, WM_COPYDATA is the only message that can ONLY use SendMessage, > since the pointer is only guaranteed valid during the transaction (well, > initiator dependant, of course!) > >In Windows, it makes no sense to send messages like EM_LINEFROMCHAR with PostMessage, as they are used to request a result from the >receiver that comes as the SendMessage function value, while PostMessage does not have a function value other than true or false. > >Do you suggest that the memory array the pointer defines and the pointer itself automatically is managed to be valid for the receiver ? > >-Michael
I can only speak from how I've used it.. Windows does 'something' with WM_COPYDATA such that the memory is shared between both processes, whether they be in the same application space or not. I have used things like [NB away from a dev environment, so OTOH] PCopyData = TCopyData; TCopyData = record s: string; end; Sender: PCD = new(PCopyData); PCD^.s := 'Hello'; i := SendMessage(OtherApplicationFormHandle, WM_COPYDATA, PCD,0); Label.caption := intotostr(i); Receiver: PCD := WParam; Label.Caption := PCD^.s; result := 5; Note in http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx where it says 'The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed.' It's exciting stuff! I've found it very useful through the years. -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
