?
Solved

Quick Report

Posted on 2006-05-31
16
Medium Priority
?
272 Views
Last Modified: 2010-04-05
Hi All

1. I am using a QuickReport for printing purposes afcourse.
When I am doing the command : quickreport.preview it's giving me an error when pages number are more than 3.The error say : cann't creat the file with many unidentified words.
I would like you to know that the compression property is set to true.

2. one more thing how can i fill a combobox with the avialable printers name attached with my PC and if i want to print more than one copy how can i control this.

any clue or solution

thanks regards
0
Comment
Question by:ibrobar
  • 9
  • 4
  • 2
  • +1
16 Comments
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16805083
About your error I have no idea what's causing this. I personally never had this error.

About Listing up the installed windows-printers, this one I did once before but I have to looklup the code fot that.

About number of copies :
     YourReportName.PrinterSettings.Copies := 3;

I'll get back to you for the printerlist-issue.

Best regards,

The Mayor.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16805095
Have you tried to set Compression back to False ?
Do you still get the same error then ?
0
 
LVL 6

Accepted Solution

by:
wimmeyvaert earned 2000 total points
ID: 16805184
To fill the a ComboBox with the Names of the installed Windows-Printers :
  ComboBox1.Items.Assign( Printer.Printers );
  ComboBox1.ItemIndex := Printer.PrinterIndex;

Make sure you have Printers in your uses-Clause.

So the user is now able to choose a printer from the Combobox.
The only thing you need to do, to be ableto print a document to the selected printer is to place following command before the Print-action :
   Printer.PrinterIndex := ComboBox1.ItemIndex;

This is NOT changing anything concerning your default-printer settings in Windows. It just makes sure that your print-action (like RichEdit1.Print) is send to the slected printer.

Is this what you are looking for ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ibrobar
ID: 16805622
yes thanks wimmeyvaert

what about first part of the question?

thanks
0
 

Author Comment

by:ibrobar
ID: 16805631
actullay Comperssion was set to false in the first place so i wasnn't able to print more than one page but when my table exceeded one page it gave me an error . so i make compression value True . now when i need to print more than 3 pages it's giving me error

regards
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 16805897
To get printers into combo box
ComboBox1.Items.Assign(Printer.Printers);

To Print the selected printer
QuickRep1.PrinterSettings.PrinterIndex:=ComboBox1.ItemIndex;

Don't forget to add in the uses clasue   Printers

If the dataset for the quickreport is not set do the following.

You have to seperately set the dataset for the QuickReport
Click/Select on the QuickReport(not on the text/band)
On the properites Set the dataset(query/table) which you are using for that report.
Run the reprot.

sun4sunday
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16805962
Concerning your first problem :
Can you give us the exact errormessage you get ?
Maybe then we can find something on the www.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16806092
I just have created a small project which can show you all installed windows printers in a ListBox. When you select a printer from the list, detailed info is showed in a ReadOnly TMemo. you can also fill a RichEdit with some text and print it to the selected printer.

I placed all the Printer-specific functions in a separate Unit, so you can use it in other applications too.

This is the separate PrinterUnit (Unit_PrinterFunctions.pas) :
unit Unit_PrinterFunctions;


interface

uses
  Windows, SysUtils, Printers, WinSpool;

type
  TPrinterInfo = record
    SeverName           : PChar;
    PrinterName         : PChar;
    ShareName           : PChar;
    PortName            : PChar;
    DriverName          : PChar;
    Comment             : PChar;
    Location            : PChar;
    DeviceMode          : PDeviceModeA;
    SepFile             : PChar;
    PrintProcessor      : PChar;
    DataType            : PChar;
    Parameters          : PChar;
    SecurityDescriptor  : PSecurityDescriptor;
    Attributes          : Cardinal;
    DefaultPriority     : Cardinal;
    StartTime           : Cardinal;
    UntilTime           : Cardinal;
    Status              : Cardinal;
    Jobs                : Cardinal;
    AveragePPM          : Cardinal;
  end;

function GetCurrentPrinterInformation : TPrinterInfo;
function GetCurrentPrinterHandle      : THandle;



implementation

function GetCurrentPrinterInformation: TPrinterInfo;
var
  hPrinter : THandle;
  pInfo: PPrinterInfo2;
  bytesNeeded: DWORD;
begin
  hprinter := GetCurrentPrinterHandle;
  try
    Winspool.GetPrinter( hPrinter, 2, Nil, 0, @bytesNeeded );
    pInfo := AllocMem( bytesNeeded );
    try
      Winspool.GetPrinter( hPrinter, 2, pInfo, bytesNeeded, @bytesNeeded );
      Result.SeverName          := pInfo^.pServerName;
      Result.PrinterName        := pInfo^.pPrinterName;
      Result.ShareName          := pInfo^.pShareName;
      Result.PortName           := pInfo^.pPortName;
      Result.DriverName         := pInfo^.pDriverName;
      Result.Comment            := pInfo^.pComment;
      Result.Location           := pInfo^.pLocation;
      Result.DeviceMode         := pInfo^.pDevMode;
      Result.SepFile            := pInfo^.pSepFile;
      Result.PrintProcessor     := pInfo^.pPrintProcessor;
      Result.DataType           := pInfo^.pDatatype;
      Result.Parameters         := pInfo^.pParameters;
      Result.SecurityDescriptor := pInfo^.pSecurityDescriptor;
      Result.Attributes         := pInfo^.Attributes;
      Result.DefaultPriority    := pInfo^.DefaultPriority;
      Result.StartTime          := pInfo^.StartTime;
      Result.UntilTime          := pInfo^.UntilTime;
      Result.Status             := pInfo^.Status;
      Result.Jobs               := pInfo^.cJobs;
      Result.AveragePPM         := pInfo^.AveragePPM;
    finally
      FreeMem( pInfo );
    end;
  finally
    ClosePrinter( hPrinter );
  end;
