Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 27 Apr 2024, 18:33

All times are UTC




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 07 Dec 2016, 14:31 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

I wonder if it is possible to write in the cells of the days? And to print them (it's very important !)?

I need to write a different data each day.

In advance, thank you


Attachments:
Sans titre.png
Sans titre.png [ 89.34 KiB | Viewed 3406 times ]
Top
 Profile  
 
PostPosted: 07 Dec 2016, 23:15 
Offline
Администратор

Joined: 22 Dec 2011, 20:19
Posts: 335
Hello ISOAR

Yes, you can.

Use TPlannerVertDayslineViewEh.OnDrawCell event like this:

Code:
type
  TDatesColAreaEhCrack = class(TDatesColAreaEh);

procedure TfrFrameOne.PlannerVertDayslineViewEh1DrawCell(
  PlannerView: TCustomPlannerViewEh; ACol, ARow: Integer; ARect: TRect;
  State: TGridDrawState; CellType: TPlannerViewCellTypeEh; ALocalCol,
  ALocalRow: Integer; ADrawCellArgs: TPlannerViewCellDrawArgsEh;
  var Processed: Boolean);
var
  NewRect: TRect;
  s: String;
begin
  if (CellType = pctDateCellEh) then
  begin
    PlannerView.DefaultDrawPlannerViewCell(ACol, ARow, ARect, State, CellType, ALocalCol, ALocalRow, ADrawCellArgs);

    PlannerView.Canvas.Brush.Color := TDatesColAreaEhCrack(PlannerVertDayslineViewEh1.DatesColArea).GetActualColor;
    NewRect := ARect;
    NewRect.Top := NewRect.Top + 20;
    NewRect.Left := NewRect.Left + 4;
    s := 'New Text';
    PlannerView.Canvas.TextRect(NewRect, s, [tfWordBreak]);
    Processed := True;
  end;
end;


Attachments:
sshot-1.png
sshot-1.png [ 14.34 KiB | Viewed 3402 times ]

_________________
Best regards
Admin
Top
 Profile  
 
PostPosted: 08 Dec 2016, 08:36 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Yes, it's works fine ! However, i also need to print them.

Thank you for everything. ;)


Top
 Profile  
 
PostPosted: 13 Dec 2016, 07:53 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

Do you have an idea to help me ?

Thank you guy !


Top
 Profile  
 
PostPosted: 15 Dec 2016, 00:55 
Offline
Администратор

Joined: 22 Dec 2011, 20:19
Posts: 335
Hello ISOAR

Yes, you can print custom text on print.

There are no special event on cell print but,

you can override class TPlannerControlPrintServiceEh

Try modify unit FrameOne from EhLib\Demos\PlannerEh.MainDemo\FrameOne.pas

Code:
uses
  ...PrintPlannersEh,

type
  TfrFrameOne = class(TMyBaseFrame)
...
  public
    MyPlannerControlPrintService: TPlannerControlPrintServiceEh;
.....
  end;

implementation

uses Unit1, Unit_ToolsDataModule;

{$R *.dfm}

type
  TPlannerViewCrack = class(TCustomPlannerViewEh);

  TMyPlannerControlPrintServiceEh = class(TPlannerControlPrintServiceEh)
  protected
    procedure PrintCellData(ACol, ARow: Integer; ARect: TRect); override;
  end;

procedure TMyPlannerControlPrintServiceEh.PrintCellData(ACol, ARow: Integer; ARect: TRect);
var
  CellType: TPlannerViewCellTypeEh;
  ALocalCol, ALocalRow: Integer;
  Grid: TPlannerViewCrack;
  NewRect: TRect;
  s: String;
begin
  inherited PrintCellData(ACol, ARow, ARect);

  Grid := TPlannerViewCrack(PlannerView);
  Grid.GetCellType(ACol, ARow, CellType, ALocalCol, ALocalRow);

  if (PlannerView is TPlannerVertDayslineViewEh) and
     (CellType = pctDateCellEh)
  then
  begin
    NewRect := ARect;
    NewRect.Top := NewRect.Top + Round(20 * ScaleX);
    NewRect.Left := NewRect.Left + Round(4 * ScaleY);
    s := 'New Text';
    Canvas.TextRect(NewRect, s, [tfWordBreak]);
  end;
end;

....

constructor TfrFrameOne.Create(AOwner: TComponent);
begin
....
  MyPlannerControlPrintService := TMyPlannerControlPrintServiceEh.Create(Self);
end;

....
procedure TfrFrameOne.Button1Click(Sender: TObject);
begin
  MyPlannerControlPrintService.Planner := PlannerControlEh1;
  MyPlannerControlPrintService.Preview;
end;

_________________
Best regards
Admin


Top
 Profile  
 
PostPosted: 23 Dec 2016, 16:06 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

it's works but when i close my TForm, i have multiple access violations...

I think there is something wrong with this method

We will see.

Thank you and Happy New Year !!!! :D


Top
 Profile  
 
PostPosted: 23 Dec 2016, 19:59 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

Try to destroy in MyPlannerControlPrintService in OnFormDestroy event handler

Code:
procedure TForm1.FormDestroy(Sender: TObject);
begin
  FreeAndNil(MyPlannerControlPrintService);
end;

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 02 Jan 2017, 16:12 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

Happy new year !


I already used FreeAndNil and same problem.
I tried with PlannerEh.MainDemo (like your example) et I have multiple violations too.



Also I want to change fonts (style and color of PlanItem) when i'm printing but i didn't.
I tried with an overloard PrintCellData and PrintSpanItem procedures (PrintPlannersEh.int) but I did not succeed.
I am sorry for my many questions: your planning is perfect However I have a hard time controlling it.

Thank you,


Top
 Profile  
 
PostPosted: 10 Jan 2017, 12:59 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hi,

I have not any violations now. Maybe, I had probably made a mistake. I'm really sorry.
However, I still do not have the solution to change the color/style (bold, underline, etc.) of the item font when I print.

Have a good day !

ISOAR


Top
 Profile  
 
PostPosted: 23 Jan 2017, 12:31 
Offline

Joined: 26 Jan 2016, 09:46
Posts: 56
Hello,

Can you tell me how I can print the text of the planitem in red?

I thank you in advance.

Greetings,

ISOAR


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 75 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group