S
SUNSTONE的Delphi笔记
Unregistered / Unconfirmed
GUEST, unregistred user!
很古老话题了,不过今天碰到了,就捡起来研究和总结一下。
delphi可以把各种资源文件整合到exe文件中,这样调入速度快。
一 bmp图像,有两种方法
procedure TfrMain.btnCanvasPic(Sender: TObject);
var bBitmap : TBitmap;
begin
bBitmap := TBitmap.Create;
try
bBitmap.Handle := LoadBitmap(hInstance, 'ATHENA');
Image1.Width := bBitmap.Width;
Image1.Height := bBitmap.Height;
Image1.Canvas.Draw(0,0,bBitmap);
finally
bBitmap.Free;
end;
end;
另一种办法:
procedure TfrMain.btnLoadPicClick(Sender: TObject);
begin
Image1.Picture.Bitmap.
LoadFromResourceName(hInstance,'EARTH');
end;
二 光标文件
procedure TfrMain.btnUseCursorClick(Sender: TObject);
const NewCursor = 1;
begin
Screen.Cursors[NewCursor] :=
LoadCursor(hInstance,'CURHAND');
Image1.Cursor := NewCursor;
end;
三 icon文件
public
nrIco : Integer;
MinIcon : array[0..1] of TIcon;
...
procedure TfrMain.FormCreate(Sender: TObject);
begin
MinIcon[0]:=TIcon.Create;
MinIcon[1]:=TIcon.Create;
MinIcon[0].Handle:=LoadIcon(hInstance,'ICOOK');
MinIcon[1].Handle:=LoadIcon(hInstance,'ICOFOLD');
NrIco:=0;
Timer1.Interval:=200;
end;
...
procedure TfrMain.Timer1Timer(Sender: TObject);
begin
if IsIconic(Application.Handle) then begin
NrIco:=(NrIco+1) mod 2;
Application.Icon:=MinIcon[NrIco];
end;
end;
...
procedure TfrMain.FormDestroy(Sender: TObject);
begin
MinIcon[0].Free;
MinIcon[1].Free;
end;
作者:sunstone 发表于2009/10/22 8:08:00 原文链接
阅读:590 评论:0 查看评论
查看更多...
delphi可以把各种资源文件整合到exe文件中,这样调入速度快。
一 bmp图像,有两种方法
procedure TfrMain.btnCanvasPic(Sender: TObject);
var bBitmap : TBitmap;
begin
bBitmap := TBitmap.Create;
try
bBitmap.Handle := LoadBitmap(hInstance, 'ATHENA');
Image1.Width := bBitmap.Width;
Image1.Height := bBitmap.Height;
Image1.Canvas.Draw(0,0,bBitmap);
finally
bBitmap.Free;
end;
end;
另一种办法:
procedure TfrMain.btnLoadPicClick(Sender: TObject);
begin
Image1.Picture.Bitmap.
LoadFromResourceName(hInstance,'EARTH');
end;
二 光标文件
procedure TfrMain.btnUseCursorClick(Sender: TObject);
const NewCursor = 1;
begin
Screen.Cursors[NewCursor] :=
LoadCursor(hInstance,'CURHAND');
Image1.Cursor := NewCursor;
end;
三 icon文件
public
nrIco : Integer;
MinIcon : array[0..1] of TIcon;
...
procedure TfrMain.FormCreate(Sender: TObject);
begin
MinIcon[0]:=TIcon.Create;
MinIcon[1]:=TIcon.Create;
MinIcon[0].Handle:=LoadIcon(hInstance,'ICOOK');
MinIcon[1].Handle:=LoadIcon(hInstance,'ICOFOLD');
NrIco:=0;
Timer1.Interval:=200;
end;
...
procedure TfrMain.Timer1Timer(Sender: TObject);
begin
if IsIconic(Application.Handle) then begin
NrIco:=(NrIco+1) mod 2;
Application.Icon:=MinIcon[NrIco];
end;
end;
...
procedure TfrMain.FormDestroy(Sender: TObject);
begin
MinIcon[0].Free;
MinIcon[1].Free;
end;
作者:sunstone 发表于2009/10/22 8:08:00 原文链接
阅读:590 评论:0 查看评论
查看更多...