Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Компоненты";
Текущий архив: 2006.05.07;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.015 c
2-1145514777
dera
2006-04-20 10:32
2006.05.07
Как узнать целое число месяцев между двумя датами?


15-1144644621
TUser
2006-04-10 08:50
2006.05.07
Все будет хорошо ...


2-1145433320
TrainerOfDolphins
2006-04-19 11:55
2006.05.07
Проверить фокус TToolButton


2-1145255059
Kosyak
2006-04-17 10:24
2006.05.07
произвольное изменение числа


1-1143741211
Mortem
2006-03-30 21:53
2006.05.07
Crt под Delphi





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский