Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.05.07;
Скачать: CL | DM;

Вниз

TIcon + TLabel   Найти похожие ветки 

 
forgery ©   (2005-10-29 23:07) [0]

Скрещиваю TCustomLabel и TImage, на пример TLabeledEdit, в результате все нормально, но есть проблемы при Align в состоянии не alNone. В положении alLeft и alTop, проблем нет при изменении размера формы а вот в alClient, alRight, alBottom наблюдается непонятное перемещение компонента по основной форме.
Перемещение делаю перерисовывая привязанный имаг, перекрывая у лабела родительский метод:

 { TCustomImagedLabel }
 TCustomImagedLabel = class(TCustomlabel)
 private
   FLabelImage: TBoundImage;
   FImagePosition: TImagePosition;
   FImageSpacing: Integer;
   procedure SetImagePosition(const Value: TImagePosition);
   procedure SetImageSpacing(const Value: Integer);
 protected
   procedure SetParent(AParent: TWinControl); override;
   procedure Notification(AComponent: TComponent; Operation: TOperation); override;
   procedure CMVisiblechanged(var Message: TMessage);
     message CM_VISIBLECHANGED;
   procedure CMEnabledchanged(var Message: TMessage);
     message CM_ENABLEDCHANGED;
 public
   constructor Create(AOwner: TComponent); override;
   procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
   procedure SetupInternalLabel;
   property LabelImage: TBoundImage read FLabelImage;
   property ImagePosition: TImagePosition read FImagePosition write SetImagePosition;
   property ImageSpacing: Integer read FImageSpacing write SetImageSpacing;
 end;

procedure TCustomImagedLabel.SetBounds(ALeft, ATop, AWidth,
 AHeight: Integer);
var
 sign: Integer;
begin
 if (FImagePosition in [ipTop]) then begin
   if (Align in [alTop]) then begin
     ATop:=ATop+FLabelImage.Height+FImageSpacing;
   end;
   if (Align in [alClient]) then begin
     ATop:=ATop+FLabelImage.Height+FImageSpacing;
     AHeight:=AHeight-FLabelImage.Height-FImageSpacing;
   end;
 end;

 if (FImagePosition in [ipBottom]) then begin
   if (Align in [alBottom]) then begin
     ATop:=ATop-FLabelImage.Height-FImageSpacing;
   end;
   if (Align in [alClient]) then begin
     AWidth:=AWidth-FLabelImage.Width-FImageSpacing;
   end;
 end;

 if (FImagePosition in [ipLeft]) then begin
   if (Align in [alLeft]) then begin
     ALeft:=ALeft+FLabelImage.Width+FImageSpacing;
   end;
   if (Align in [alClient]) then begin
     ALeft:=ALeft+FLabelImage.Width+FImageSpacing;
     AWidth:=AWidth-FLabelImage.Width-FImageSpacing;
   end;
 end;

 if (FImagePosition in [ipRight]) then begin
   if (Align in [alRight]) then begin
     ALeft:=ALeft-FLabelImage.Width-FImageSpacing;
   end;
   if (Align in [alClient]) then begin
     AWidth:=AWidth-FLabelImage.Width-FImageSpacing;
   end;
 end;

 inherited SetBounds(ALeft, ATop, AWidth, AHeight);
 SetImagePosition(FImagePosition);
end;

procedure TCustomImagedLabel.SetImagePosition(const Value: TImagePosition);
var
 P: TPoint;
begin
 if FLabelImage = nil then exit;
 FImagePosition := Value;
 case Value of
   ipTop   : P := Point(Left, Top - FLabelImage.Height - FImageSpacing);
   ipBottom: P := Point(Left, Top + Height + FImageSpacing);
   ipLeft  : P := Point(Left - FLabelImage.Width - FImageSpacing,
                   Top + ((Height - FLabelImage.Height) div 2));
   ipRight : P := Point(Left + Width + FImageSpacing,
                   Top + ((Height - FLabelImage.Height) div 2));
 end;
 FLabelImage.SetBounds(P.x, P.y, FLabelImage.Width, FLabelImage.Height);
end;


 
TStas ©   (2005-10-30 19:19) [1]

Align in [alClient] ? А не наоборот? И компилятор не ругается?


 
forgery ©   (2005-10-31 19:58) [2]

нет, все ок....
но вопрос то не в этом :((



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

Текущий архив: 2006.05.07;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
2-1145269028
Leshas
2006-04-17 14:17
2006.05.07
Математическое приложение - разбор формулы


15-1144853043
kilonet
2006-04-12 18:44
2006.05.07
Книга по клиент - серверным БД.


15-1144736884
Карелин Артем
2006-04-11 10:28
2006.05.07
Пирамида и знак над ней на 1 USD. Из какой части света взято?


15-1144973253
Дмитрий_177
2006-04-14 04:07
2006.05.07
Отключить на ноутбуке энергосберегающий режим


2-1145034615
Express
2006-04-14 21:10
2006.05.07
Сортировка