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}implementationconstructor 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[i] := 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[i] 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[i] := 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}implementationconstructor 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[i] := 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[i] 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[i] := 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创建一个空间的过程叙述以下。
那一个函数进行了那些操作, 分别有什么用。 请大虾费心,分数不够我另加!!
解决方案 »
- 谁推荐个比较好的DELPHI代码格式工具
- 如何用delphi学】 取得双显示卡,并创建表面
- 高分求解~~~~怎么用ADOQUERY 把excel中的数据导如到SQL SERVER 2000中?~~~~~~~~在线等待
- 请问如何执行chm帮助文件!急。。。。。
- 如何将某文件夹下的指定扩展名的所有文件显示出来
- 关于MDI关闭的问题
- 从网上下载的rm格式的文件,播放时画面不连续,不流畅,怎么办?已经试了好几个播放器了?
- Cxgrid如何添加一列虚拟字段用来实现计算后所得出的数据?
- blob字段怎样读写阿,
- 有谁在Delphi中实现过IDocHostUIHandler接口,高分求教
- 哪里有好的免费的计数器或提供免费的统计服务啊?
- 疯了,以下问题(TServerSocket 的线程阻塞方式,有代码)困扰我2天了!!100分,在线等待!!!
t := TBlockList.Create;
t.Parent := Self;//少了这句.
t.Left ;= 0;
t.Top := 0;
另外, 控件中没有定义边界。
我试了可以的!!!!!