BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Printer Bin selection

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical)
View previous topic :: View next topic  
Author Message
Gunnar Beushausen
Guest





PostPosted: Fri Mar 18, 2005 10:42 am    Post subject: Printer Bin selection Reply with quote



Hi!

Sorry if this isn't the right newsgroup, don't know where to post. I've
got some problems with printer bin selection, seems the Borland
PrinterSetupDialog is buggy. I've stumbled across this code but
unfortunatly i don't know Pascal well enough. Could somebody please help
me in translatig it to c++?

Thanks in advance,

cheers
Gunnar

---
unit ubinmain;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls;

type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
Setup1: TPrinterSetupDialog;
Label1: TLabel;
SpeedButton2: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
UserBinCode : integer;
UserCollateCode : integer;

implementation
uses printers, ubrepunit;
{$R *.DFM}

// this function retrieves the current user selection of
// bin code. It can easily be adapted to include other
// DevMode members, like collate, print quality etc
// Global variables may be set, allowing other parameters to be
// retrieved. See 'UserCollateCode' below.
function GetBinSelection: integer;
var
hDevMode: THandle;
Device,Driver,Port: array [0..1024] of Char;
bin: integer;
DevMode : PDevMode;
begin
Printer.GetPrinter (Device,Driver,Port,hDevMode);
bin := -1;
if hDevMode <> 0 then
begin
DevMode := GlobalLock (hDevMode);
// here we can catch members of DevMode
bin := DevMode^.DMDEFAULTSOURCE;
UserCollateCode := DevMode^.dmCollate;
GlobalUnlock (hDevMode);
end;
result := bin;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
setup1.Execute;
UserBinCode := GetBinSelection;
label1.Caption := 'Bin code : ' + inttostr( UserBinCode)+ '
Collate code ' + inttostr( UserCollateCode);
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
report1.quickrep1.print;
end;

end.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.