Sign in to follow this  
psae0001

Why the WM_PAINT doesn't work?

Recommended Posts

psae0001    100
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


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this