Programalama > DELPHI

Etiketler: open, source, flat, image

Ort. 0
Puan ver:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
unit FlatImage;
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;
 
type
  TFlatImage = class(TPAintBox)
  private
    { Private declarations }
    MouseOn : Boolean;
    IsMouseDown : Boolean;
    FPicture: TPicture;
    FStrValue: string;
    procedure PictureChanged(Sender: TObject);
    procedure SetPicture(const Value: TPicture);
  protected
    { Protected declarations }
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
    function DestRect: TRect;
    Procedure Paint;override;
  public
    { Public declarations }
  published
    { Published declarations }
    Constructor Create(AOwner:TComponent);override;
    Destructor Destroy;override;
    property Picture: TPicture read FPicture write SetPicture;
    property StrValue: string read FStrValue write FStrValue;
  end;
 
 
implementation
 
 
{ TFlatImage }
 
procedure TFlatImage.CMMouseEnter(var Message: TMessage);
begin
  MouseOn := True;
  Repaint;
end;
 
procedure TFlatImage.CMMouseLeave(var Message: TMessage);
begin
  MouseOn := False;
  IsMouseDown := False;
  Repaint;
end;
 
constructor TFlatImage.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  MouseOn := False;
  FPicture := TPicture.Create;
  FPicture.OnChange := PictureChanged;
  Height := 105;
  Width := 105;
 
end;
 
 
 
destructor TFlatImage.Destroy;
begin
  FPicture.Free;
  inherited Destroy;
end;
 
 
function TFlatImage.DestRect: TRect;
begin
  Result := Bounds((Width - Picture.Width) div 2, (Height - Picture.Height) div 2,
      Picture.Width, Picture.Height)
end;
 
 
 
procedure TFlatImage.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  Inherited MouseDown(Button,Shift,x,y);
  If Button = mbLeft then
  begin
    IsMouseDown := True;
    Repaint;
  end;
end;
 
procedure TFlatImage.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  Inherited MouseUp(Button,Shift,x,y);
  If Button = mbLeft then
  begin
    IsMouseDown := false;
    Repaint;
  end;
end;
 
procedure TFlatImage.Paint;
var PaintRect : TRect;
begin
  Inherited Paint;
  PaintRect := Rect(0, 0, Width-1, Height-1);
 
  with inherited Canvas do
    StretchDraw(DestRect, Picture.Graphic);
 
  If IsMouseDown then DrawEdge(Canvas.Handle, PaintRect, BDR_SUNKENINNER,BF_RECT)
  else If MouseOn then DrawEdge(Canvas.Handle, PaintRect, BDR_RAISEDOUTER,BF_RECT)
end;
 
procedure TFlatImage.PictureChanged(Sender: TObject);
begin
  RePaint;
end;
 
procedure TFlatImage.SetPicture(const Value: TPicture);
begin
  FPicture.Assign(Value);
end;
 
end.


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2025 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.