Simple Question
-
Hi, I am trying put one rectangle in MemDC and bring to screen. Here is the code: CDC MemDC; CClientDC mydc(this); MemDC.CreateCompatibleDC(&mydc); MemDC.Rectagble(&myrect); MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before MemDC.FillRect(&myrect,&mybrush); mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); But I am not finding any output. Help me. Thanks Satya
-
Hi, I am trying put one rectangle in MemDC and bring to screen. Here is the code: CDC MemDC; CClientDC mydc(this); MemDC.CreateCompatibleDC(&mydc); MemDC.Rectagble(&myrect); MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before MemDC.FillRect(&myrect,&mybrush); mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); But I am not finding any output. Help me. Thanks Satya
-
This can't work...you have to construct a compatible bitmap and select it into the memory DC. At the moment, you are simply drawing on "nothing"...and "nothing" is what you are bitblitting. greets, Jason
-
Hi, Where I have to include that Compatible Bitmap?? That means I have to draw the things on the bitmap and move this to memory and bitblt to screen?? Can U please give some explanation, Regards Satya
>CDC MemDC; >CClientDC mydc(this); CBitmap bmMem; >MemDC.CreateCompatibleDC(&mydc); if (bmMem.CreateCompatibleBitmap(&mydc, nWidth, nHeight)) { CBitmap* pOldBM = MemDC.SelectObject(&bmMem); >MemDC.Rectagble(&myrect); >MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before >MemDC.FillRect(&myrect,&mybrush); >mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBM); }
-
>CDC MemDC; >CClientDC mydc(this); CBitmap bmMem; >MemDC.CreateCompatibleDC(&mydc); if (bmMem.CreateCompatibleBitmap(&mydc, nWidth, nHeight)) { CBitmap* pOldBM = MemDC.SelectObject(&bmMem); >MemDC.Rectagble(&myrect); >MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before >MemDC.FillRect(&myrect,&mybrush); >mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBM); }
-
Hi, I am trying put one rectangle in MemDC and bring to screen. Here is the code: CDC MemDC; CClientDC mydc(this); MemDC.CreateCompatibleDC(&mydc); MemDC.Rectagble(&myrect); MemDC.SelectObject(&mybrush); /////myrect and mybrush I created before MemDC.FillRect(&myrect,&mybrush); mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); But I am not finding any output. Help me. Thanks Satya
//Looks like you want to do flicker free drawing //Which is the only reason for doing this CDC MemDC; CBitmap bmp; CClientDC mydc(this); MemDC.CreateCompatibleDC(&mydc); bmp.CreateCompatibleBitmap(&mydc,1024,768); CBitmap* pOldBmp = MemDC.SelectObject(&bmp); // Draw rectangle CBrush* pOldBrush = MemDC.SelectObject(&mybrush); MemDC.Rectangle(myrect); MemDC.SelectObject(&pOldBrush); //TODO: Draw other things //Blit to client DC mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); //Clean up MemDC.SelectObject(&pOldBmp); MemDC.DeleteDC(); Doing all of the above when you receive a WM_PAINT message is the slow way, but it works. Find the article "Do a flicker-free drawing using MFC methods" here at codeproject. I have not read it but it should provide you with your answers. Trust in the code Luke. Yea right!
-
//Looks like you want to do flicker free drawing //Which is the only reason for doing this CDC MemDC; CBitmap bmp; CClientDC mydc(this); MemDC.CreateCompatibleDC(&mydc); bmp.CreateCompatibleBitmap(&mydc,1024,768); CBitmap* pOldBmp = MemDC.SelectObject(&bmp); // Draw rectangle CBrush* pOldBrush = MemDC.SelectObject(&mybrush); MemDC.Rectangle(myrect); MemDC.SelectObject(&pOldBrush); //TODO: Draw other things //Blit to client DC mydc.BitBlt(0,0,1024,768,&MemDC,0,0,SRCCOPY); //Clean up MemDC.SelectObject(&pOldBmp); MemDC.DeleteDC(); Doing all of the above when you receive a WM_PAINT message is the slow way, but it works. Find the article "Do a flicker-free drawing using MFC methods" here at codeproject. I have not read it but it should provide you with your answers. Trust in the code Luke. Yea right!