Hallo,
danke für die Antworten. Ich hab aber wohl mein Anliegen schlecht beschrieben. ExtCreatePen macht schon was es soll, nur ist die Zuweisung Canvas.Pen.Handle deprecated. Soweit ich mich nun eingelesen habe ersetzt man pen.handle mit canvas.Pen.Reference. Das geht aber wohl nur zum Lesen? Eine Ausgabe habe ich jedenfalls nicht hinbekommen. Soll ich oder muss ich die Warnung also ignorieren???
Viele Grüße
Bernd
property Handle: HPEN; [rw] deprecated ; The Operating System Handle for the current Pen
property Reference: TWSPenReference; [r] A Reference made to this Pen
aus der unit WSReferences:
Code: Alles auswählen
// All properties with _ are temporary and for lcl use only.
// They can be removed anytime, without notice
//
// (don't complain that I didn't warn you)
TWSPenReference = object(TWSGDIObjReference)
property _lclHandle: TLCLHandle write FRef.Handle;
property Handle: TLCLHandle read FRef.Handle;
end;
Mein Quelltext:
Code: Alles auswählen
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
LCLType, LCLIntf;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormPaint(Sender: TObject);
begin
canvas.Line(0,50,Width,50);
end;
procedure TForm1.Button1Click(Sender: TObject);
const
//Dashes: array[0..3] of DWord = (10, 10, 10, 10); // gestrichelt
//Dashes: array[0..3] of DWord = (10, 10, 3, 10); // strichpunkt
Dashes : array[0..5] of DWord = (10,5,3,5,3,5); // strichpunktpunkt
PenStyle : DWord = PS_GEOMETRIC or PS_USERSTYLE or PS_ENDCAP_FLAT;
var
lb: TLogBrush;
PenWidth : DWord;
NewPen : HPen;
begin
lb.lbColor := ColorToRGB(clblue);
lb.lbHatch := 0;
lb.lbStyle := BS_SOLID;
PenWidth := Canvas.Pen.Width;
NewPen := ExtCreatePen(PenStyle, PenWidth, lb, Length(Dashes), @Dashes);
canvas.Pen.Handle:=NewPen;
Invalidate;
end;
end.
Hier die Meldung:

- Bildschirmfoto.png (22.46 KiB) 4030 mal betrachtet