Per il PDF .. non in "automatico". (A proposito dell'appetito vien mangiando ;) Stai alzando il tiro :D )
Devi usare una libreria aggiuntiva per scrivere PDF. La griglia da sola non lo fa.
Per la selezione della riga sotto il mouse, devi gestire gli eventi del mouse (onMouseMove ad esempio)
procedure AForm.HandlerGrigliaMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer);
var
row, col: Int32;
begin
Griglia.MouseToCell(x, y, col,row);
Griglia.Row := row;
end;
Ad esempio..
Stilgar
ti ringrazio per i link ma devo partire mooolto piu' dal basso; ho trovato questo
http://wiki.freepascal.org/Using_the_printer, però copiando il codice mi da già
un errore (come da allegati).
//Raise error if Printer.Printing is not Value
procedure TPrinter.CheckPrinting(Value: Boolean);
begin
if Printing<>Value then
begin
if Value then
raise EPrinter.Create('Printer is not printing')
else
raise Eprinter.Create('Printer is printing');
end;
end; [/code ]
[code]
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Printers,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
PrintBtn: TButton;
procedure PrintBtnClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.PrintBtnClick(Sender: TObject);
const
LEFTMARGIN = 100;
HEADLINE = 'I Printed My Very First Text On ';
var
YPos, LineHeight, VerticalMargin: Integer;
SuccessString: String;
begin
with Printer do
try
BeginDoc;
Canvas.Font.Name := 'Courier New';
Canvas.Font.Size := 10;
Canvas.Font.Color := clBlack;
LineHeight := Round(1.2 * Abs(Canvas.TextHeight('I')));
VerticalMargin := 4 * LineHeight;
// There we go
YPos := VerticalMargin;
SuccessString := HEADLINE + DateTimeToStr(Now);
Canvas.TextOut(LEFTMARGIN, YPos, SuccessString);
finally
EndDoc;
end;
end;
end.
Alla riga 298 di Printers è definite la variabile ....
var
Printer: TPrinter = nil;
function TPrinterCanvas.GetRightMargin: Integer;
begin
if (fRightMargin=0) and (fPrinter<>nil) then
begin
with fPrinter.Papersize.PaperRect do
Result := PhysicalRect.Right-WorkRect.Right;
end else
Result := fRightMargin;
end;
finalization
If Assigned(Printer) then
Printer.Free;
end.
Ma non vedo l'inizializzazione della variabile stessa.
Prova con un :
Printer := TPrinter.Create;
Secondo me risolvi.
Stilgar
constructor TPrinter.Create;
begin
if ClassType=TPrinter then
raise Exception.Create('TPrinter is an abstract base class.'
+' Please use a printer implementation like the package printers4lazarus.');
Inherited Create;
fPrinterIndex:=-1; //By default, use the default printer
fCanvas:=nil;
fPaperSize:=nil;
fBins:=nil;
fTitle:='';
end;
No ... non risolvi. Ho appena controllato il costruttore.
Stilgar
Ritorno al problema di partenza, cioè una volta che il mouse fa click su una cella cambiarne il colore, ho provato in vari modi ma niente (mi manca proprio un manuale anche per le cose semplicissime)
procedure TTfcancella.GrigliaClick(Sender: TObject);
begin
Griglia.Canvas.Brush.Color := clYellow;
end;