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

    print screen, urgent PLEASE

    Hi,
    I have a BIG problem with my application and I don't know what to do. Can you PLEASE help me?
    My program displays (CScrollView) one big bitmap (CBitmap) and some lines (LineTo) on it.
    I have to add a print screen option, so I use:

    HDC hDC;
    DOCINFO di;
    CRect myRect;
    CPrintDialog dlgPrint(FALSE);

    GetWindowRect(&myRect);
    if (dlgPrint.DoModal() == IDOK)
    {

    hDC = dlgPrint.GetPrinterDC();
    memset(&di, 0, sizeof( DOCINFO ) );
    di.cbSize = sizeof( DOCINFO );
    di.lpszDocName = "Dyread";
    StartDoc( hDC, &di );
    StartPage( hDC );

    int printer_w = GetDeviceCaps(hDC,VERTRES);
    int printer_h = GetDeviceCaps(hDC,HORZRES);
    //print the bitmap
    StretchBlt(hDC,0, 0, printer_w, printer_h, GetDC()->GetSafeHdc(),
    0, 0, myRect.Width(),myRect.Height(), SRCCOPY);

    CDrawDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    //print the lines
    .....

    EndPage( hDC );
    EndDoc( hDC );
    DeleteDC( hDC );
    }
    The problem is that I use MM_TEXT map mode, so the pixels on my screen and the dots on the printer are different sizes.
    The bitmap looks terrible (StretchBlt)!
    I tried to use MM_LOENGLISH but then the bitmap doesn't appear
    Can you PLEASE help me?

    Thanks
    C.J.


  2. #2
    Join Date
    Jun 1999
    Location
    Canada - Québec
    Posts
    273

    Re: print screen, urgent PLEASE

    are you try with Bitblt()?


  3. #3
    Guest

    Re: print screen, urgent PLEASE

    The reason that the bitmap doesn't appear in MM_LOENGLISH is because in this mapping mode, 0 on the Y axis is at the bottom of the screen/page, so you need to start drawing the bitmap at X = 0 and Y = 0 - Height_Of_Bitmap.


  4. #4
    Join Date
    Jul 1999
    Location
    Uitca, NY
    Posts
    120

    Re: print screen, urgent PLEASE

    I'm about to look at the problem myself. I found a section in Books Online for VC++ 4.0. The path is Win32 SDK:Win32, Overviews. Graphics Device Interface - Printing a Document. The section includes sample code for printing a bitmap (from a file) to scale and text on the same page. The comment about the MM_LOENGLISH mapping mode is accurate. Y coordinates start at 0 at the top of the screen and are negative below that, the opposite sign of MM_TEXT mapping mode. Hope I pointed you in the right direction.


  5. #5
    Guest

    Re: print screen, urgent PLEASE

    Hi,
    I've tried and tried but it doesn't work
    Can someone PLEASE write a small program that prints (to printer) one CBitmap and afew lines on it?

    many thanks,
    C.J.


  6. #6
    Join Date
    Aug 1999
    Posts
    3

    Re: print screen, urgent PLEASE

    As a general rule, I use DrawDibDraw() in vfw.dll. I use it almost exclusively because it handles palette issues without any help from me whatsoever, and does stretching/shrinking better as well. Maybe it will help


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