Hallo Leute,
ich versuche gerade mein erstes eigenes GraphicControl, also vollständig selbst gezeichnet, hinzubekommen, hänge aber schon am Start fest
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| type TGraphicPanel = class (TGraphicControl) private FText: WideString; protected procedure SetText(AValue: WideString); public procedure Paint; override; constructor Create(AOwner: TComponent); property Text: WideString read FText write SetText; property Color; end;
implementation
procedure TGraphicPanel.Paint; var textwidth: Integer; textheight: Integer; begin Canvas.Brush.Color := Color; Canvas.Rectangle(0, 0, Width, Height); textwidth := Canvas.TextWidth(Text); textheight := Canvas.TextHeight(Text); Canvas.Font := self.Font; Canvas.TextOut(self.Width div 2 - textwidth div 2, Height div 2 - textheight div 2, Text); end; |
Problem? Das Control wird einfach nicht gezeichnet, ich hab im Paint einen Breakpoint und da kommt er nie vorbei!
im Testprojekt (verteilt auf Form.OnCreate und OnShow):
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| HintPnl := TGraphicPanel.Create(self); HintPnl.Parent := self; HintPnl.Top := 50; HintPnl.Left := 50; HintPnl.Text := 'viel'#13#10'viel'#13#10'Text!!!!!!'; HintPnl.Width := 100; HintPnl.Height := 100; HintPnl.Color := clInfoBk; HintPnl.Visible := true; |
Ich sehe das Ding wie gesagt nicht und Paint wird nicht aufgerufen... was mache ich da falsch?
Vielen Dank für eure Hilfe
Jakob