end;


function GetCurrentPrinterHandle: THandle;
var
  Device, Driver, Port : array[0..255] of char;
  hDeviceMode: THandle;
begin
  Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
  if not OpenPrinter(@Device, Result, nil) then
    RaiseLastWin32Error;
end;

end.


/***********************************************************/


Here is the complete code in my Form (first DFM, then the PAS-file) :

/*File : Form_Q_21870633.dfm*/

object Form1: TForm1
  Left = 228
  Top = 244
  Width = 533
  Height = 465
  Caption = 'Q_21870633'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 0
    Top = 400
    Width = 177
    Height = 25
    Caption = 'Show Current Printer'
    TabOrder = 0
  end
  object ListBox1: TListBox
    Left = 0
    Top = 8
    Width = 177
    Height = 385
    ItemHeight = 13
    TabOrder = 1
    OnClick = ListBox1Click
  end
  object btnPrint: TButton
    Left = 224
    Top = 104
    Width = 137
    Height = 25
    Caption = 'Print to Selected Printer'
    TabOrder = 2
    OnClick = btnPrintClick
  end
  object RichEdit1: TRichEdit
    Left = 200
    Top = 8
    Width = 313
    Height = 89
    Lines.Strings = (
      'This is a Test-Page.')
    ScrollBars = ssBoth
    TabOrder = 3
    WordWrap = False
  end
  object Memo1: TMemo
    Left = 192
    Top = 144
    Width = 321
    Height = 281
    Lines.Strings = (
      'Memo1')
    ReadOnly = True
    ScrollBars = ssBoth
    TabOrder = 4
    WordWrap = False
  end
end




/*File : Form_Q_21870633.pas*/

unit Form_Q_21870633;

interface

uses
  StdCtrls, ComCtrls, Classes, Controls, Messages, SysUtils, Forms, Dialogs,
  Printers;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    btnPrint: TButton;
    RichEdit1: TRichEdit;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure btnPrintClick(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
  private
    { Private declarations }
    procedure ShowPrnInfo;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit_PrinterFunctions;


{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Items.Assign( Printer.Printers );
  ListBox1.ItemIndex := Printer.PrinterIndex;
  ShowPrnInfo;
end;


procedure TForm1.btnPrintClick(Sender: TObject);
begin
  RichEdit1.Print( 'Printing a Test-Page' );
  MessageDlg('Document is printed on ' + ListBox1.Items[Printer.PrinterIndex] , mtInformation, [mbOK], 0);
end;


procedure TForm1.ListBox1Click(Sender: TObject);
begin
  ShowPrnInfo;
end;


procedure TForm1.ShowPrnInfo;
var
  PrinterInfo: TPrinterInfo;
begin
  Printer.PrinterIndex := ListBox1.ItemIndex;
  PrinterInfo := GetCurrentPrinterInformation;
  memo1.Clear;
  with memo1.Lines do
  begin
    Add('PrinterName : ' + PrinterInfo.PrinterName);
    Add('Comment     : ' + PrinterInfo.Comment);
    Add('ServerName  : ' + PrinterInfo.SeverName);
    Add('ShareName   : ' + PrinterInfo.ShareName);
    Add('PortName    : ' + PrinterInfo.PortName);
    Add('DriverName  : ' + PrinterInfo.DriverName);
    Add('Location    : ' + PrinterInfo.Location);
    Add('Jobs        : ' + IntToStr(PrinterInfo.Jobs));
  end;
end;

end.

/***********************************************************/




Hope to be of some help,

The Mayor.
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 16806253
Which version delphi and quick report are you using?

Did you try like on the previous post?

sun4sunday
0
 

Author Comment

by:ibrobar
ID: 16815497
I am using delphi4
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16815587
THe code I posted is made and tested in Delphi 5 Enterprise Edition.

Maybe try it out if it works in Delphi4 too.

Can you check your version of your QuickReport ?

In My version of Delphi I have Quickreport 3.5.0

Maybe you can check if you can do an upgrade : http://www.qusoft.com/stanlegacy.html

Maybe after that your QuickReport-Problem is solved.
0
 

Author Comment

by:ibrobar
ID: 16815929
Hi

you asked my about the error message i am getting . it's as below :

Project  name.exe raised exception class efcreate error with message 'cannot create file (unknown stuff)' process stopped, use step or run to continue

regards
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16816200
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16816230
Do you run your project on Windows 2000/XP ?
Have you tried to run it on Windows 98 or NT ?
My previous comment was related to this.
0
 
LVL 11

Expert Comment

by:calinutz
ID: 16819884
Have you considered reinstalling the printer's drivers? Also check to see if you have the right to write temporary files on that particular computer. Did you try to test your application on a different computer. I believe it is an OS problem.
I don't have D4  nor the QuickReport for that version, so I cannot reproduce your code on my machine to check for the error.
regards
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16840044
Thanks for the points and the grade.
Did you checked the link in one of my last comments to help you out with your QuickReports-Error ?

Best regards,

The Mayor.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question