delphiwindows-messagesdatamodule

Delphi - How do I send a windows message to TDataModule?


I need to send a windows message to a TDataModule in my Delphi 2010 app.

I would like to use

PostMessage(???.Handle, UM_LOG_ON_OFF, 0,0);

Question:

The TDataModule does not have a Handle. How can I send a windows message to it?


Solution

  • You can give it a handle easily enough. Take a look at AllocateHWND in the Classes unit. Call this to create a handle for your data module, and define a simple message handler that will process UM_LOG_ON_OFF.