Главная страница
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.076 c
11-1125762294
Wiz@rd
2005-09-03 19:44
2006.05.07
Transparent


15-1145248069
~ dancer ~
2006-04-17 08:27
2006.05.07
PhotoShop глубина цвета


2-1145442756
@gent
2006-04-19 14:32
2006.05.07
Как мне выводить в Memo не только ответ, но и решение


15-1144937217
oldman
2006-04-13 18:06
2006.05.07
Навеяно веткой про американский "Солярис"


2-1145280366
nyron
2006-04-17 17:26
2006.05.07
печатная форма