Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I noticed that there is 2 verision of sendMessage()

one under the CWnd class, and another uder the WINAPI

I found the prototype of the 2 sendMesage on MSDN.

C++
LRESULT WINAPI SendMessage(
	HWND hWnd,
	UINT Msg,
	WPARAM wParam,
	LPARAM lParam
);

CWnd::LRESULT SendMessage(
	UINT message,
	WPARAM wParam = 0,
	LPARAM lParam = 0 
);


Question:
1.What is the difference between these two?
2.Which verision is used under what situation?( an example would be nice)
3.For the CWnd class verision, that is the hWnd send? ( does it default to the hWnd of the object that sends the message?)

Thanks ~
Posted
Comments
CPallini 3-Dec-12 17:08pm    
That's the peculiarity of (the original?) MFC: a thin wrapper around the Windows API.
Mohibur Rashid 3-Dec-12 22:04pm    
I believe you need to understand both how windows work, how mfc work under windows and also C++ to understand how mfc work in this situation

chronoseraph wrote:
1.What is the difference between these two?

One belongs to the Windows API and the other is the MFC version.

chronoseraph wrote:
2.Which verision is used under what situation?( an example would be nice)

If you're using MFC, you might as well use the MFC version... it's usually easier to use when you're in that context anyway.

chronoseraph wrote:
3.For the CWnd class verision, that is the hWnd send? ( does it default to the hWnd of the object that sends the message?)

It uses the hwnd that corresponds to the particular cwnd object. If you don't know the difference between hwnd and cwnd, that's a whole-nother bag-o-worms.

Hope that helps a bit.
 
Share this answer
 
v2
Comments
CPallini 3-Dec-12 17:05pm    
My 5.
Albert Holguin 3-Dec-12 17:33pm    
Thank you
[no name] 3-Dec-12 22:51pm    
Good answer.
Albert Holguin 4-Dec-12 13:46pm    
Thank you Sajeesh
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900