#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;
};
Window Client Area Redraw Issue
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 :
Any help appreciated.
[Edited by - peter_mayes on May 30, 2009 2:34:40 AM]
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++.
Minor: you question has 100% absolutely nothing to do with C++.
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)
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)
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement