Autor Beitrag
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 30.03.05 19:44 
Moin :)!

Ich hab extreme Probleme mit einer TFont-Property: sieht der Code so aus

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TDSCalendar.SetFont(AValue: TFont);
begin
  FFont := AValue;
  Repaint;
end;


bekomm ich eine AV; mach ichs so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TDSCalendar.SetFont(AValue: TFont);
begin
  FFont.Assign(AValue);
  Repaint;
end;


klappt zwar eine direkte Zuweisung wie z.B.

ausblenden Delphi-Quelltext
1:
DSCalendar1.Font := MyFont;					


nicht aber Zuweisungen wie

ausblenden Delphi-Quelltext
1:
DSCalendar1.Font.Name := 'Verdana';					


Das bleibt komplett ohne Erfolg. Was mach ich falsch?

AXMD
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 30.03.05 20:09 
TFont hat ein OnChange-Ereignis, dem du einen privaten Event-Handler zuweisen solltest - dann bekommst du auch Änderungen an den Font-Eigenschaften mit..!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
AXMD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 30.03.05 20:23 
user profile iconMotzi hat folgendes geschrieben:
TFont hat ein OnChange-Ereignis, dem du einen privaten Event-Handler zuweisen solltest - dann bekommst du auch Änderungen an den Font-Eigenschaften mit..!


Klingt gut, aber irgendwie ist es das noch nicht ganz... hier der aktuelle Code:

ausblenden Delphi-Quelltext
 
215:
{ ... }
property Font: TFont read GetFont write SetFont;


ausblenden Delphi-Quelltext
 
273:
274:
275:
276:
{ ... }
constructor TDSCalendar.Create(AOwner: TComponent);
{...}
  FFont := TFont.Create;
  FFont.OnChange := OnFontChange;


ausblenden Delphi-Quelltext
 
441:
442:
443:
444:
445:
446:
{ ... }
procedure TDSCalendar.SetFont(AValue: TFont);
begin
  FFont.Assign(AValue);
  SetAutoHeight(FAutoHeight); //Größe anpassen falls notwendig
  Repaint;
end;


ausblenden Delphi-Quelltext
 
634:
635:
636:
637:
{ ... }
procedure TDSCalendar.OnFontChange(Sender: TObject);
begin
  Repaint;
end;


Folgender Code funtkioniert damit nicht (also das Control repaintet nicht):

ausblenden Delphi-Quelltext
1:
2:
  acal.Font.Name := 'Times New Roman';
  acal.Font.Size := 30;


(wobei acal ein zur Laufzeit erzeugtes TDSCalendar-Objekt ist)

AXMD
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 30.03.05 20:34 
Hast du mal im Debugger geprüft, ob OnFontChange denn überhaupt aufgerufen wird..?

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
AXMD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 30.03.05 20:38 
user profile iconMotzi hat folgendes geschrieben:
Hast du mal im Debugger geprüft, ob OnFontChange denn überhaupt aufgerufen wird..?


Mein OnFontChange wird nicht aufgerufen; warum weiß ich nicht :nixweiss:

AXMD