Solved

Sending Message

Posted on 1998-12-26
9
166 Views
Last Modified: 2010-04-04
how do i passing a additional parameter to my message handler ? let say i write my own message and send my additional parameter to my message handler instead of using the LParam and WParam.
0
Comment
Question by:qwertyuiopasdfghjkl
9 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1353156
If your additional data is a record then you use a pointer and send it with the lparam or wparam..

SendMessage(Handle, Message, lparam, longint(@data));
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353157
oh, I forgot, then when you receive it you typecast it like this...

var
  myrec : TMYREC;
begin
  myRec := TMYREC(msg.lparam^);
 //Then use your record here... It can work for any variable or type or whatever..You just send a pointer with the message...
end;

-Viktor
--Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1353158
is this what you needed??
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1353159
Vik's method is a good idea...however, don't you have to pass the pointer thru the LParam?  [If I remember correctly, WParam is a word, and a pointer is a double-word]
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Expert Comment

by:viktornet
ID: 1353160
Oppps... Scrappy :) is right... Actualy that's exactly what I've done, but I have a typo that makes it look if I've exchanged the parameters...

This line

SendMessage(Handle, Message, lparam, longint(@data));

should be

SendMessage(Handle, Message, wparam, longint(@data));

sorry for da typo... :))

Does it help now? Am I allowed to answer the q'n?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1353161
Scrappy is only half right (sorry to be picky). Yes you should use LParam, but, Wparam in Win32 is a DWORD!

Cheers,

Raymond.

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1353162
Yes, Raymond is right. In win16, wParam is 16 bit long, in win32 it is 32 bit long.

However, if you send messages from one application to another, you can't just give in a pointer to a data block, since the pointer will definitely be invalid in the other application's memory context.
So if you're sending this message from one of your applications to another one of your applications, you'll have to look at the WM_COPYDATA message, which is thought for this purpose.
Otherwise (that means if the message is sent and received from the same application) Viktor's solution is right.
0
 

Author Comment

by:qwertyuiopasdfghjkl
ID: 1353163
ok..Viktor ...you can post it as answer now...
0
 
LVL 10

Accepted Solution

by:
viktornet earned 30 total points
ID: 1353164
10Q

btw- Madshi is right about the WM_COPYDATA.

Happy New Year (Well almost)

-Viktor
--Ivanov
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now