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

Вниз

как рисовать на TPanel   Найти похожие ветки 

 
sLa\/a   (2004-11-13 19:01) [0]

как на TPanel загрузить bmp?


 
DrPass ©   (2004-11-13 19:09) [1]

Проблематично


 
sLa\/a   (2004-11-13 19:18) [2]

а поточнее?


 
Rusty   (2004-11-13 19:19) [3]

Попробуй использовать TImage...


 
Mihey_temporary ©   (2004-11-13 22:23) [4]

Около type пишешь:


Type
 THackPanel = class(TPanel)
 end;


Когда надо загрузить битмап, рисуй его на панели:


With THackPanel(MyPanel).Canvas do
begin
 Draw(x, y, MyBitmap);
end;


 
tormoz   (2004-11-14 01:22) [5]

положи на TPanel TPaintBox, на ней и рисуй


 
KilkennyCat ©   (2004-11-14 01:24) [6]


> tormoz   (14.11.04 01:22) [5]


PaintBox - он, а не она :)


 
DrPass ©   (2004-11-14 02:21) [7]

РисовальнаяКоробка - все-таки она :)))


 
KilkennyCat ©   (2004-11-14 02:27) [8]

блин... а я как "ящик" перевел :)


 
debuger ©   (2004-11-14 15:41) [9]

Можно на ТПанел ложить ТИмаге. Он как бы прозрачный, и посему, что на нем, то и под ним:)


 
Defunct ©   (2004-11-14 19:22) [10]

Давно написал, выложу и здесь, очень полезный компонент (панель с Glyph"ом double buffered):

unit SkinnedPanel;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 ExtCtrls;

type
 TSkinnedPanel = class(TPanel)
 private
   FPicture     : TPicture;
   FTransparent : Boolean;
   FStretch     : Boolean;
   FCenter      : Boolean;
   FDrawing     : Boolean;
   FOnProgress: TProgressEvent;
   FIncrementalDisplay: Boolean;

   Procedure PictureChanged(Sender : TObject);
   Procedure SetPicture(Value: TPicture);
   procedure SetCenter(Value: Boolean);
   procedure SetStretch(Value: Boolean);
   procedure SetTransparent(Value: Boolean);
 protected
   { Protected declarations }
   function DoPaletteChange: Boolean;
   function DestRect: TRect;
   procedure Paint; override;
   procedure Progress(Sender: TObject; Stage: TProgressStage;
     PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string); dynamic;
 public
   { Public declarations }
   Constructor Create(AOwner:TComponent);Override;
   Destructor Destroy;Override;
 published
   property Picture: TPicture read FPicture write SetPicture;
   property Stretch: Boolean read FStretch write SetStretch default False;
   property Transparent: Boolean read FTransparent write SetTransparent default False;
   property Center: Boolean read FCenter write SetCenter default False;
 end;

procedure Register;

implementation

Constructor TSkinnedPanel.Create;
Begin
 Inherited;
 FPicture := TPicture.Create;
 FPicture.OnChange := PictureChanged;
 FPicture.OnProgress := Progress;
End;

Procedure TSkinnedPanel.PictureChanged(Sender: TObject);
Var G: TGraphic;
Begin
 If AutoSize and (Picture.Width > 0) and (Picture.Height > 0) then
    SetBounds(Left, Top, Picture.Width, Picture.Height);
 G := Picture.Graphic;
 if G <> nil then
 begin
   If not ((G is TMetaFile) or (G is TIcon)) then
      G.Transparent := FTransparent;
   If (not G.Transparent) and (Stretch or (G.Width >= Width)
      and (G.Height >= Height)) then
      ControlStyle := ControlStyle + [csOpaque]
   Else
     ControlStyle := ControlStyle - [csOpaque];
   if DoPaletteChange and FDrawing then Update;
 End Else ControlStyle := ControlStyle - [csOpaque];
 If not FDrawing then Invalidate;
End;

Procedure TSkinnedPanel.SetPicture(Value: TPicture);
Begin
 FPicture.Assign(Value);
End;

Procedure TSkinnedPanel.SetCenter(Value: Boolean);
Begin
 If FCenter <> Value then
 Begin
   FCenter := Value;
   PictureChanged(Self);
 End;
End;

Procedure TSkinnedPanel.SetStretch(Value: Boolean);
Begin
 If Value <> FStretch then
 Begin
   FStretch := Value;
   PictureChanged(Self);
 End;
End;

procedure TSkinnedPanel.SetTransparent(Value: Boolean);
begin
 If Value <> FTransparent then
 Begin
   FTransparent := Value;
   PictureChanged(Self);
 End;
End;

function TSkinnedPanel.DoPaletteChange: Boolean;
var
 ParentForm: TCustomForm;
 Tmp: TGraphic;
begin
 Result := False;
 Tmp := Picture.Graphic;
 if Visible and (not (csLoading in ComponentState)) and (Tmp <> nil) and
   (Tmp.PaletteModified) then
 begin
   if (Tmp.Palette = 0) then
     Tmp.PaletteModified := False
   else
   begin
     ParentForm := GetParentForm(Self);
     if Assigned(ParentForm) and ParentForm.Active and Parentform.HandleAllocated then
     begin
       if FDrawing then
         ParentForm.Perform(wm_QueryNewPalette, 0, 0)
       else
         PostMessage(ParentForm.Handle, wm_QueryNewPalette, 0, 0);
       Result := True;
       Tmp.PaletteModified := False;
     end;
   end;
 end;
end;

function TSkinnedPanel.DestRect: TRect;
begin
 if Stretch then
   Result := ClientRect
 else if Center then
   Result := Bounds((Width - Picture.Width) div 2, (Height - Picture.Height) div 2,
     Picture.Width, Picture.Height)
 else
   Result := Rect(0, 0, Picture.Width, Picture.Height);
end;

procedure TSkinnedPanel.Paint;
var
 Save: Boolean;
begin
 if csDesigning in ComponentState then
   with inherited Canvas do
   begin
     Pen.Color := Color;
     Brush.Color := Color;
     Rectangle(0, 0, Width, Height);
   end;
 Save := FDrawing;
 FDrawing := True;
 try
   with inherited Canvas do
     StretchDraw(DestRect, Picture.Graphic);
 finally
   FDrawing := Save;
 end;
end;

procedure TSkinnedPanel.Progress(Sender: TObject; Stage: TProgressStage;
 PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string);
begin
 if FIncrementalDisplay and RedrawNow then
 begin
   if DoPaletteChange then Update
   else Paint;
 end;
 if Assigned(FOnProgress) then FOnProgress(Sender, Stage, PercentDone, RedrawNow, R, Msg);
end;

Destructor TSkinnedPanel.Destroy;
Begin
 Try
   FPicture.Destroy
 Finally
   Inherited;
 End;
End;

procedure Register;
begin
 RegisterComponents("Standard", [TSkinnedPanel]);
end;

end.



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

Форум: "Основная";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.48 MB
Время: 0.044 c
3-1099400743
Nexel
2004-11-02 16:05
2004.11.28
Delphi+Bde+Paradox=Index out of date


14-1100208303
Soft
2004-11-12 00:25
2004.11.28
Ваши мнения о П-296?


1-1100114788
Cardinal
2004-11-10 22:26
2004.11.28
Работа с потоками. Помогите!


6-1095751092
Петр
2004-09-21 11:18
2004.11.28
сеть на Delphi


1-1100505669
olookin
2004-11-15 11:01
2004.11.28
Breakpoint не работает.





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский