
-----------------------------------
np_123
Sat Jan 27, 2018 6:44 pm

Wait for mouse button press (outside of callback)
-----------------------------------
I create a window and the below code is the callback for it.
What I'm looking for is a way to wait for those events to happen, using the callback essentially as a trigger. But doing something like toggling a boolean variable and having a loop waiting for it would cause the UI to hang as it's event-driven. Any suggestions?




LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window
							UINT	uMsg,			// Message For This Window
							WPARAM	wParam,			// Additional Message Information
							LPARAM	lParam)			// Additional Message Information
{
	switch (uMsg) {
	case (WM_LBUTTONDOWN | WM_RBUTTONDOWN): // | WM_LBUTTONUP | WM_RBUTTONUP):
		Cursor.X = GET_X_LPARAM(lParam);
		Cursor.Y = GET_Y_LPARAM(lParam);
		Cursor.buttonmask = wParam;
		break;
	case WM_MOUSEMOVE:
		Cursor.X = GET_X_LPARAM(lParam);
		Cursor.Y = GET_Y_LPARAM(lParam);		
		break;
	case WM_CLOSE:
		MIOGLGraph_CloseWin();
		stGLWinClosed = TRUE;
		return 0;
	}

	// Pass All Unhandled Messages To DefWindowProc
	return DefWindowProc(hWnd,uMsg,wParam,lParam);
}


-----------------------------------
np_123
Sat Jan 27, 2018 8:31 pm

RE:Wait for mouse button press (outside of callback)
-----------------------------------
Nvm figured it out.
I reversed my logic as in:

My non-callback function continuously returns a boolean value determined by an internal variable. I loop on this function, waiting for it to be True. (I assume because it's always entering & returning the procedure, that's why it doesn't hang).
When the callback registers a click it sets the variable to True. This causes the function to return True. Problem now solved.
Ty
