0

I want to write method which assing to CPaintDC member a CDC object.

This is sample method:

void CToradexEkg1View::setDCPaint(CDC dcmem)
{
    dcPaint = dcmem;
}

Below is calling this metod:

void CToradexEkg1View::updateBitmap()
{   
    PrintingObject * printingObject = getPrintingSet();
    Bitmap.LoadBitmapW(IDB_BITMAP1);
    GetObject(Bitmap, sizeof(bmpInfo), &bmpInfo);
    cdc.CreateDC(L"DISPLAY", NULL, NULL, NULL);
    dcMemory.CreateCompatibleDC(&cdc);
    dcMem.CreateCompatibleDC(NULL);
    dcMem.SelectObject(&Bitmap);
    hbmpMem.CreateCompatibleBitmap(&cdc, bmpInfo.bmWidth, bmpInfo.bmHeight);
    dcMemory.SelectObject(&hbmpMem);
    dcMemory.BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMem, 0, 0, SRCCOPY);
    m_pSignalDisplay->DrawECG(&dcMemory, printingObject->samples[0], 3, 9000);
    test = cdc.BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
    cdc.BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
    setDCPaint(dcMemory);
}

This is snippet from header file:

BOOL test;
    CBitmap Bitmap2;
    CBitmap hbmpMem;
    CBitmap Bitmap;
    CDC dcPaint;
    BITMAP bmpInfo;
    HBITMAP hbmObraz;
    CDC cdc;
    CDC dcMemory;
    CDC dcMem;

When I am calling the function setDCPaint(dcMemory) I get error:

Error 39 error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject' C:\Program Files (x86)\Windows CE Tools\SDKs\Toradex_CE800\sdk\atlmfc\Include\afxwin.h 1137 1 ToradexEkg1

How I can solve this problem?

  • 1
    Not sure exactly what your usage is but, more often than not, your `dcPaint` member and `dcmem` argument would be *pointers* to `CDC` objects. That would avoid the assignment (i.e. copying) of the DC objects, which smells very odd indeed. – Adrian Mole Feb 09 '21 at 12:22
  • Your title is misleading as you don't have any `CPaintDC` class objects, only a member variable whose name is similar (its name contains the phrases `dc` and `Paint`). – Some programmer dude Feb 09 '21 at 12:22

0 Answers0