我做了打印的程序,就是将列表框里的文本打印出来,可是按照一般书上所说的,不管打印多少字,打印完都会把这页纸退出来,这样太浪费纸了,能不能打印多少,就走多少纸,能不能控制走纸

解决方案 »

  1.   

    只能控制针打用 CreateFile("\\LPT1:", ..........);WriteFile("打印文本\r\n");打多少走多少,看我写的程序//打印字符到默认的打印机
    void CPrintDlg::PrintfStrToDefPrinter(CString strPrint)
    {
    HANDLE hPrint = CreateFile(m_steAlertPrinterPort,GENERIC_READ|GENERIC_WRITE,
    0,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL); if( !hPrint)
      return ; //Setup for overlapped I/O
    COMMTIMEOUTS CommTimesOuts; CommTimesOuts.ReadIntervalTimeout = 1000;
    CommTimesOuts.ReadTotalTimeoutMultiplier = 2;
    CommTimesOuts.ReadTotalTimeoutConstant = 1000 ; CommTimesOuts.WriteTotalTimeoutMultiplier = 0 ;
    CommTimesOuts.WriteTotalTimeoutConstant = 500; SetCommTimeouts(hPrint,&CommTimesOuts); DWORD dwWritted = 0; strPrint += "\r\n";
    int nLength = 0 ;
    nLength = strPrint.GetLength(); WriteFile(hPrint,strPrint.GetBuffer(nLength),nLength,&dwWritted,NULL); CloseHandle(hPrint);
    }