In Jamie's patch: FColorDialog: TCommonDialog?
This way you can assign it a TColorDialog, a TColorDialog derivative, or any other custom dialog (derived from TCommonDialog)?
No, it inherits from TColorDialog. TCommonDialog is too general, it does not have the Color property needed by the TColorListbox and the TColorBox. My first thought was of an intermediate, abstract class, something like this:
type
TBasicColordialog = class(TCommonDialog)
protected
function GetColor: TColor; virtual; abstract;
protected SetColor(const AValue: TColor); virtual; abstract;
public
property Color: TColor read GetColor write SetColor;
end;
TColorDialog = class(TBasicColorDialog)
private
FColor: TColor;
...
protected
function GetColor: TColor; override; // Result := FColor;
procedure SetColor(const AValue: TColor); override; // FColor := AValue;
...
published
property Color;
end;
TColorListbox = class(....)
private
FColorDialog: TBasicColorDialog;
...
published
property ColorDialog: TBasicColorDialog read FColorDialog write FColorDialog;
...
end;
That's one possibility. What I don't like is that the color dialog still must derive from TCommonDialog. There is no way to hook in the mbColorLib color dialogs or any other third-party color dialogs without changing their code - the TmbOfficeColorDialog, for example, inherits from TComponent directly. But isn't this what interfaces are good for? Unfortunately I am not very experienced with them. My question to the experienced users here: When the ColorDialog property of, e.g., TColorListbox inherits only from TComponent, is there some trick with interfaces so that it can be used by TColorListbox?