?
Solved

Urgent!! Printing problem

Posted on 1998-10-07
2
Medium Priority
?
242 Views
Last Modified: 2010-04-01
This is the source code for printing.
I got a problem here.
When I print out, the size of the printed is different in
laser printer and inkjet printer.
In laser printer, the size is smaller than that of inkjet printer.
Could you solve this problem?
I'm using Visual C++ 5.0.
Thank you in advance.


int clientX,clientY,temp;
CRect rectClient;
GetClientRect(rectClient);
clientX = rectClient.right;
clientY = rectClient.bottom;
temp = clientY - 50;
            
clientY = 1400;

// Load Blank Image
HANDLE hBitmap;
CBitmap *lpBitmap;

hBitmap = ::LoadImage(NULL,
      "picture\\blankprint.bmp",
      IMAGE_BITMAP,
      clientX, clientY,
      LR_LOADFROMFILE);

lpBitmap = CBitmap::FromHandle((HBITMAP)hBitmap);

// Make the Image for printing
CClientDC dc1(this);
CDC dc;
CDC dc2;
CPrintDialog dlg(FALSE);
CBitmap   PrnBitmap;
CBrush    p_brush;
dc.CreateCompatibleDC(&dc1);
dc2.CreateCompatibleDC(&dc1);
PrnBitmap.CreateCompatibleBitmap(&dc1, clientX, clientY);
p_brush.CreateStockObject(WHITE_BRUSH);
dc.SelectObject(&p_brush);
dc.SelectObject(&PrnBitmap);
      
dc2.SelectObject(lpBitmap);
dc.BitBlt(0, 0, clientX, clientY, &dc2, 0, 0, SRCCOPY);            

dc.BitBlt(0, 0, clientX, temp, &dc1, 0, 50, SRCCOPY);
            
dc.TextOut(20,clientY-120, "** Provider Information **",26);

dc.TextOut(20,clientY-100, "Doctor ID ", 10);
dc.TextOut(20,clientY-80,  "Name      ", 10);
dc.TextOut(20,clientY-60,  "Address   ", 10);

dc.TextOut(120,clientY-100, doctorID,sizeof(doctorID));
            
wsprintf(DName,"%s, %s\0",dLname, dFname);
            
int length = strlen(DName);

dc.TextOut(120,clientY-80, DName,length);
dc.TextOut(120,clientY-60, Addr1,sizeof(Addr1));
dc.TextOut(120,clientY-40, Addr2,sizeof(Addr2));

if(dlg.DoModal() == IDOK)
{
      DOCINFO di;
      memset (&di, 0, sizeof( DOCINFO) );
      di.cbSize = sizeof(DOCINFO);
      di.lpszDocName = "Printing!";
      
      dc.SetWindowExt(2100,1500);
      dc.SetWindowOrg(0, 0);
      HDC hdc;
      hdc = dlg.GetPrinterDC();    
      ::StartDoc(hdc,&di);
      ::StartPage(hdc);
      ::BitBlt(hdc, 100, 100, 2100, 3000, dc.m_hDC,
                  0, 0, SRCCOPY);
      ::RestoreDC(hdc,-1);
      ::EndPage(hdc);
      ::EndDoc(hdc);
            
}      
delete dlg;

0
Comment
Question by:jaewoo082098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Expert Comment

by:snoegler
ID: 1174640
Your laser printer has a higher resolution than your ink jet printer.
This means, say the ink jet printer's pixel lie within (0,0)-(2100,3000)
But for the laser printer, they lie within, say, (0,0)-(4000,5500).
(I'll elaborate more later, got no time now)
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 1174641
As snoegler says, the DPI (dot per inch) of a laser printer is normally higher than the DPI of an ink jet printer. Use the following code after calling StartPage so that the size is the same as the size on the screen.

        // ...
        ::StartPage(hdc);
       
        HDC hdcDisp = ::CreateIC("DISPLAY", NULL, NULL, NULL);
        ::SetMapMode(hdc, MM_ANISOTROPIC);
        ::SetWindowExt(hdc, ::GetDeviceCaps(hdcDisp, LOGPIXELSX),
                            ::GetDeviceCaps(hdcDisp, LOGPIXELSY));
        ::SetViewportExt(hdc, ::GetDeviceCaps(hdc, LOGPIXELSX),
                              ::GetDeviceCaps(hdc, LOGPIXELSY));
        ::SetWindowOrg(hdc, 0, 0);
        ::SetViewportOrg(hdc, 0, 0);
        ::DeleteDC(hdcDisp);
        // ...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question