Window contents will not update

Started by
1 comment, last by DividedByZero 13 years, 1 month ago
Hi Guys,

I have a wierd one. I am drawing a bitmap inside my WM_PAINT message and it will not show up.

But! If I call a message box within the WM_PAINT message (to check that WM_PAINT is being called) the bitmap will show up - but then I get a message box that I dont want.

case WM_PAINT:
{
if(bDataReceieved)
{
HBITMAP hBitmap;
PAINTSTRUCT ps;
char *tempImageArea;

hBitmap=CreateDIBSection(NULL,bmInfoHeader,DIB_RGB_COLORS,(void**)&tempImageArea,NULL,0);
SetDIBits(NULL,hBitmap,0,bmInfoHeader->bmiHeader.biHeight,bmPixelData,bmInfoHeader,DIB_RGB_COLORS);

HDC hDC=BeginPaint(hWnd,&ps);
if(hBitmap!=0)
{
HDC hdcMem=CreateCompatibleDC(hDC);
SelectObject(hdcMem,hBitmap);
BitBlt(hDC,0,0,bmInfoHeader->bmiHeader.biWidth,bmInfoHeader->bmiHeader.biHeight,hdcMem,0,0,SRCCOPY);
DeleteDC(hdcMem);
}
//MessageBox(0,"","",0);
EndPaint(hWnd,&ps);
}
}
break;


Any ideas as to where I am going wrong? I have even tried placing UpdateWindow(hWnd) all over the place, but still no good.

Thanks in advance!

Advertisement
What do you do in response to your handler? Do you return 0 (which you should) or pass the message on to DefWindowProc?
How is the repaint triggered? InvalidateRect (which you should) or sending WM_PAINT manually (which you should never do)?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Hi Endurion,

I just read about InvalidateRect() about an hour ago and that seems to be doing the job!

Is there a way to update the area to be refreshed without the flicker? At the moment, I am updating the screen every 1/10th of a second. There is slight flicker, which obviously, I would prefer not to have.

This topic is closed to new replies.

Advertisement