Jump to content
  • Advertisement
Sign in to follow this  
psae0001

Why the WM_PAINT doesn't work?

This topic is 4655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!