Главная страница
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.042 c
15-1144835643
Гость101
2006-04-12 13:54
2006.05.07
Родительный падеж


3-1142091496
Sollo
2006-03-11 18:38
2006.05.07
dbExpress сумма вычисляемых полей


3-1142324067
Ega23
2006-03-14 11:14
2006.05.07
Утилита isql - какие ограничения?


15-1145002581
data
2006-04-14 12:16
2006.05.07
Ежегодное приглашение))


2-1145261109
d_oleg
2006-04-17 12:05
2006.05.07
функции в dll