PDA

View Full Version : یک سوال در مورد Qreport



سیروس مقصودی
چهارشنبه 14 اردیبهشت 1384, 19:20 عصر
با سلام

چگونه میتوان در یک Qreport وقتی گزارش در حالت پیش نمایش (Preview) است کلید چاپگر را در محیط Preview غیر فعال نمود .

باتشکر :گیج:

hr110
پنج شنبه 15 اردیبهشت 1384, 07:30 صبح
شما لزوماً نیازی نیست از پیش نمایش QReport با استفاده از متد Preview استفاده کنید، با کمی تلاش میتوانید به سادگی یک پیش نمایش برای نرم افزارتان ایجاد کنید و کلید های دلخواه را برایش تعریف کنید.

نسیم بهار
پنج شنبه 22 اردیبهشت 1384, 21:19 عصر
چطوری؟

Touska
پنج شنبه 22 اردیبهشت 1384, 21:25 عصر
کاری نداره یک Qrreport رو فرم قرار بدهید و سپس آن را نمایش بدهید. :flower:

vcldeveloper
جمعه 23 اردیبهشت 1384, 03:54 صبح
چطوری؟
باید با استفاده از کامپوننت QRPreview یک فرم پیش نمایش بسازید و سپس یک کلاس از رابط TQRPreviewInterface ایجاد کرده و متدهای Show و ShowModal آن را پیاده سازی کنید.

نحوه انجام کارهای فوق همرا با مثال در راهنمای QuickReport توضیح داده شده است.

سیروس مقصودی
شنبه 04 تیر 1384, 16:27 عصر
با سلام

جناب آقای کشاورز نحوه ایجاد یک کلاس TQRPreviewInterface را نمیدانم چگونه است اگر امکان دارد در این مورد مرا راهنمائی کنید .

با تشکر :flower: :flower: :flower:

vcldeveloper
یک شنبه 05 تیر 1384, 04:44 صبح
نحوه ایجاد یک کلاس TQRPreviewInterface را نمیدانم چگونه است اگر امکان دارد در این مورد مرا راهنمائی کنید

از راهنمای QrReport :


Creating a default custom preview

We mentioned back in the 'Previews and composite reports' section that it was possible to change the default preview mechanism. It is time to look at how this is done.

The first step when creating a custom default preview is to derive a new class from TQRPreviewInterface, like this:


// use QRPrntr to get TQRPreviewInterface

TQRCustomPreviewInterface = class(TQRPreviewInterface)
public
function Show(AQRPrinter : TQRPrinter) : TWinControl; override;
function ShowModal(AQRPrinter : TQRPrinter): TWinControl; override;
end;

Notice that this is an interface class – it serves only to define a couple of functions, and has no data of its own. These two functions are implemented to construct and display your custom preview in non-modal and modal forms.

Lets suppose that the preview form is going to be called TCustPreview. Then the implementation of the TQRCustomPreviewInterface methods might look like this:

function TQRCustomPreviewInterface.Show(
AQRPrinter: TQRPrinter): TWinControl;
var
frm : TCustPreview;
begin
frm := TCustPreview.Create(Application, AQRPrinter);
frm.Show;
Result := frm;
end;

function TQRCustomPreviewInterface.ShowModal(
AQRPrinter: TQRPrinter): TWinControl;
var
frm : TCustPreview;
begin
frm := TCustPreview.Create(Application, AQRPrinter);
frm.ShowModal;
Result := frm;
end;


To register our alternative previewer, we need to call the RegisterPreviewClass function, which is in the QRPrntr unit. The call looks like this:

RegisterPreviewClass(TQRCustomPreviewInterface;

Now we are done with the glue code, and can build the actual previewer form. Mine is minimal; just a single TQRPreview control stuck onto a form:

Simple preview form

When you do real previews in your applications, you will probably want to add buttons to call TQRPreview’s Zoom method and other facilities.
To support the previewing mechanism, I had to write a little more code. Here is the declaration of TCustPreview. Notice I have added a new constructor, which expects to receive the TQRPrinter argument passed in by the Show and ShowModal methods of the interface class. Delphi generates a warning message that the new constructor hides the original. In this case it is deliberate, so I have wrapped the class in


{$WARNINGS ON} ... {$WARNINGS OFF}

//compiler directives to make it shut up.

{$WARNINGS OFF}

TCustPreview = class(TForm)
QRPreview1: TQRPreview;
procedure CustPreviewClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
fQRPrinter : TQRPrinter;
public
{ Public declarations }
constructor Create(AOwner : TComponent;
AQRPrinter : TQRPrinter); virtual;
end;

{$WARNINGS ON}


Finally, here is the implementation of the class. Notice in particular the cleanup code held in the form’s OnClose event. If you don’t call ClosePreview here, you will get a nasty memory leak. (QuickReport 2 users should note that this is a new requirement. You must modify your existing preview forms when porting them to QuickReport 3 and later.)

constructor TCustPreview.Create(AOwner: TComponent;
AQRPrinter: TQRPrinter);
begin
inherited Create(AOwner);
fQRPrinter := AQRPrinter;
QRPreview1.QRPrinter := AQRPrinter;
end;

procedure TCustPreview.CustPreviewClose(Sender: TObject;
var Action: TCloseAction);
begin
fQRPrinter.ClosePreview(Self);
Action := caFree;
end;