Reputation: 830
Rather than use the standard PrintDialog I am building my own dialog.
I want to be able to invoke the Printer driver's own Setup dialog i.e. as if one had clicked on the Properties button from the PrintDialog.
Can you suggest a method of doing this?
Upvotes: 1
Views: 145
Reputation: 108929
I have not used this API before, but it seems to me like you can use the DocumentProperties
function for this.
A minimal example (using the default printer):
var
PrinterName: string;
BufLen: Cardinal;
PrinterHandle: THandle;
begin
GetDefaultPrinter(nil, @BufLen);
SetLength(PrinterName, BufLen);
GetDefaultPrinter(PChar(PrinterName), @BufLen);
SetLength(PrinterName, BufLen - 1);
if not OpenPrinter(PChar(PrinterName), PrinterHandle, nil) then
begin
ShowMessage('Could not open printer.');
Exit;
end;
try
DocumentProperties(Handle, PrinterHandle, PChar(PrinterName), nil, nil, DM_IN_PROMPT)
// possibly do other things that might raise an exception
finally
ClosePrinter(PrinterHandle);
end;
The nil
pointers can be replaced by DEVMODE
structures that contain the initial settings and the settings selected by the user in the GUI, if you also add the corresponding flags. See the documentation for details.
Upvotes: 2