• 10
• 13
• 18
• 27
• 9

# Window contents will not update

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

## Recommended Posts

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.

##### Share on other sites
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)?

##### Share on other sites
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.