Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send a string via SendMessage ?

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi

I have a progress label in my main form, and lots of objects which do different processes. When I reach a certain object level, I can't 'see' the main form. I'd like to send a string (eg. 'processing prices') via SendMessage (from the lower objects) so the main form will capture it and update the progress label.

How do I do it?
lou
(I am trying - a lot of people have told me that)
 
Best way would probably be to do
SendMessage(mainFormHandle, WM_USER, 0, 0)
Disinguish between different events you want to signal by using WM_USER + 1, WM_USER + 2 etc.

Or, if you want to be able to pass arbitrary strings, just pass a pointer to one in the wparam/lparam parameter.
 
Thanks, Mike. lou
(I am trying - a lot of people have told me that)
 
hi Mike

I'm now trying to actually send a string via the wparam but can't get it to work. Could you help me:-

//in other object
var MainMsg : string;
pMainMsg : array[0..79] of char;
:
pMainMsg := 'Checking yield...';
SendMessage(Globals.MainFormHandle, WM_UPDATEPROGRESSLABEL, integer(pMainMsg),0); //pMainMsg = invalid typecast


//in main form
procedure TFormMain.WMDISPLAYMESSAGE(var Message: TMessage);
begin
//Update progress label with message.WParam;
pnlProgress.Caption := StrPas(Pointer(Message.WParam));
end;

many thanks lou
(I am trying - a lot of people have told me that)
 
Should be:

SendMessage(Globals.MainFormHandle, WM_UPDATEPROGRESSLABEL, integer(@pMainMsg),0);
 
Brilliant, thankyou. lou
(I am trying - a lot of people have told me that)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top