delphi的资源文件
很古老话题了,不过今天碰到了,就捡起来研究和总结一下。
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;
相关文档:
此文适合Delphi新手阅读,特别是连接数据库方面还一懂半懂甚至根本不懂的新手;
--------------------------但总体显得有点乱-------------------------
本文章以Delphi 7和SQL Server 2000为例,控件名均为系统默认,如Unit1,DataModule1,Edit1,ADOCommand1,ADODataS ......
有时需要使用透明控件用于捕获鼠标消息
1.调用Windows2000,xp新的API函数实现这一功能的过程。使用SetLayeredWindowAttributes
2.直接设置控件的alphablend,alphablendvalue,间接调用上述api.
3.使用TStaticText控件
procedure WMCtrlColor(var Message: TWMCtlColor); message WM_CTLCOLOR;
procedure TForm3.WMCtr ......
◇[DELPHI]产生鼠标拖动效果
通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL:
var xpanel,ypanel,xlabel,ylabel:integer;
PANEL的MouseMove事件:xpanel:=x;ypanel:=y;
PANEL的DragOver事件:xpanel:=x;ypanel:=y;
LABEL的MouseMove事件:xlabel:=x;ylabel:=y;
LABEL的EndDrag事件:label ......
一个很简单的问题,但我凭我学习C++/VC一年多,接触Delphi的时间也不短了,但仍然写不出来。
本来以为,不就是将Form1.Show和Form1.Hide么,但却就是达到不到自己想要的结果
这个问题倒不用作深入研究了,到是让我发现,Delphi也不是信手摘来,什么都是那么容易的,以为自己有点儿VC的底子,就小看了Delphi。
最近一段时 ......