Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while ( ::PeekMessage(&msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) )

this loop is not ending some times could you please let me know what might be the problem.


this functionality i wrote for Track the strecthing of a cell.

What I have tried:

C++
while ( true )
{
		MSG msg;
		while ( ::PeekMessage(&msg, m_hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) )
		{
			if ( msg.message != WM_MOUSEMOVE )
			{
				dc.DrawDragRect(&cRectLast, CSize(2, 2), NULL, CSize(2, 2));
				DispatchMessage(&msg);
				return;
			}
			else
			{
				CPoint cPoint(GET_X_LPARAM(msg.lParam),    GET_Y_LPARAM(msg.lParam));
            }
Posted
Updated 2-Dec-17 22:31pm
v2

1 solution

The documentation of PeekMessage says that it only returns false, if no message is available. Take also a look at the example code in this articel.

Make an output of the incoming messages to better understand the incoming messages.

Your code snippet: the outer loop will only get exited with the return, else you get an re-entry per the heading while.
 
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