Solved

Sending Message

Posted on 1998-12-26
9
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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