CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Miami, Florida
    Posts
    242

    how to create CDC dc; - I am just plain confused

    I took a function from codeguru. I want to call this function shown below in OnInitialUpdate.

    void DrawBitmap( HDC hdc, ....)

    I tried just typing:

    OnInitialUpdate()
    {
    CDC dc;
    DrawBitmap(dc.m_hDC, ....);
    }



    but in the function DrawBitmap(), I get a debug assertion error at the line:

    ASSERT( hdc != NULL );

    I don't understand how to construct or create the variable CDC dc;.

    I have read through MSDN and am still stuck. Please, any response any one can give me to get past this debug assertion error will be greatly appreciated.

    Sincerely,
    Erich J. Ruth


  2. #2
    Join Date
    Sep 1999
    Posts
    3

    Re: how to create CDC dc; - I am just plain confused

    Usually in MFC the default constructor does nothing; so in your code you have a CDC variable that is not initialised.
    Try this code:

    OnInitialUpdate()
    {
    CDC* pDc = GetDC();
    if (pDc != NULL)
    {
    DrawBitmap(pDc->m_hDC, ....);
    ReleaseDC(pDc);
    }
    }



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