TCheckBox in RichView

General TRichView support forum. Please post your questions here
Post Reply
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

TCheckBox in RichView

Post by BernhardRoos »

I've post my problem here, too (in the private newsgroup I get no answer). But I'm working the whole day on this problem without success. And now I have no ideas anymore.

All what I want is to put Checkboxes with the Editor in a Richview Component which then should print or show in the Preview.

In the editor I only use InserControl.
The TCheckbox I have registered with RegisterControl(TCheckBox).

If I execute the report (the report has a Component tppRichView and the tppRichView has the Checkbox into) then the place is empty where the Checkbox should be print.

If I set the Checkbox with the editor in another color (for example black) then I see in the preview a black rectangle.

I'm using Delphi 2007.

What do I am wrong? Where can I find an example (without ScaleRichview, I must solve it with the normal TRichView Component).

Best wishes
Bernhard
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Not all controls can be printed by default TRichView printing procedure.
If some controls are not printed, use OnPrintComponent event.
For checkboxes:

Code: Select all

procedure TForm1.RVPrint1PrintComponent(Sender: TCustomRVPrint; 
  PrintMe: TControl; var ComponentImage: TBitmap); 
var r: TRect; 
    State: Cardinal; 
begin 
  if PrintMe is TCheckBox then begin 
    ComponentImage := TBitmap.Create; 
    ComponentImage.Width := PrintMe.Width; 
    ComponentImage.Height := PrintMe.Height; 
    ComponentImage.Canvas.Brush.Color := TCheckBox(PrintMe).Color; 
    r := Rect(0,0, PrintMe.Width, PrintMe.Height); 
    ComponentImage.Canvas.FillRect(r); 
    if TCheckBox(PrintMe).Checked then 
      State := DFCS_CHECKED 
    else 
      State := 0; 
    r.Right := r.Bottom; 
    DrawFrameControl(ComponentImage.Canvas.Handle, r, DFC_BUTTON, 
      DFCS_BUTTONCHECK or State); 
    r := Rect(r.Right,0, PrintMe.Width, PrintMe.Height); 
    ComponentImage.Canvas.Font := TCheckBox(PrintMe).Font; 
    DrawText(ComponentImage.Canvas.Handle, PChar(' '+TCheckBox(PrintMe).Caption), -1, r, 
      DT_VCENTER or DT_SINGLELINE); 
  end; 
end;
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

Thanks for the answer. I've tried OnComponentPrint. But I'm not sure if I've assigned it correct because the debugger shows me it never receives this event. Where have I set this event (for which component or classes).
Have I set this event for each Item?
Can I have an example where I can assign this event?
Best wishes
Bernhard
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

In the Preview which is implemented in the ActionTest Demo I can RVPrint1 use to assign the Event OnComponentPrint.
But how can I do this if I use the Print/Preview of the Reportbuilder (using ppRichView.pas). There is a property Helper and Helper has a Property RichView and this has a property RVPrint, but RVPrint is nil. If I set RVPrint to a component TRVPrint and assign the OnComponentPrint, then nothing happens. The debugger shows me that this event never is executed.
How can I use the OnComponentPrint?
Best wishes
Bernhard
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

The debugger shows me further :

in RVItem.pas in TRVControlItemInfo.PrintingToBitmap in line 2266 the condition (RichView is TPrintableRV) is false. So the OnPrintComponent is not executed. What can I do that RichView is from type TPrintableRV?
And where can I assign the OnPrintComponent.
Post Reply