CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    5

    Device Context Problems

    Code Snippet

    if(r->GETvisibility())
    {

    HBITMAP hBmp;
    CBitmap bmp;
    CDC bmpDC;
    CClientDC dc1(this);
    BITMAP bi;

    bmpDC.DeleteDC();
    bmpDC.CreateCompatibleDC(&dc1);

    hBmp = r->REThbitmap();

    bmp.DeleteObject();
    bmp.Detach();
    bmp.Attach(hBmp);

    CBitmap *pOldbmp = bmpDC.SelectObject(&bmp);

    bmp.GetBitmap(&bi);
    dc1.StretchBlt((r->RETminx()-pDoc->minx)/extent,(pDoc->maxy-r->RETmaxy())/extent,(r->RETmaxx()-r->RETminx())/extent,(r->RETmaxy()-r->RETminy())/extent,&bmpDC,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY);

    }
    else
    {
    /*
    bmpDC.DeleteDC();
    bmp.DeleteObject();
    bmp.Detach();*/

    }



    Description : -

    1. In this case when the value of raster1 is not 0, it implies that there exist a BMP image that must be displayed
    2. If r->GETvisibility is true, then we must display the image on the screen
    3. If r->GETvisibility is false, then we must not display the image on the screen

    when the image is loaded for the first time it is displayed properly. WHen we make the image invisible then it hides correctly.
    The problem arises when we make the image visible again, this time the image is not displayed on the screen. I don't want this to happen.

    Pls help

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Device Context Problems

    This seems like a pretty easy bug to find. Have you tried stepping through the code and checking all return codes?
    Gort...Klaatu, Barada Nikto!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured