Autor Beitrag
Siluro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Di 31.10.06 17:22 
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.

ausblenden volle Höhe 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:
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

{frxTntCombobox begin}
type
  TfrxTntComboBoxControl = class(TfrxDialogControl)
  private
    FComboBox: TTntComboBox;
    FOnChange: TfrxNotifyEvent;
    function GetItemIndex: Integer;
    function GetItems: TTntStrings; //function GetItems: TStrings;
    function GetText: WideString; //function GetText: String;
    procedure DoOnChange(Sender: TObject);
    procedure SetItemIndex(const Value: Integer);
    procedure SetItems(const Value: TTntStrings);
    procedure SetText(const Value: WideString); //procedure SetText(const Value: String);
  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 Text: String 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;
{frxTntCombobox end}

{frxTntCombobox begin}
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;
{frxTntCombobox 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
Siluro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Do 02.11.06 19:55 
Hi,
also das erste Problem war eigentlich schon gelöst, als ich den Quelltext gepostet hab. Hatte eine falsche Basisklasse benutzt. Zu meinem zweiten Problem: Gibt es vielleicht eine Möglichkeit die Eigenschaft "Items" von der Komponente TTntComboBox abzuleiten, also statt die Eigenschaft und die Methoden dazu selbst zu schreiben, sie einfach zu übernehmen?
Also statt:
ausblenden Delphi-Quelltext
1:
property Items: TTntStrings read GetItems write SetItems;					

einfach:
ausblenden Delphi-Quelltext
1:
property Items; //irgendwie abgeleitet von TTntComboBox.Items					

Björn
Siluro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Fr 03.11.06 17:43 
Hi,
ich hab mir gedacht ich poste mal ein Bild von meinem Items-Problem, vielleicht fällt ja dann jemandem was ein.

Björn
Einloggen, um Attachments anzusehen!