Link to home
Start Free TrialLog in
Avatar of sheepfarmer
sheepfarmer

asked on

Adding a message loop in Delphi

I am looking to implement some sort of message or callback within a Delphi comms program.

I have a main form and a secondary form containing all the comms stuff.

I call a function on the comms form to send a comms request.
The comms form sends the message for me and has a receive event that collected the received information (which can take 5-10 seconds)

I need some method of the comms form letting the main form that something has been received on the comms port.

What would be an appropriate way to do this?

Thanks
SF
ASKER CERTIFIED SOLUTION
Avatar of btframework
btframework
Flag of Belarus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sheepfarmer
sheepfarmer

ASKER

Indeed, I have implemented your second suggestion.
The comms form does have an event for 'data received' (using the ComPort library) so when that it's fired, I gather the data I need, then send a message to the main form.

What is the different between SendMessage and PostMessage (I am using the latter as I found that via separate research).

Also, I am using 0 for DataPointer and DataLength as I only need to know when there is data received (I collect the data from the comms form via a direct function call).  Presumably its perfectly valid to just send
SendMessage(MainForm.Handle, WM_USER+10, 0,0));

Thanks
SF
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot.

SF