日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

DELPHI之备忘(二)

發布時間:2023/12/20 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DELPHI之备忘(二) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. DLL的資源釋放問題

EXITPROC
//*******************
//釋放資源
//*******************
var
??dllExit:?Pointer;
procedure?MyExit;
begin
//資源釋放
?ExitProc?:
=?dllExit;
end;
//******************************
//創建資源
//******************************
begin
??
//?資源創建
??ExitProc?:
=?@MyExit;
??dllExit?:
=?ExitProc;
end.

這種釋放方式不能在動態載入下用,即loadLibrary方式載入,HELP幫助說明如下:

Do not use ExitProc in a dynamically loaded package. This procedure is called when the process halts, not when a package or DLL is unloaded. If you set ExitProc from a package or DLL, it may interfere with the ExitProc of the host executable. Because ExitProc is not compatible with packages, it is recommended that you add code to the finalization section of a unit instead. Inside a DLL, you can use the DLLProc variable instead.

應該用單元里面加initialization和finalization來控制

2. DLL引用傳入的Tquery組件應注意Close和UnPrepare,如下:

其中InitDriver是導出函數

Tquery
function?InitDriver(const??AOwner:TComponent;const?Aquery:Tquery):Byte;stdcall;
begin
??result?:
=?1;
??
if?fileexists('.\SQL\s.SQL')?then?begin
????aquery.Close;
????aquery.SQL.LoadFromFile(
'.\SQL\s.SQL');????
????//aquery.Prepare;不能用
????aquery.ParamByName(
'param').AsInteger?:=?1????;
????aquery.Open;
????
while?not?aquery.Eof?do?begin
??????。。。。?
??????aquery.Next;
????
end;
????aquery.Close;
????aquery.UnPrepare;?
??
end;??
??result?:
=?0;
end;

3. 變體記錄

變體記錄
TMessage?=?packed?record
????Msg:?Cardinal;
????
case?Integer?of
??????
0:?(
????????WParam:?Longint;
????????LParam:?Longint;
????????Result:?Longint);
??????
1:?(
????????WParamLo:?Word;
????????WParamHi:?Word;
????????LParamLo:?Word;
????????LParamHi:?Word;
????????ResultLo:?Word;
????????ResultHi:?Word);
end;

變體記錄使用能夠容納可變部分最大長度的空間來存儲!而CASE不占存儲,只是用來判別可變部分的類型。

CASE TAG:INTEGER OF.....? VAR.TAG :=1;其實是沒有效果的!
4.GRID 右鍵選中 并顯示右鍵菜單

GRID右鍵菜單
procedure?Tform.sgaddressMouseUp(Sender:?TObject;?Button:?TMouseButton;
??Shift:?TShiftState;?X,?Y:?Integer);
var????p:Tpoint;selectrow,selectcol?:integer;
????
//???GrdCrd:???TGridCoord;
????myRect:?TGridRect;
begin

??
if?button?=?mbRight?then?begin
???
//?grdcrd?:=?sgaddress.MouseCoord(x,y);??//?也可以用這個獲取cell
????sgaddress.MouseToCell(x,y,selectcol,selectrow);
????
if?selectcol?<?0?then?exit;
????
if?selectrow?<?0?then?exit;
????myRect.Left?:
=0;//?selectcol;
????myRect.Right?:
=sgaddress.ColCount-1;?//selectcol;
????myRect.Top?:
=?selectrow;
????myRect.Bottom?:
=?selectrow;
????sgaddress.Selection?:
=?myRect;??//修改選中區域

???
//?if?(y?>=?sgaddress.CellRect(grdcrd.X,grdcrd.Y).Top)
???
//??and?(y?<=?(sgaddress.CellRect(grdcrd.X,grdcrd.Y).Top+15))?then
????
if?(y?>=?sgaddress.CellRect(selectcol,selectrow).Top)
?????
and?(y?<=?(sgaddress.CellRect(selectcol,selectrow).Top+15))?then?begin
????GetCursorPos(P);
????PopupMemu.Popup(p.x,p.y);
????
end;
??
end;
end;

5.結構體指針的NEW和DISPONSE方法?
暫缺
6.opendialog會影響系統當前工作目錄,即不能用'.\file'而要用ExtractFileDir(Application.Exename)+'file';

轉載于:https://www.cnblogs.com/enli/archive/2008/12/17/1356744.html

總結

以上是生活随笔為你收集整理的DELPHI之备忘(二)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。