How to use SendMessage to another form in same app
- by Robert Frank
I've been trying to get this to work for some time now and can't figure it out. Probably obvious once you know it.
I simply want a non-modal form (or perhaps an instantiated non-TForm class) to send a message to the application's main form.
I can make the main form send a message to itself and receive (announcing with a beep)
But, I can't seem to have other objects send messages to the main form.
I'm using WM_MY_MESSAGE = WM_APP + 200;
What should the first argument of the SendMessage be to send a message to the main form? Even sending it to Application.MainForm.Handle doesn't seem to work.
The reason I need to do this is that the modal form has a slider that another form (#2) needs to know when it changes. Notifying the other form via a callback procedure was making it sluggish as form #2 did some work before returning from the call. Is having a modal form send a windows message to the main form a reasonable way to avoid this?