代码如下:
var
   adevice,adriver,aport:array [0..255] of char;
   devicehandle:thandle;
   devmode:pdevicemode;
begin
  if printer.Printers.Count =0 then
    begin
      showmessage('没有检测到打印机,请先添加打印机!');
      exit;
    end;
    //设置打印颜色
  printer.GetPrinter(adevice,adriver,aport,devicehandle);
  if devicehandle=0 then
    begin
      printer.PrinterIndex :=printer.PrinterIndex;
      printer.GetPrinter(adevice,adriver,aport,devicehandle);
    end;
  if devicehandle=0 then
    begin
      raise exception.Create('错误,初始化失败!')
    end
  else
    begin
      devmode:=globallock(devicehandle);
    end;
  with devmode^ do
  begin
    dmfields:=dmfields or dm_printquality;
    if dmcolor=1 then
      begin
        suiradiobutton1.Checked :=true;
      end;
    if dmcolor=2 then
      begin
        suiradiobutton2.Checked :=true;
      end;
    if (dmcolor=3) or (dmcolor=4) then
      begin
        suiradiobutton3.Checked :=true;
      end;
  end;
  if not devicehandle=0 then
    begin
      globalunlock(devicehandle);
    end;
end;
编译通过,但dmcolor值无法获得,请问如何得到默认打印机dmcolor的值以及如何设置该值

解决方案 »

  1.   

    小弟还想问一下,如何设置打印方向,代码如下:
    procedure TMETREREADING.suiButton1Click(Sender: TObject);
    begin
      //设置打印方向,poPortrait为纵向,poLandscape为横向
      printer.PrinterIndex :=suicombobox1.ItemIndex;
      if suiradiobutton4.Checked =true then
        begin
          printer.Orientation := poPortrait;
        end
      else
        begin
          printer.Orientation := poLandscape;
        end;
    end;
    运行后,打印方向并未更改,请问如何写代码