dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Why this code not print anything??

  1. #1
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Why this code not print anything??

    Code:
    void CMAEC_SoftView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
    {
    	// TODO: add customized printing code here
    	CBitmap bmpLogo;
    	bmpLogo.LoadBitmap(IDB_BITMAP_LOGO);
    	
    	CDC dcLogo;
    	dcLogo.CreateCompatibleDC(pDC);
    	dcLogo.SelectObject(&bmpLogo);	
    
    	pDC->BitBlt(0,0,bmpLogo.GetBitmapDimension().cx,bmpLogo.GetBitmapDimension().cy,&dcLogo,0,0,SRCCOPY);	
    	dcLogo.DeleteDC();
    }

  2. #2
    Join Date
    Feb 2000
    Location
    Indore, India
    Posts
    1,046

    Re: Why this code not print anything??

    Hello,

    Get the bitmap dimension using BITMAP object. For that add the following lines in place of your line containing BitBlt call.

    Code:
    	BITMAP BM;
    	bmpLogo.GetBitmap(&BM);
    	pDC->BitBlt(0, 0, BM.bmWidth, BM.bmHeight, &dcLogo,0,0,SRCCOPY);	
    GetBitmapDimension will return the dimension of the bitmap in 0.1 mm units, which may not be the mapping mode of your printer DC.

    Regards,
    Pravin.
    Let me know if I have helped by rating this post

    Recent FAQs

    Drag an image
    Area of a window exposed on desktop
    Display rotated bitmap

  3. #3
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: Why this code not print anything??

    Thanks Pravin, now I can see a black scuare in the print... some any idea why the result is a black scuare?

    Very thanks for your reply.

  4. #4
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    Re: Why this code not print anything??

    Because when you print you must use DIB Bitmaps. (Device Independent Bitmaps)

  5. #5
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: Why this code not print anything??

    Hi Luz.

    And who can I change the resource bitmap to DIB bitmap??

  6. #6
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    Re: Why this code not print anything??

    Have a look at this FAQ. Is not the best example of coding but should work.

    http://www.codeguru.com/forum/showthread.php?t=234177

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)