printersetupdialog能设置纸张大小,横向纵向打印.
printersetupdialog并不能改变Quickrep1的设置.
用QuickRep1.PrinterSetup; 

解决方案 »

  1.   

    如果非要用printersetupdialog, 调用如下函数
    不要忘了加分和FAQ.Function MainPrintSet(MainQuickrep:TQuickrep):Boolean;
    Var
        Device, Driver, Port: array[0..255] of char;
        ADevMode: THandle ;
        DevMode: PDeviceMode;
    Begin
      Try
        Result:=True;
        MainQuickrep.Units := Pixels;
        If GetPrintIndex<>Printer.PrinterIndex Then
         DefaultPrinterFlag:=True;
        MainQuickrep.PrinterSettings.PrinterIndex := printer.PrinterIndex;
        MainQuickrep.Page.Orientation := printer.Orientation;
        with Printer do
          GetPrinter(Device, Driver, Port, ADevMode);
        if ADevMode<>0 then
        Begin
          DevMode := GlobalLock(ADevMode);
          Case DevMode^.dmPaperSize of
            DMPAPER_LETTER:  MainQuickrep.Page.PaperSize :=Letter;
            DMPAPER_LETTERSMALL:  MainQuickrep.Page.PaperSize :=LetterSmall;
            DMPAPER_TABLOID: MainQuickrep.Page.PaperSize :=Tabloid;
            DMPAPER_lEDGER: MainQuickrep.Page.PaperSize :=Ledger;
            DMPAPER_lEGAL: MainQuickrep.Page.PaperSize :=Legal;
            DMPAPER_STATEMENT: MainQuickrep.Page.PaperSize :=Statement;
            DMPAPER_EXECUTIVE: MainQuickrep.Page.PaperSize :=Executive;
            DMPAPER_A3:     MainQuickrep.Page.PaperSize :=A3;
            DMPAPER_A4:     MainQuickrep.Page.PaperSize :=A4;
            DMPAPER_A4SMALL: MainQuickrep.Page.PaperSize :=A4Small;
            DMPAPER_A5:     MainQuickrep.Page.PaperSize :=A5;
            DMPAPER_B4:     MainQuickrep.Page.PaperSize :=B4;
            DMPAPER_B5:     MainQuickrep.Page.PaperSize :=B5;
            DMPAPER_FOLIO: MainQuickrep.Page.PaperSize :=Folio;
            DMPAPER_QUARTO: MainQuickrep.Page.PaperSize :=Quarto;
            DMPAPER_10X14: MainQuickrep.Page.PaperSize :=qr10X14;
            DMPAPER_11X17: MainQuickrep.Page.PaperSize :=qr11X17;
            DMPAPER_NOTE: MainQuickrep.Page.PaperSize :=Note;
            DMPAPER_ENV_9: MainQuickrep.Page.PaperSize :=Env9;
            DMPAPER_ENV_10: MainQuickrep.Page.PaperSize :=Env10;
            DMPAPER_ENV_11: MainQuickrep.Page.PaperSize :=Env11;
            DMPAPER_ENV_12: MainQuickrep.Page.PaperSize :=Env12;
            DMPAPER_ENV_14: MainQuickrep.Page.PaperSize :=Env14;
            else
            Begin
              GlobalUnlock(ADevMode);
              Result:=false;
              Exit;
              //MainQuickrep.Page.PaperSize :=Letter;
              //DevMode^.dmFields := DevMode^.dmFields or DM_PaperSize;
              //DevMode^.dmPaperSize := DMPAPER_LETTER;        End;
          End;
          GlobalUnlock(ADevMode);
        End;
       Except
          On E:Exception do
          Begin
            Result:=false;
            Exit;
          end;
       end;
      

  2.   

    请试了一下superljj的文法,但它报错:
    [Error] hmreport.pas(136): Undeclared identifier: 'GetPrintIndex'
    [Error] hmreport.pas(136): Undeclared identifier: 'Printer'
    [Error] hmreport.pas(141): Undeclared identifier: 'GetPrinter'
    [Error] hmreport.pas(146): Undeclared identifier: 'Letter'
    [Error] hmreport.pas(147): Undeclared identifier: 'LetterSmall'
    [Error] hmreport.pas(148): Undeclared identifier: 'Tabloid'
    [Error] hmreport.pas(149): Undeclared identifier: 'Ledger'
    [Error] hmreport.pas(150): Undeclared identifier: 'Legal'
    [Error] hmreport.pas(151): Undeclared identifier: 'Statement'
    [Error] hmreport.pas(152): Undeclared identifier: 'Executive'
    [Error] hmreport.pas(153): Undeclared identifier: 'A3'
    [Error] hmreport.pas(154): Undeclared identifier: 'A4'
    [Error] hmreport.pas(155): Undeclared identifier: 'A4Small'
    [Error] hmreport.pas(156): Undeclared identifier: 'A5'
    [Error] hmreport.pas(157): Undeclared identifier: 'B4'
    [Error] hmreport.pas(158): Undeclared identifier: 'B5'
    [Error] hmreport.pas(159): Undeclared identifier: 'Folio'
    [Error] hmreport.pas(160): Undeclared identifier: 'Quarto'
    [Error] hmreport.pas(161): Undeclared identifier: 'qr10X14'
    [Error] hmreport.pas(162): Undeclared identifier: 'qr11X17'
    [Error] hmreport.pas(163): Undeclared identifier: 'Note'
    [Error] hmreport.pas(164): Undeclared identifier: 'Env9'
    [Error] hmreport.pas(165): Undeclared identifier: 'Env10'
    [Error] hmreport.pas(166): Undeclared identifier: 'Env11'
    [Error] hmreport.pas(167): Undeclared identifier: 'Env12'
    [Error] hmreport.pas(168): Undeclared identifier: 'Env14'
    [Error] hmreport.pas(191): Statement expected but 'PROCEDURE' found
    [Fatal Error] yusuan.dpr(69): Could not compile used unit 'hmreport.pas'
      

  3.   

    Function MainPrintSet(MainQuickrep:TQuickrep):Boolean;
    Var
        Device, Driver, Port: array[0..255] of char;
        ADevMode: THandle ;
        DevMode: PDeviceMode;
    Begin
      Try
        Result:=True;
        MainQuickrep.Units := Pixels;
        MainQuickrep.PrinterSettings.PrinterIndex := printer.PrinterIndex;
        MainQuickrep.Page.Orientation := printer.Orientation;
        with Printer do
          GetPrinter(Device, Driver, Port, ADevMode);
        if ADevMode<>0 then
        Begin
          DevMode := GlobalLock(ADevMode);
          Case DevMode^.dmPaperSize of
            DMPAPER_LETTER:  MainQuickrep.Page.PaperSize :=Letter;
            DMPAPER_LETTERSMALL:  MainQuickrep.Page.PaperSize :=LetterSmall;
            DMPAPER_TABLOID: MainQuickrep.Page.PaperSize :=Tabloid;
            DMPAPER_lEDGER: MainQuickrep.Page.PaperSize :=Ledger;
            DMPAPER_lEGAL: MainQuickrep.Page.PaperSize :=Legal;
            DMPAPER_STATEMENT: MainQuickrep.Page.PaperSize :=Statement;
            DMPAPER_EXECUTIVE: MainQuickrep.Page.PaperSize :=Executive;
            DMPAPER_A3:     MainQuickrep.Page.PaperSize :=A3;
            DMPAPER_A4:     MainQuickrep.Page.PaperSize :=A4;
            DMPAPER_A4SMALL: MainQuickrep.Page.PaperSize :=A4Small;
            DMPAPER_A5:     MainQuickrep.Page.PaperSize :=A5;
            DMPAPER_B4:     MainQuickrep.Page.PaperSize :=B4;
            DMPAPER_B5:     MainQuickrep.Page.PaperSize :=B5;
            DMPAPER_FOLIO: MainQuickrep.Page.PaperSize :=Folio;
            DMPAPER_QUARTO: MainQuickrep.Page.PaperSize :=Quarto;
            DMPAPER_10X14: MainQuickrep.Page.PaperSize :=qr10X14;
            DMPAPER_11X17: MainQuickrep.Page.PaperSize :=qr11X17;
            DMPAPER_NOTE: MainQuickrep.Page.PaperSize :=Note;
            DMPAPER_ENV_9: MainQuickrep.Page.PaperSize :=Env9;
            DMPAPER_ENV_10: MainQuickrep.Page.PaperSize :=Env10;
            DMPAPER_ENV_11: MainQuickrep.Page.PaperSize :=Env11;
            DMPAPER_ENV_12: MainQuickrep.Page.PaperSize :=Env12;
            DMPAPER_ENV_14: MainQuickrep.Page.PaperSize :=Env14;
            else
            Begin
              GlobalUnlock(ADevMode);
              Result:=false;
              Exit;
              //MainQuickrep.Page.PaperSize :=Letter;
              //DevMode^.dmFields := DevMode^.dmFields or DM_PaperSize;
              //DevMode^.dmPaperSize := DMPAPER_LETTER;        End;
          End;
          GlobalUnlock(ADevMode);
        End;
       Except
          On E:Exception do
          Begin
            Result:=false;
            Exit;
          end;
       end;
    end;
      

  4.   

    非常感谢superljj的帮助问题已解决。