Вниз
Скачать: CL | DM;

Control "Has no parent window"   Найти похожие ветки 

← →
Ломов   (2007-01-15 15:07) [0]

Здравствуйте! Пытаюсь объеденить два компонента

Есть главный компонент от TScrollBox

type TMyClass = class(TScrollBox)
 private

 public
  Finder: TFinder ;
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
 end;


и

младший компонент от tpaintbox

type
 TFinder = class(TPaintBox)
 private
   protected
   procedure Paint; override;
   procedure Painter;
 public
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
 published
   end;


в создателе главного я пишу так

constructor TMyClass.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 Parent:=AOwner as TWinControl;
 Finder := TFinder .Create(Self);
 Finder .Parent:=self;
 Finder .Visible := True;
end;


Младшего так

constructor TFinder.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
end;


Это прекрасно работает

procedure TFinder.Paint;
begin
 with inherited Canvas do
 begin
   Pen.Style := psDash;
   Brush.color := clwhite;
   Rectangle(0, 0, Width, Height);
 end;

end;


а вот при вызове этой процедуры возникает сабжевое сообщение

procedure TFinder.Painter;
begin
 with inherited Canvas do
 begin
   Pen.Style := psDash;
   Brush.color := clwhite;
   Rectangle(0, 0, Width, Height);
 end;

end;


знаю, в инициализации второго объекта напортачил, а как, не доходит. Поможите


← →
ors_archangel ©   (2007-01-15 15:37) [1]

Можно банально

procedure TFinder.Painter;
begin
if HasParent then with inherited Canvas do  begin
  Pen.Style := psDash;
  Brush.color := clwhite;
  Rectangle(0, 0, Width, Height);
end;
end;


← →
Ломов   (2007-01-16 05:54) [2]


> ors_archangel ©   (15.01.07 15:37) [1]

Не помогло (
Может есть еще варианты?


← →
ors_archangel ©   (2007-01-16 06:06) [3]


>  Finder .Visible := True;

зачем?
Когда вызывается Painter?


← →
Ломов   (2007-01-16 06:24) [4]


> ors_archangel ©

Спасибо за внимание. Вопрос снят. Это я сам затупил. Пытался вызвать Painter посредством другой процедуры из конструктора TFinder, предварительно не позаботившись о флагах


← →
DimaBr   (2007-01-16 09:25) [5]

Перенесите присвоение парента вложенного компонента в перекрытие метода SetParent


← →
Ega23 ©   (2007-01-16 11:36) [6]


> Перенесите присвоение парента вложенного компонента в перекрытие
> метода SetParent


Точно.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.026 c
15-1168304227
vasIzmax
2007-01-09 03:57
2007.02.04
Везет как утопленнику :(


2-1168994214
M1sT
2007-01-17 03:36
2007.02.04
Поиск по файлам, типа *.xls, *.mdb, *.dbf


15-1168464147
GanibalLector
2007-01-11 00:22
2007.02.04
Порты в дистанц. управлении рабочим столом(mstsc.exe)


2-1168772080
Garacio
2007-01-14 13:54
2007.02.04
в ListView правильно SubItems.add или SubItems.Strings


15-1168860340
XTD
2007-01-15 14:25
2007.02.04
ОФФ:Borland.Delphi.2006.Enterprise




   Наверх