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

Вниз

как рисовать на 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;
Скачать: CL | DM;

Наверх




Память: 0.5 MB
Время: 0.042 c
3-1099233673
Sam Stone
2004-10-31 17:41
2004.11.28
ADO и MDB


6-1095624621
Klopan
2004-09-20 00:10
2004.11.28
Scan of 21, 80 ports


1-1100151588
Margel
2004-11-11 08:39
2004.11.28
мастера! Нужна ф-я шифрования-дешифрования строки


3-1097219685
Настенька
2004-10-08 11:14
2004.11.28
синхронизация dbgridов


6-1095462159
Comp
2004-09-18 03:02
2004.11.28
Трафик