Click here to Skip to main content
16,011,680 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: InternetGetConnectedState() failed on WINME Pin
David Crow4-Oct-04 4:14
David Crow4-Oct-04 4:14 
GeneralSending data with ::SendMessage(...) function Pin
Muhammad Azam3-Oct-04 18:49
Muhammad Azam3-Oct-04 18:49 
GeneralRe: Sending data with ::SendMessage(...) function Pin
ThatsAlok3-Oct-04 19:18
ThatsAlok3-Oct-04 19:18 
GeneralRe: Sending data with ::SendMessage(...) function Pin
Steen Krogsgaard4-Oct-04 3:52
Steen Krogsgaard4-Oct-04 3:52 
GeneralRe: Sending data with ::SendMessage(...) function Pin
Ed K4-Oct-04 16:07
Ed K4-Oct-04 16:07 
GeneralRe: Sending data with ::SendMessage(...) function Pin
Steen Krogsgaard4-Oct-04 20:50
Steen Krogsgaard4-Oct-04 20:50 
GeneralRe: Sending data with ::SendMessage(...) function Pin
Muhammad Azam4-Oct-04 20:33
Muhammad Azam4-Oct-04 20:33 
GeneralRe: Sending data with ::SendMessage(...) function Pin
Steen Krogsgaard4-Oct-04 21:25
Steen Krogsgaard4-Oct-04 21:25 
Hi Muhammad,

this is why I made the distinction between SendMessage and PostMessage. SendMessage is synchronous meaning that it will call the receiving windows' WindowProc directly, bypassing the message queue. So the call to SendMessage will behave exactly as any other function call. It is not possible for cs1 or cs2 to go out of scope or to be changed by the caller during the call. What the callee does with the data is another matter, and these changes will be relayed back to the caller as you have passed cs1 and cs2 as references (pointers).

The points you have here are absolutely valid if you use PostMessage. It's a "fire-and-forget" call - you have no control or knowledge about when the callee will execute. In this case it's best to pass a copy of the data in the call:

<br />
// pass a copy:<br />
LPTSTR lpsz1 = new TCHAR[cs1.GetLength()+1];<br />
_tcscpy(lpsz1, cs1);<br />
::PostMessage(hwnd, WM_MYMESSAGE, (WPARAM)lpsz1, 0),<br />


Cheers
Steen.

"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
GeneralRe: Sending data with ::SendMessage(...) function Pin
Muhammad Azam4-Oct-04 23:26
Muhammad Azam4-Oct-04 23:26 
GeneralActive X Problem Pin
BAIJUMAX3-Oct-04 17:31
professionalBAIJUMAX3-Oct-04 17:31 
Generalcontext and winhelp menus not staying in foreground Pin
raultkd3-Oct-04 16:45
raultkd3-Oct-04 16:45 
QuestionI'm floating integer to hex? Pin
BOBOBOBOBS3-Oct-04 15:53
BOBOBOBOBS3-Oct-04 15:53 
AnswerRe: I'm floating integer to hex? Pin
ThatsAlok3-Oct-04 19:09
ThatsAlok3-Oct-04 19:09 
AnswerRe: I'm floating integer to hex? Pin
mirex4-Oct-04 2:40
mirex4-Oct-04 2:40 
GeneralHelp Pin
Anonymous3-Oct-04 14:22
Anonymous3-Oct-04 14:22 
GeneralRe: Help Pin
ThatsAlok3-Oct-04 20:36
ThatsAlok3-Oct-04 20:36 
GeneralExtract HBITMAP from IMAGELIST icon Pin
peterchen3-Oct-04 14:15
peterchen3-Oct-04 14:15 
GeneralRe: Extract HBITMAP from IMAGELIST icon Pin
PJ Arends3-Oct-04 16:24
professionalPJ Arends3-Oct-04 16:24 
GeneralMFC Progress Bar Pin
Anonymous3-Oct-04 11:59
Anonymous3-Oct-04 11:59 
GeneralRe: MFC Progress Bar Pin
ThatsAlok3-Oct-04 19:25
ThatsAlok3-Oct-04 19:25 
GeneralRe: MFC Progress Bar Pin
pubududilena4-Oct-04 0:06
pubududilena4-Oct-04 0:06 
QuestionWinVerifyTrust on legacy Win9x? Pin
Jason De Arte3-Oct-04 10:36
Jason De Arte3-Oct-04 10:36 
AnswerRe: WinVerifyTrust on legacy Win9x? Pin
Jason De Arte3-Oct-04 17:01
Jason De Arte3-Oct-04 17:01 
Generalresource is open in another editor Pin
Anonymous3-Oct-04 10:08
Anonymous3-Oct-04 10:08 
GeneralRe: resource is open in another editor Pin
pubududilena3-Oct-04 21:07
pubududilena3-Oct-04 21:07 

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.