Click to See Complete Forum and Search --> : Bad things when window goes offscreen


Calculator
July 19th, 2006, 07:23 PM
I guess my problem can be best expressed by a screenshot.

http://img.photobucket.com/albums/v221/Tonto1/shithappensyo.jpg

This happens when I hold down the mouse over the caption, drag it down (window recieves WM_WINDOWPOSCHANGING/WM_WINDOWPOSCHANGED notifications) so the client area is below the start menu, and pull it back up. This whole thing I think is complicated by several factors. One is that this sort of a game application, so my message loop uses peekmessage and does a paintroutine while it idles between messages, I do not handle WM_PAINT messages. So, if I tried to just invalidaterect when I recieve these messages, it doesn't rect do anything. Also, I can change this if I need to, but I also have it so that WM_ERASEBKGND just returns and does not do anything. Is there any way that I can fix this problem?

ovidiucucu
July 20th, 2006, 02:33 AM
handle WM_PAINT message.

Calculator
July 20th, 2006, 03:07 PM
Okay, I rearranged to some of my WindowProc to have

case WM_PAINT:
{
PAINTSTRUCT ps;
::BeginPaint(hwnd, &ps);
PaintRoutine(hwnd);
::EndPaint(hwnd, &ps);
break;
}
case WM_ERASEBKGND:
return 1;

And my message loop to

while(true)
{
if(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT) break;

::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
::UpdateWindow(hwnd);
::Sleep(100);
}
}

And now it is smooth, I don't have the problem, it just takes a bit of CPU (30% - 40%) when I move the window around a bit. I don't think that's a problem?

CraigV
July 20th, 2006, 05:15 PM
Unless your programming some Graphic intensive window with using DirectX or you need to process some sort of code while the Window Message Pump is Empty, why use PeekMessage?? Your only killing CPU... Stick with a GetMessage Loop for standard Apps unless PeekMessage Is Needed

Calculator
July 20th, 2006, 05:33 PM
Um, it used to be very choppy for some reason that I forget about, but I changed it back to a getmessage-style loop and it seems to be fine now. I am kind of trying to make pixely blocky games, but nothing graphically intense ;) I have a 2-D grid of COLORREF's and I fill in an offscreen dc with Rectangle()'s based on the grid.

CraigV
July 20th, 2006, 05:53 PM
Yea sounds like my little GDI Snakes game i made back in the day, Just stick with the GetMessage Loop for that it'll free up some of that CPU, control speed of drawing Your Rectangles with a Timer ;)