Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - CXTPReportPaintManager::DrawBitmap
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPReportPaintManager::DrawBitmap

 Post Reply Post Reply
Author
Message
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post Topic: CXTPReportPaintManager::DrawBitmap
    Posted: 23 March 2009 at 4:18am
I use Xtreme ToolkitPro v13.0.0, static.

int CXTPReportPaintManager::DrawBitmap(CDC* pDC, CXTPReportControl* pControl, CRect rcColumn, int iIcon)
{
    ASSERT(pControl);
    if (!pControl)
        return 0;

    POINT ptIcon;

    CXTPImageManagerIcon* pIcon = pControl->GetImageManager()->GetImage(iIcon, 0);

    if (!pIcon)
        return 0;

    CSize szImage(pIcon->GetWidth(), pIcon->GetHeight());
    CSize szColumn(rcColumn.Size());

    if (szImage.cx < szColumn.cx && szImage.cy < szColumn.cy && pDC)
    {
        ptIcon.x = rcColumn.left + 1;
        ptIcon.y = rcColumn.top + (szColumn.cy - szImage.cy) /2;

        if (pDC->IsPrinting())
        {
            CBitmap bmp;
            bmp.CreateCompatibleBitmap(pDC, szImage.cx, szImage.cy);
            CXTPCompatibleDC dcMem(NULL, &bmp);
            dcMem.FillSolidRect(0, 0, szImage.cx, szImage.cy, pDC->GetBkColor());

            pIcon->Draw(&dcMem, CPoint(0, 0), pIcon->GetIcon());
            pDC->BitBlt(ptIcon.x, ptIcon.y, szImage.cx, szImage.cy, &dcMem, 0, 0, SRCCOPY);
        }
 
       else
        {
            pIcon->Draw(pDC, ptIcon, pIcon->GetIcon());
        }
    }

    return 1 + szImage.cx;
}


For what if printing is drawn to another way? Drawn is not transparent :(
What do I lose if you remove this block? Or how to fix transparent?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2009 at 8:22pm

I like your questions. Why don't try yourself and share your experience. It is easy...

 

Btw - does ALL printers able to make nice transparent output? I am not sure...

Back to Top
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 3:02am
I am not a specialist in printing and do not face problems with printing.
I see strange code and I think the developers did not just write it for fun.
I use the printer Samsung SCX-4300, and when I removed this block it prints well without problems.
Where can I read more information on this issue?
Back to Top
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 3:18am

What is the difference for printer between: I put one image to another? Or just bring a ready picture?
The result of the same...

To avoid problems with printing, I must mix the pictures before painting on printing DC?
Back to Top
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 3:26am
Is not only I use program. I should know about the problems of my users, preferably in advance.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 8:31am
Back to Top
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 10:24am
Thank you, Mark!!! I recognize the problem!

Here is a solution for me:
static int stDrawBitmaps( CDC* pDC, CXTPReportControl* pControl, CRect rcColumn, int iIcon1, int iIcon2 )
{
    ASSERT(pControl);
    if (!pControl)
        return 0;

    POINT ptIcon;

    CXTPImageManagerIcon* pIcon1 = pControl->GetImageManager()->GetImage( iIcon1, 0 );
    CXTPImageManagerIcon* pIcon2 = pControl->GetImageManager()->GetImage( iIcon2, 0 );

    if ( !pIcon1 ) return 0;

    CSize szImage( pIcon1->GetWidth(), pIcon1->GetHeight() );
    CSize szColumn( rcColumn.Size() );

    if ( szImage.cx < szColumn.cx && szImage.cy < szColumn.cy && pDC )
    {
        ptIcon.x = rcColumn.left + 1;
        ptIcon.y = rcColumn.top + (szColumn.cy - szImage.cy) /2;

        if (pDC->IsPrinting())
        {
            CBitmap bmp;
            bmp.CreateCompatibleBitmap( pDC, szImage.cx, szImage.cy );
            CXTPCompatibleDC dcMem( NULL, &bmp );
            dcMem.FillSolidRect( 0, 0, szImage.cx, szImage.cy, pDC->GetBkColor() );
            pIcon1->Draw( &dcMem, CPoint( 0, 0 ), pIcon1->GetIcon() );
            if ( pIcon2 != NULL ) pIcon2->Draw( &dcMem, CPoint( 0, 0 ), pIcon2->GetIcon() );
            pDC->BitBlt( ptIcon.x, ptIcon.y, szImage.cx, szImage.cy, &dcMem, 0, 0, SRCCOPY );
        }
        else
        {
            pIcon1->Draw( pDC, ptIcon, pIcon1->GetIcon() );
            if ( pIcon2 != NULL ) pIcon2->Draw( pDC, ptIcon, pIcon2->GetIcon() );
        }
    }

    return 1 + szImage.cx;
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.