Solved

Sending Message

Posted on 1998-12-26
9
167 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 191
How to call a form that is in a DLL  from an application? 13 65
tidtcpserver connection lost handle 2 71
Create a path if not exists 7 69
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

13 Experts available now in Live!

Get 1:1 Help Now