Консультация № 21736
03.06.2005, 23:44
0.00 руб.
0 3 3
Здраствуйте Экспреты.
У меня вопрос в чем у меня ошибка. Я создаю класс наследник StringGrid‘a , но почему-то при инсталировании он выдает ошибки даже на подключенные библиотеки.
Помогите пожалуйста.
Код наследника смотрите в приложении
С Уважением
Ujin Antikvar

Приложение:
unit MyGrid;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls;type TMyGrid = class(TStringGrid) private { Private declarations } protected Procedure SetCols(Value: TStrings); Function GetCols : TStrings; Procedure SetRows(Value: TStrings); Function GetRows : TStrings; { Protected declarations } public Procedure ShowGrids; { Public declarations } published // Первая колонка Property TextCols: TStrings read GetCols write SetCols; // Первая строка Property TextRows: TStrings read GetRows write SetRows; { Published declarations } end;procedure Register;implementation{*.tmg}Constructor TMyGrids.Create(AOwner: TComponent);begininherited Create(AOwner); ColCount := 2; DefaultRowHeight := 20;end;Procedure TMyGrids.SetCols(Value: TStrings);begin if Value.Count > RowCount then RowCount := Value.Count; Cols[0].Assign(Value);end;Function TMyGrids.GetCols: TStrings;begin result := Cols[0];end;Procedure TMyGrids.SetRows(Value: TStrings);begin if Value.Count > ColCount then ColCount := Value.Count; Rows[0].Assign(Value);end;Function TMyGrids.GetRows: TStrings;begin result := Rows[0];end;Procedure TMyGrid.ShowGrids;begin if Key = VK_F11 then ShowMessage(‘Name = ‘+Name+#10#13#10+‘RowCount = ‘+IntToStr(RowCount)+ #10#13#10+‘ColCount = ‘+IntToStr(ColCount)+#10#13#10+‘FixedRows = ‘+ IntToStr(FixedRows)+#10#13#10+‘FixedCols = ‘+IntToStr(FixedCols)+#10#13#10 +‘Left = ‘+IntToStr(Left)+#10#13#10+‘Top = ‘+IntToStr(Top));end;procedure Register;begin RegisterComponents(‘Ujin Antikvar component‘, [TMyGrid]);end;end.

Обсуждение

Неизвестный
04.06.2005, 00:24
общий
это ответ
Здравствуйте, Ujin Antikvar!
А как у тебя с английским???
TMyGrid и TMyGrids идут через 1
ЧТО ТАКОЕ ЗА IF KEY= ... ??? Если просто параметр, то ему не место здесь, если
обработчик OnKeyPress - заменяй OnKeyPress у родителя так же как и Constructor
Кстати конструктор криво написан, все методы в Protected - это бред(я бы сказал что лучше в public, но это уже философский вопрос).
Идём дальше:
Property TextCols: TStrings read GetCols write SetCols;
Это наоборот в Protected надо, а уже Read&Write будут делать то что надо!
В общем чистая матчасть,ничего с чем стоило бы обращаться к экспертам, а сначала элементарно почитать что пишет компилятор.

Приложение:
unit MyGrid;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls;type TMyGrids = class(TStringGrid) private { Private declarations } protected Procedure SetCols(Value: TStrings); Function GetCols : TStrings; Procedure SetRows(Value: TStrings); Function GetRows : TStrings; { Protected declarations } public Procedure ShowGrids(key:cardinal);//????? Constructor Create(AOwner: TComponent); override; { Public declarations } published // Первая колонка Property TextCols: TStrings read GetCols write SetCols; // Первая строка Property TextRows: TStrings read GetRows write SetRows; { Published declarations } end;procedure Register;implementation{*.tmg}Constructor TMyGrids.Create(AOwner: TComponent);begininherited Create(AOwner); ColCount := 2; DefaultRowHeight := 20;end;Procedure TMyGrids.SetCols(Value: TStrings);begin if Value.Count > RowCount then RowCount := Value.Count; Cols[0].Assign(Value);end;Function TMyGrids.GetCols: TStrings;begin result := Cols[0];end;Procedure TMyGrids.SetRows(Value: TStrings);begin if Value.Count > ColCount then ColCount := Value.Count; Rows[0].Assign(Value);end;Function TMyGrids.GetRows: TStrings;begin result := Rows[0];end;Procedure TMyGrids.ShowGrids(key:cardinal);begin if Key = VK_F11 then //ЧТО ЭТО???!!! ShowMessage(‘Name = ‘+Name+#10#13#10+‘RowCount = ‘+IntToStr(RowCount)+ #10#13#10+‘ColCount = ‘+IntToStr(ColCount)+#10#13#10+‘FixedRows = ‘+ IntToStr(FixedRows)+#10#13#10+‘FixedCols = ‘+IntToStr(FixedCols)+#10#13#10 +‘Left = ‘+IntToStr(Left)+#10#13#10+‘Top = ‘+IntToStr(Top));end;procedure Register;begin RegisterComponents(‘Ujin Antikvar component‘, [TMyGrids]);end;end.
давно
Мастер-Эксперт
425
4118
04.06.2005, 12:31
общий
это ответ
Здравствуйте, Ujin Antikvar!
А какую ошибку то выдает? Что же Вы не пишете?
Об авторе:
Я только в одном глубоко убеждён - не надо иметь убеждений! :)
Неизвестный
04.06.2005, 13:26
общий
это ответ
Здравствуйте, Ujin Antikvar!
Че то ты тут намудрил...
Что пишет компилятор?
Пробуй так:

Приложение:
unit MyGrid;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls;type TMyGrids = class(TStringGrid) private { Private declarations } protected Procedure SetCols(Value: TStrings); Function GetCols : TStrings; Procedure SetRows(Value: TStrings); Function GetRows : TStrings; { Protected declarations } public Procedure ShowGrids(key:cardinal);//????? Constructor Create(AOwner: TComponent); override; { Public declarations } published // Первая колонка Property TextCols: TStrings read GetCols write SetCols; // Первая строка Property TextRows: TStrings read GetRows write SetRows; { Published declarations } end;procedure Register;implementation{*.tmg}Constructor TMyGrids.Create(AOwner: TComponent);begininherited Create(AOwner); ColCount := 2; DefaultRowHeight := 20;end;Procedure TMyGrids.SetCols(Value: TStrings);begin if Value.Count > RowCount then RowCount := Value.Count; Cols[0].Assign(Value);end;Function TMyGrids.GetCols: TStrings;begin result := Cols[0];end;Procedure TMyGrids.SetRows(Value: TStrings);begin if Value.Count > ColCount then ColCount := Value.Count; Rows[0].Assign(Value);end;Function TMyGrids.GetRows: TStrings;begin result := Rows[0];end;Procedure TMyGrids.ShowGrids(key:cardinal);begin if Key = VK_F11 then //ЧТО ЭТО???!!! ShowMessage(‘Name = ‘+Name+#10#13#10+‘RowCount = ‘+IntToStr(RowCount)+ #10#13#10+‘ColCount = ‘+IntToStr(ColCount)+#10#13#10+‘FixedRows = ‘+ IntToStr(FixedRows)+#10#13#10+‘FixedCols = ‘+IntToStr(FixedCols)+#10#13#10 +‘Left = ‘+IntToStr(Left)+#10#13#10+‘Top = ‘+IntToStr(Top));end;procedure Register;begin RegisterComponents(‘Ujin Antikvar component‘, [TMyGrids]);end;end.
Форма ответа