我想在ActiveX中修改本地打印机的属性,如纸张类型、纸张方向、页宽、页高等属性,请问该如何写?我不需要开打印属性窗口设置属性,而是直接将它默认就可以了。
谢谢,急盼!

解决方案 »

  1.   

    直接修改注册表
    //设定打印的方向为纵向或横向
    procedure TprintAX.setportrait(portrait: WordBool);
    begin
        if(portrait) then
        //横向
            //Printer.Orientation := poLandscape
            Printer.Orientation := poLandscape
        else
        //纵向
            Printer.Orientation := poPortrait;
    end;//设定页眉
    procedure TprintAX.setheader(const header: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('header', header);
            end;
            closekey;
            free;
        end;
    end;//设定页脚
    procedure TprintAX.setfooter(const footer: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('footer', footer);
            end;
            closekey;
            free;
        end;
    end;//设定左边距
    procedure TprintAX.setleft(const left: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('margin_left', left);
            end;
            closekey;
            free;
        end;
    end;//设定右边距
    procedure TprintAX.setright(const right: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('margin_right', right);
            end;
            closekey;
            free;
        end;
    end;//设定顶边距
    procedure TprintAX.settop(const top: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('margin_top', top);
            end;
            closekey;
            free;
        end;
    end;//设定底边距
    procedure TprintAX.setbottom(const bottom: WideString);
    var
        registertemp : TRegistry;
    begin
        registertemp := tregistry.create;
        with registertemp do
        begin
            rootkey:=HKEY_CURRENT_USER;
            if openkey('\Software\Microsoft\Internet Explorer\PageSetup', true) then
            begin
                writestring('margin_bottom', bottom);
            end;
            closekey;
            free;
        end;
    end;