Jump to content
  • Advertisement
Sign in to follow this  

Window Client Area Redraw Issue

This topic is 3276 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

Hi. I am very out of pactice in my C++ and have even forgotten how to make a window correctly! I am having an issue where the window displays but the client area never updates. it is a snapshot of whatever was under the window when it was displayed. How do I make the window client area display as the standard grey as I am expecting? I have pieced this together from examples on MSDN. (Some of which appear to not give all the info you need) Here is my code :
#include <windows.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{			
	case WM_DESTROY:
         PostQuitMessage( 0 );
         break;

	default :  return DefWindowProc(hwnd, uMsg, wParam, lParam);
	}
}


int WINAPI winmain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
    // Register the window class.
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WindowProc, 0L, 0L, 
	GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
	"test", NULL };

	RegisterClassEx( &wc );

	// Create the application's window.
	HWND hWnd = CreateWindowEx(0, "test", "test2", 
	WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, 100, 100, 300, 300,
	(HWND) NULL, (HMENU) NULL, wc.hInstance, NULL );  
    
	if (!hWnd) 
      return FALSE; 
 
    ShowWindow(hWnd, SW_SHOWDEFAULT); 
    UpdateWindow(hWnd); 

	MSG msg;
	BOOL fGotMessage;
    while ((fGotMessage = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0 && fGotMessage != -1) 
    { 
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
    } 

	return TRUE;
};


Any help appreciated. [Edited by - peter_mayes on May 30, 2009 2:34:40 AM]

Share this post


Link to post
Share on other sites
Advertisement
I'm not a WinAPI expert, but is it perhaps because you're not handling WM_PAINT messages?

Share this post


Link to post
Share on other sites
You need to either handle WM_PAINT as jyk mentioned or you need to initialize the hbrBackground member of your WNDCLASSEX instead of just slamming in NULL for everything.

Minor: you question has 100% absolutely nothing to do with C++.

Share this post


Link to post
Share on other sites
Thankyou.

Yes I needed the hbrBackground member filled in.

I think where I went wrong is I was looking at a DirectX example that doesn't bother filling it in as it renders straight to the cliant area in that sample (eventually).

Also :

"Minor: you question has 100% absolutely nothing to do with C++."

Except for the fact that my code sample is written in C++ and the syntax MAY have been wrong somewhere. :D (which wasn't the case here but it could have been)




Share this post


Link to post
Share on other sites
If you get stuck with the basics of creating a window AND you are using Visual C++ Express, start a new windowed project and you'll see all the code you need to create a sample window.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!