T
TOTO
Unregistered / Unconfirmed
GUEST, unregistred user!
type
TBlockList = class(TGraphicControl)
private
Data : array[1..20] of Byte;
ItemWidth, ItemHeight : Integer;
fPicture : TPicture;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMMouseMove (var Msg : TWMMouseMove); message WM_MOUSEMOVE;
procedure WMEraseBkgnd (var Msg : TWMEraseBkgnd ); message WM_EraseBkgnd;
procedure DrawBox;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
published
property Canvas;
property Hint;
property ShowHint;
property Pictuer : TPicture read fPicture ;
property Visible;
property OnClick;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
procedure Register;
{$R BlockTitle.Res}
implementation
constructor TBlockList.Create(AOwner: TComponent);
var
I : Integer;
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csFixedWidth , csFixedHeight, csOpaque ];
Parent := TWinControl(AOWner);
fPicture := TPicture.Create;
fPicture.Bitmap.Handle := LoadBitmap(hInstance, 'DEFAULT');
ItemHeight := fPicture.Height div 4;
ItemWidth := fPicture.Width;
ShowHint := TRUE;
for i := 1 to 20 do
Data := 0;
DrawBox;
end;
destructor TBlockList.Destroy;
begin
fPicture.Free;
inherited Destroy;
end;
procedure TBlockList.WMPaint(var Message: TWMPaint);
begin//here
inherited;
end;
procedure TBlockList.DrawBox;
var
i : Integer;
begin
for i:= 1 to 20 do
begin
with Canvas do
begin
case Data of
0 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight * 3, SRCCOPY );
1, 2 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight * 2, SRCCOPY );
3, 4, 5 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight , SRCCOPY );
end;
end;
end;
end;
procedure TBlockList.Clear;
var
I : Integer;
begin
for i := 1 to 20 do
Data := 0;
DrawBox;
end;
procedure TBlockList.Paint;
begin
inherited Paint;
DrawBox;
end;
procedure TBlockList.WMMouseMove(var Msg : TWMMouseMove);
var
x, p : Integer;
begin
x := Msg.XPos;
if (x mod ItemWidth) = 0 then
p := x div ItemWidth
else
P := ( X div ItemWidth ) + 1;
Hint := Format('分数: d% ', [P]);
inherited;
end;
procedure TBlockList.WMEraseBkgnd (var Msg : TWMEraseBkgnd );
begin
Msg.Result := 1;
end;
end.
请教打下:
这是原代码。我为了调试, 在另一个FORM动态创建了一个空间。
并在FORM上显示。我跟踪Create 正常,但却没有显示出来。我有假手
WM_Paint消息中显示调用PAINT并在PAINT中设段点, 可根本没有中断。
增么回师?
另外, 那为打下能把DELPHI创建一个空间的过程叙述以下。
那一个函数进行了那些操作, 分别有什么用。
请打下费心,分数不够我另加!!
TBlockList = class(TGraphicControl)
private
Data : array[1..20] of Byte;
ItemWidth, ItemHeight : Integer;
fPicture : TPicture;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMMouseMove (var Msg : TWMMouseMove); message WM_MOUSEMOVE;
procedure WMEraseBkgnd (var Msg : TWMEraseBkgnd ); message WM_EraseBkgnd;
procedure DrawBox;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
published
property Canvas;
property Hint;
property ShowHint;
property Pictuer : TPicture read fPicture ;
property Visible;
property OnClick;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
procedure Register;
{$R BlockTitle.Res}
implementation
constructor TBlockList.Create(AOwner: TComponent);
var
I : Integer;
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csFixedWidth , csFixedHeight, csOpaque ];
Parent := TWinControl(AOWner);
fPicture := TPicture.Create;
fPicture.Bitmap.Handle := LoadBitmap(hInstance, 'DEFAULT');
ItemHeight := fPicture.Height div 4;
ItemWidth := fPicture.Width;
ShowHint := TRUE;
for i := 1 to 20 do
Data := 0;
DrawBox;
end;
destructor TBlockList.Destroy;
begin
fPicture.Free;
inherited Destroy;
end;
procedure TBlockList.WMPaint(var Message: TWMPaint);
begin//here
inherited;
end;
procedure TBlockList.DrawBox;
var
i : Integer;
begin
for i:= 1 to 20 do
begin
with Canvas do
begin
case Data of
0 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight * 3, SRCCOPY );
1, 2 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight * 2, SRCCOPY );
3, 4, 5 : Bitblt( Handle, ( i - 1 ) * ItemWidth, 0, ItemWidth, ItemHeight,
fPicture.Bitmap.Canvas.Handle, 0, ItemHeight , SRCCOPY );
end;
end;
end;
end;
procedure TBlockList.Clear;
var
I : Integer;
begin
for i := 1 to 20 do
Data := 0;
DrawBox;
end;
procedure TBlockList.Paint;
begin
inherited Paint;
DrawBox;
end;
procedure TBlockList.WMMouseMove(var Msg : TWMMouseMove);
var
x, p : Integer;
begin
x := Msg.XPos;
if (x mod ItemWidth) = 0 then
p := x div ItemWidth
else
P := ( X div ItemWidth ) + 1;
Hint := Format('分数: d% ', [P]);
inherited;
end;
procedure TBlockList.WMEraseBkgnd (var Msg : TWMEraseBkgnd );
begin
Msg.Result := 1;
end;
end.
请教打下:
这是原代码。我为了调试, 在另一个FORM动态创建了一个空间。
并在FORM上显示。我跟踪Create 正常,但却没有显示出来。我有假手
WM_Paint消息中显示调用PAINT并在PAINT中设段点, 可根本没有中断。
增么回师?
另外, 那为打下能把DELPHI创建一个空间的过程叙述以下。
那一个函数进行了那些操作, 分别有什么用。
请打下费心,分数不够我另加!!