Click here to Skip to main content
16,004,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Pass pointer to double array as func. parameter Pin
Tom Archer5-Jun-05 8:01
Tom Archer5-Jun-05 8:01 
GeneralRe: Pass pointer to double array as func. parameter Pin
Dominik Reichl5-Jun-05 9:54
Dominik Reichl5-Jun-05 9:54 
GeneralRe: Pass pointer to double array as func. parameter Pin
Michael Dunn5-Jun-05 18:02
sitebuilderMichael Dunn5-Jun-05 18:02 
GeneralRe: Pass pointer to double array as func. parameter Pin
Robert Palma Jr.6-Jun-05 5:03
Robert Palma Jr.6-Jun-05 5:03 
GeneralSend a data with a message Pin
Pasquale825-Jun-05 6:44
Pasquale825-Jun-05 6:44 
GeneralRe: Send a data with a message Pin
Tom Archer5-Jun-05 8:08
Tom Archer5-Jun-05 8:08 
GeneralRe: Send a data with a message Pin
Jack Puppy5-Jun-05 8:11
Jack Puppy5-Jun-05 8:11 
GeneralRe: Send a data with a message Pin
Rouslan Grabar [Russ]5-Jun-05 18:59
Rouslan Grabar [Russ]5-Jun-05 18:59 
Yes, as other have just suggested you may cast your int and string to wparam and lparam repectively.
But what are you going to do if you will need to pass more data than do not fit in two variables later? I'd suggest to declare a struct, that would contain any information you need to pass with a message. This has one long tern advantage - if the code to be tweaked sometime later, tweaking will not affect function signatures and the app's architecture.


<br />
struct MYMESSAGEDATA<br />
{<br />
 int    nInteger;<br />
 char*  nString;<br />
 // add here anything you want later<br />
 // e.g. status flags, length of a string, etc.<br />
};<br />
<br />
...<br />
...<br />
MYMESSAGEDATA* pData = new MYMESSAGEDATA;<br />
pData->nInteger = 1;<br />
pData->nString = "string";<br />
...<br />
...<br />
<br />
::SendMessage(hwnd, msg, NULL, (WPARAM)pData); <br />
<br />
...<br />
LRESULT CProvaDlg::OnMyMessage1(WPARAM wParam, LPARAM lParam)<br />
{ <br />
// cast lprama back to our message data<br />
MYMESSAGEDATA* pIncomingData = (MYMESSAGEDATA*)lParam;<br />
<br />
//do what ever you need <br />
<br />
...<br />
...<br />
<br />
//deallocate memory<br />
delete pIncomingData;<br />
<br />
return 0;<br />
}<br />


As you can see in above example, you have a spare wParam which could be used to pass, for example, ID of the sender of the message, consider it as another advantage of this approach.

Smile | :)
GeneralRe: Send a data with a message Pin
ThatsAlok5-Jun-05 19:32
ThatsAlok5-Jun-05 19:32 
GeneralRe: Send a data with a message Pin
Pasquale826-Jun-05 6:28
Pasquale826-Jun-05 6:28 
GeneralTree MDI Framework Pin
laiju5-Jun-05 5:57
laiju5-Jun-05 5:57 
GeneralSeconde mouse Pin
Member 19344145-Jun-05 3:38
Member 19344145-Jun-05 3:38 
GeneralRe: Seconde mouse Pin
Michael Dunn5-Jun-05 18:08
sitebuilderMichael Dunn5-Jun-05 18:08 
GeneralC# interop with DLL Pin
scchan19845-Jun-05 1:57
scchan19845-Jun-05 1:57 
GeneralUsing MFC Pin
Member 20005495-Jun-05 1:24
Member 20005495-Jun-05 1:24 
GeneralRe: Using MFC Pin
David Crow5-Jun-05 10:30
David Crow5-Jun-05 10:30 
GeneralRe: Using MFC Pin
Nilesh K.5-Jun-05 22:53
Nilesh K.5-Jun-05 22:53 
GeneralCTreeCtrl GetSelectedItem() Pin
laiju5-Jun-05 1:18
laiju5-Jun-05 1:18 
GeneralRe: CTreeCtrl GetSelectedItem() Pin
Jack Puppy5-Jun-05 8:33
Jack Puppy5-Jun-05 8:33 
GeneralCTreeCtrl GetSelectedItem() Pin
laiju5-Jun-05 1:17
laiju5-Jun-05 1:17 
GeneralRe: CTreeCtrl GetSelectedItem() Pin
Dominik Reichl5-Jun-05 10:05
Dominik Reichl5-Jun-05 10:05 
Generaludp sockets Pin
Usman Tasleem Akshaf4-Jun-05 22:59
Usman Tasleem Akshaf4-Jun-05 22:59 
GeneralRe: udp sockets Pin
S Douglas4-Jun-05 23:06
professionalS Douglas4-Jun-05 23:06 
GeneralRe: udp sockets Pin
Usman Tasleem Akshaf5-Jun-05 4:11
Usman Tasleem Akshaf5-Jun-05 4:11 
GeneralRe: udp sockets Pin
S Douglas5-Jun-05 4:23
professionalS Douglas5-Jun-05 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.