next up previous contents
Next: Memory Mapped Files Up: How to implement a Previous: Message loop   Contents

How to define a new message type

To define a new message type, we need a constant that does not collide with something previously defined by the operating system or by other applications. In GPU, we call a Windows API function at startup that hashes a string to a constant.

procedure TForm1.FormCreate(Sender : TObject)
begin
 WMsgGPURequest := RegisterWindowMessage('GPURequest');
 WMsgGPUResult  := RegisterWindwoMessage('GPUResult');
end;

To send a message we can then call

SendMessage(GPUHWnd,WMsgGPURequest,0,0);

GPUHWnd is the Handle that identifies the GPU application. It can be retrieved using

GPUHWnd := FindWindow('TMainForm', nil);



Tiziano Mengotti 2004-03-27