Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Window contents will not update

This topic is 2661 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 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!

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
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.

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!