Why the WM_PAINT doesn't work?

Started by
1 comment, last by psae0001 18 years, 5 months ago
Ok, I got a problem here, my WndProc function doesn't seem to respond the wm_paint function - when I want to update the window. I'm not idea why the window doesn't update without me to resize or do something with it. Any idea?


LRESULT CALLBACK app_proc_callback ( HWND h_wnd, UINT u_msg, WPARAM w_par, LPARAM l_par )
{

	HDC				hdc = NULL ;
	RECT			rt = { 0 } ;
	PAINTSTRUCT		ps = { 0 } ;
	static char test_str [ 10 ] = "" ;

	switch ( u_msg )
	{

	case WM_CHAR:					// MUST have this messsage otherwise the thread
									// WILL NOT capture each input
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:

	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:

	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:

	case WM_SYSKEYDOWN:
	case WM_SYSKEYUP:

	case WM_KEYDOWN:
	case WM_KEYUP:

		sprintf ( test_str, "%s", "keys" ) ;
		PostMessage ( h_wnd, WM_PAINT, 0, 0 ) ;
		UpdateWindow ( h_wnd ) ;

		return 0;

	case WM_PAINT:

		hdc = BeginPaint ( h_wnd, &ps ) ;
		// TODO: Add any drawing code here...
		GetClientRect ( h_wnd, &rt ) ;
		DrawText ( hdc, test_str, -1, &rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE ) ;
		EndPaint ( h_wnd, &ps ) ;

		return 0 ;

	case WM_DESTROY:

		PostQuitMessage(0) ;

		return 0 ;

	}

	return DefWindowProc ( h_wnd, u_msg, w_par, l_par ) ;

}


// end


Advertisement
Try InvalidateRect followed by UpdateWindow. You don't need the call to PostMessage.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
YAAAAAHOOOOOOOOOOOO !!!!

Thank you!

This topic is closed to new replies.

Advertisement