Hi,
ich brauch unbedingt Unicodekompatible Dialogcontrols für Fastreport, also wollte ich einfach die TNT-Koponenten, die ich in Delphi benutze, einbinden. Als einzige Informationquelle hatte ich das Developer Manual von Fastreport. Anhand des Beispiels und des Quelltexts der TfrxComboBoxControl hab ich dann folgenden Code zustande gebracht.
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: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103:
| unit frxTNTComponents;
interface
uses frxClass, frxDsgnIntf, frxRes, TntStdCtrls, TntClasses, Classes;
implementation
type TfrxTntComboBoxControl = class(TfrxDialogControl) private FComboBox: TTntComboBox; FOnChange: TfrxNotifyEvent; function GetItemIndex: Integer; function GetItems: TTntStrings; function GetText: WideString; procedure DoOnChange(Sender: TObject); procedure SetItemIndex(const Value: Integer); procedure SetItems(const Value: TTntStrings); procedure SetText(const Value: WideString); public constructor Create(AOwner: TComponent); override; class function GetDescription: String; override; property ComboBox: TTntComboBox read FComboBox; property ItemIndex: Integer read GetItemIndex write SetItemIndex; published property Color; property Items: TTntStrings read GetItems write SetItems; property Text: WideString read GetText write SetText; property OnChange: TfrxNotifyEvent read FOnChange write FOnChange; property OnClick; property OnDblClick; property OnEnter; property OnExit; property OnKeyDown; property OnKeyPress; property OnKeyUp; end;
constructor TfrxTntComboBoxControl.Create(AOwner: TComponent); begin inherited; FComboBox := TTntComboBox.Create(nil); FComboBox.OnChange := DoOnChange; InitControl(FComboBox);
Width := 145; Height := 21; end;
class function TfrxTntComboBoxControl.GetDescription: String; begin Result := frxResources.Get('TntComboBox'); end;
function TfrxTntComboBoxControl.GetItems: TTntStrings; begin Result := FComboBox.Items; end;
function TfrxTntComboBoxControl.GetItemIndex: Integer; begin Result := FComboBox.ItemIndex; end;
function TfrxTntComboBoxControl.GetText: WideString; begin Result := FComboBox.Text; end;
procedure TfrxTntComboBoxControl.SetItems(const Value: TTntStrings); begin FComboBox.Items := Value; end;
procedure TfrxTntComboBoxControl.SetItemIndex(const Value: Integer); begin FComboBox.ItemIndex := Value; end;
procedure TfrxTntComboBoxControl.SetText(const Value: WideString); begin FComboBox.Text := Value; end;
procedure TfrxTntComboBoxControl.DoOnChange(Sender: TObject); begin if Report <> nil then Report.DoNotifyEvent(Self, FOnChange); end;
initialization frxObjects.RegisterObject1(TfrxTntComboBoxControl, nil, '', 'Other controls');
finalization frxObjects.Unregister(TfrxTntComboBoxControl);
end. |
Jetzt hab ich drei Probleme und finde keinen Ansatz. Erstens bekomme ich einen Fehler wenn ich die Komponente auf einem Dialog platziere, zweitens funktioniert die Eigenschaft "Items" nicht (wenn ich "TStrings" und "String" benutze ist alles in Ordnung) und drittens, wenn ich die Komponente im Script benutze, bekomme ich eine Fehlermeldung, das er die Klasse "TfrxTntComboBoxControl" nicht kennt. Hat vielleicht jemand einen Vorschlag oder eine Lösung zu einem oder vielleicht sogar all meinen Problemen?
Danke im Vorraus
Björn