Y
Yang.SZ
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码W1:= 30; W2:= 800; W3:= 233; //W3:=100;W4:=60;W5:=195;H1:= 60; H2:= 500; H3:= 40 ; //H3:=40;AQ1.Close;AQ1.SQL.Text:='SELECT FYM, SUM(SSJE)AS JE FROM ZY_SFLSB GROUP BY FYM';AQ1.Open;AQ1.First;FOR i:= 0 To AQ1.RecordCount - 1 Do BEGIN printer.GetPrinter(pDevice, pDriver, pPort, HDMode); IF hDmode = 0 THEN begin printer.PrinterIndex:= printer.PrinterIndex; printer.GetPrinter(pDevice, pDriver, pPort, hDmode); end; AQ2.Close; AQ2.SQL.Text:= 'SELECT * FROM ZY_SFLSB WHERE FYM = '''+ AQ1.FieldValues['FYM'] +''''; AQ2.Open; if AQ2.RecordCount < 5 then H2:= 500 else H2:= 150 + AQ2.RecordCount * (H3); IF Hdmode <> 0 THEN begin pdmode:= globallock(hdmode); IF pdmode <> nil then begin pdmode^.dmFields := pdmode^.dmFields or dm_papersize; pdmode^.dmPaperSize := DMPAPER_USER; pdmode^.dmFields := pdmode^.dmFields or dm_paperwidth; pdmode^.dmPaperWidth := 2410; pdmode^.dmFields := pdmode^.dmFields or dm_paperlength; pdmode^.dmpaperlength:= H2 + 200; globalunlock(hdmode); printer.PrinterIndex:=printer.PrinterIndex; end; end; printer.Orientation:= poPortrait; printer.BeginDoc; printer.Canvas.Font.Name:= '黑体'; printer.Canvas.Font.Size:= 10; printer.Canvas.TextOut(175 , 30 , '住院处医疗费收据'); printer.Canvas.MoveTo(W1 , H1); printer.Canvas.LineTo(W2 , H1); printer.Canvas.MoveTo(W1 , H1); printer.Canvas.LineTo(W1 , H2); printer.Canvas.MoveTo(W2 , H2); printer.Canvas.LineTo(W1 , H2); printer.Canvas.MoveTo(W2 , H2); printer.Canvas.LineTo(W2 , H1); printer.Canvas.MoveTo(W1 , H1 + H3); printer.Canvas.LineTo(W2 , H1 + H3); printer.Canvas.MoveTo(W1 + W3 * 1 , H1); printer.Canvas.LineTo(W1 + W3 * 1 , H1 + H3); printer.Canvas.MoveTo(W1 + W3 * 2 , H1); printer.Canvas.LineTo(W1 + W3 * 2 , H1 + H3); printer.Canvas.MoveTo(W1 , H2 - H3); printer.Canvas.LineTo(W2 , H2 - H3); printer.Canvas.MoveTo(W1 + W3 * 1 , H2); printer.Canvas.LineTo(W1 + W3 * 1 , H2 - H3); printer.Canvas.MoveTo(W1 + W3 * 2 , H2); printer.Canvas.LineTo(W1 + W3 * 2 , H2 - H3); printer.Canvas.Font.Name:='宋体'; printer.Canvas.Font.Size:=10; printer.Canvas.TextOut(W1 + W3 * 0 + 10 , H1 + 10 , '住院编号:' + Self.LE_ZYH.Text); printer.Canvas.TextOut(W1 + W3 * 1 + 10 , H1 + 10 , '患者姓名:' + Self.LE_H.Text); printer.Canvas.TextOut(W1 + W3 * 2 + 10 , H1 + 10 , '处方日期:' + FormatDateTime('YYYY"-"MM"-"DD' , ADO_SJ.FieldByname('SJ').AsDateTime)); printer.Canvas.TextOut(W1 + W3 * 0 + 10 , H2 - H3 + 10 , '住院科室:' + Self.LE_K.Text); printer.Canvas.TextOut(W1 + W3 * 1 + 10 , H2 - H3 + 10 , '处方医生:' + Self.LE_Y.Text); printer.Canvas.TextOut(W1 + W3 * 2 + 10 , H2 - H3 + 10 , '处方金额:' + FormatFloat('0.000' , AQ1.FieldByname('JE').AsFloat)); AQ2.First; For J:= 0 To AQ2.RecordCount - 1 DO begin printer.Canvas.TextOut(W1 + 10 , H1 + H3 + 10 + H1 * J , AQ2.FieldValues['NAME']); printer.Canvas.TextOut(W2 - 350 , H1 + H3 + 10 + H1 * J , AQ2.FieldValues['STAND']); printer.Canvas.TextOut(W2 - 200 , H1 + H3 + 10 + H1 * J , AQ2.FieldValues['UNIT']); printer.Canvas.TextOut(W2 - 150 , H1 + H3 + 10 + H1 * J , FormatFloat('0.00' , AQ2.FieldValues['SALE']) + ' * ' + IntToStr(AQ2.FieldValues['NUM'])); AQ2.Next; end; end;按我的想法打完第一个表时 应该紧接着打第二个表 但实际上 打完第一个表时走完A4纸长度后再打第二个表 研究了好久始终不明原因 请哪位达人看看这是为什么。 有什么好的解决办法没有 操作系统是2000或XP