Thread: Help with CDC.

  1. #1
    Registered User headexplodes's Avatar
    Join Date
    Aug 2001
    Posts
    26

    Smile Help with CDC.

    I have just signed up for this new board so lets see if can get any replies for this.

    I have the following code in Microsoft Visual C++ 6.0

    CBitmap bmpBlue;
    bmpBlue.LoadBitmap(IDB_BLUE);

    CDC bmpDC;
    bmpDC.CreateCompatibleDC(dc);
    bmpDC.SelectObject(&bmpBlue);

    CDC memDC;
    memDC.CreateCompatibleDC(dc);
    memDC.BitBlt(0,0,400,400,&bmpDC,0,0,SRCCOPY);

    BitBlt(dc->m_hDC, 0, 0, 400, 400, memDC.m_hDC, 0, 0, SRCCOPY);

    and it outputs nothing. I belive this is because the memDC does not have a size. If i just paint the tmpDC like this:

    BitBlt(dc->m_hDC, 0, 0, 400, 400, bmpDC.m_hDC, 0, 0, SRCCOPY);

    it works fine. Do you know i can fix my problem?

    Thanx,
    HeadExplodes .
    /* MSN and E-Mail - head_explodeshotmail.com */
    If Bill Gates got a dollar for every time windows crahsed... oh... he does.
    I always use MSVC++6.0

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You have to select your bitmap into your memDC to 'paint' onto.

  3. #3
    Registered User headexplodes's Avatar
    Join Date
    Aug 2001
    Posts
    26
    So i HAVE to have a window or bitmap accociated with the CDC for it to work?
    /* MSN and E-Mail - head_explodeshotmail.com */
    If Bill Gates got a dollar for every time windows crahsed... oh... he does.
    I always use MSVC++6.0

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Yes, you need to create the memDC from an existing DC and then select a bitmap into the memDC.

    Then when you use GDI functions using the memDC you are drawing on the bitmap you've selected into it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tons of memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 12-05-2005, 10:19 AM
  2. CDC shape Helps
    By cfrost in forum C++ Programming
    Replies: 3
    Last Post: 05-13-2004, 05:49 AM
  3. CDC :: Arc
    By Jamsan in forum Windows Programming
    Replies: 2
    Last Post: 05-13-2003, 01:13 PM
  4. VC++6: Problem : CDC
    By L.O.K. in forum Windows Programming
    Replies: 1
    Last Post: 11-20-2002, 02:15 AM