none
Print grafics/pictures/logos RRS feed

  • Question

  • My program print a report. It uses CDC to set up printer, set font, set colour, set mapping mode and so on. So far the report only include plain text and boxes. Which I manages with CDC->MoveTo, CDC->LineTo and CDC->ExtTextOut. Now I want the report to include logos which comes from e.g a *.jpb or *.tif file. I have tried with the functions LoadIcon and       CDC->DrawIcon but the logo/picture do not get printed on the report.

    The program is a VS 2008 MFC project.

    I would be grateful if someone have a solution to this. Thanks in advance.

    Tuesday, March 30, 2010 7:28 AM

Answers

  • I make a reply to myself incase someone else have the same problem.

    To print a bitmap in my report I used the following code.

    ---------------------------------------------------------

    CDC dcMemory;

    CBitmap MyBitMap ;

    HBITMAP hbm = (HBITMAP)LoadImage(NULL,

    "C:\\BitMap\\Merke.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

    MyBitMap.Attach(hbm);

    dcMemory.CreateCompatibleDC(pDC);

    dcMemory.SelectObject(&MyBitMap);

    pDC->BitBlt(X0,Y0,600,300,&dcMemory,0,0,SRCCOPY);

    dcMemory.DeleteDC();

    MyBitMap.DeleteObject();

    -------------------------------------------------------

    • Marked as answer by SivKM Wednesday, April 7, 2010 6:56 AM
    Wednesday, April 7, 2010 6:56 AM