Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Windows messaging

Avatar of DanHamm
DanHamm asked on
DelphiWindows OS
1 Comment1 Solution308 ViewsLast Modified:
I have a single windows application where I pass messages between different modules using the standard SendMessage and PostMessage.  This all works

When passing a string, I use the code:

    copyDataStruct.dwData := 1;
    copyDataStruct.cbData := 1 + Length(AString);
    copyDataStruct.lpData := PChar(AString);

    SendMessage(Application.MainFormHandle, WM_PLG_COPYDATA, ATarget, Integer(@copyDataStruct));

where WM_PLG_COPYDATA is a messaging constant private to my own application, which is received by a message function of the form
    procedure WMCopyData(var Msg : TWMCopyData); message WM_PLG_COPYDATA;

This also works, although all of the examples I have seen (copying between applications) use the standard procedure WMCopyData(var Msg : TWMCopyData); message WM_COPYDATA;

My question is: is there any reason why I should stick to the standard WM_COPYDATA rather than a private constant?  I have done a check for memory leaks, and everything seems OK
Avatar of ThievingSix
ThievingSixFlag of United States of America imageDeveloper

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers