Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Fragen zu Assigned und Handle (https://www.delphipraxis.net/77094-fragen-zu-assigned-und-handle.html)

Lich 14. Sep 2006 15:01


Fragen zu Assigned und Handle
 
Hallo,

bin momentan dabei ein schon bestehendes Programm umzuschreiben, nun bin ich auf die Abfrage gestoßen, ob eine bestimmte Assigned ist. Meine Frage ist nun, wie man etwas Assigned bekommt? Und wozu Assigned überhaupt dient.

Dann wird noch der Wert Handle benutzt von dem ich nicht weiß, wie sein Wert zustande kommt, könnt ihr mir da vielleicht helfen?

Tschuldigung wegen diese blöden Fragen, aber ich kann mir da wirklich keinen Reim drauf mach

Gruß

Lich

hoika 14. Sep 2006 15:04

Re: Fragen zu Assigned und Handle
 
Hallo,

Assigned checked normalerweise auf <>NIL,
da NIL intern ein Pointer auf 0 (oder so ähnlich) ist,

könnte das Assigned auf Handle<>0 testen,
Handle=0 ist bei Windows meistens ein Fehler,
also if Assigned(Handle) bedeutet, if Handle is valid


Ein bissel Bsp.-Code würde helfen.


Heiko

Lich 14. Sep 2006 15:43

Re: Fragen zu Assigned und Handle
 
Das ist der Code, der zu der Komponente ColerGrid gehört

Delphi-Quellcode:
unit Clrgrid;

interface
uses winTypes, classes, Graphics, grids;

type
  TColorEvent = procedure (Sender: TObject; ARow, ACol: Longint;
                           AState: TGridDrawState;
                           ABrush: TBrush; AFont: TFont ) of object;

  TColorStringGrid = class(TStringGrid)
  private
    FonGetCellColor: TColorEvent;
  protected
    procedure DrawCell(ACol, ARow: Longint; ARect: TRect;
              AState: TGridDrawState); override;
  Published
    property OnGetCellColor: TColorEvent read FOnGetCellColor
                                         write FOnGetCellColor;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples',[TColorStringGrid]);
end;

procedure TColorStringGrid.DrawCell(ACol, ARow: Longint; ARect: TRect;
          AState: TGridDrawState);
begin
  if Assigned(FOnGetCellColor) then
    FOnGetCellColor(Self, ARow, ACol, AState, Canvas.Brush, Canvas.Font);
  inherited DrawCell(ACol, ARow, ARect, AState);
end;[/quote]

Und hier wird überprüft, ob FOnGetCellColor Assigned ist, bevor die Funktion zum Ausfüllen der Grid gestartet wird:

[quote]if Assigned(FOnGetCellColor) then
    FOnGetCellColor(Self, ARow, ACol, AState, Canvas.Brush, Canvas.Font);
  inherited DrawCell(ACol, ARow, ARect, AState);
Bei mir ist das ganze irgentwie nie Assigned und ich weiß nicht wodran es liegen könnte?

[edit=SirThornberry]Delphi-Tags gesetzt - Mfg, SirThornberry[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz