Главная страница | назад





Article #16650: printing in color

 Question and Answer Database
FAQ1650D.txt — printing in color
Category :Printing
Platform :All
Product :
Question:
How do I print in color?
Answer:
Generally, no special effort is required to print in color assuming
the printer is a color printer and is set to its native color mode.
Windows will automatically convert color to black and white if the
printer does not support color. If you need to change the color mode
in code, you can access the DevMode structure of the printer driver.
Example:
uses Printers;
procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
with Printer do begin
PrinterIndex := PrinterIndex;
GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then begin
pDMode.dmFields := pDMode.dmFields or dm_Color;
pDMode.dmColor := DMCOLOR_COLOR;
GlobalUnlock(hDMode);
end;
end;
PrinterIndex := PrinterIndex;
BeginDoc;
Canvas.Font.Color := clRed;
Canvas.TextOut(100,100, 'Red As A Rose!');
EndDoc;
end;
end;
4/2/99 11:24:38 AM

Last Modified: 01-SEP-99