delphi
Delphi遍歷文件夾及子文件夾
摘要: 字符截取函數(shù)LeftStr, MidStr, RightStr
這幾個(gè)函數(shù)都包含在StrUtils中,所以需要uses StrUtils;
假設(shè)字符串是 Dstr := ’Delphi is the BEST’, 那么
LeftStr(Dstr, 5) := ’Delph’
MidStr(Dstr, 6, 7) := ’i is th’
RightStr(Dstr, 6) := ’e BEST’
~~~~~~~~~~~~~~~~~~~~~~~~~
function RightStr
(Const Str: String; Size: Word): String;
begin
if Size > Length(Str) then Size := Length(Str) ;
RightStr := Copy(Str, Length(Str)-Size+1, Size)
end;
function MidStr
(Const Str: String
閱讀全文
posted @
2010-05-19 11:48 Ke 閱讀(3544) |
評論 (0) 編輯
為TListBox組件添加水平滾動(dòng)條
摘要: Delphi的TListBox組件會(huì)自動(dòng)添加一個(gè)垂直滾動(dòng)條,即當(dāng)列表框的高度容納不下所有的列表?xiàng)l目時(shí),垂直滾動(dòng)條就自動(dòng)顯示。但是,當(dāng)條目的寬度大于列表框的寬度時(shí),水平滾動(dòng)條不會(huì)自動(dòng)顯示。當(dāng)然, 可以在列表框中加如水平滾動(dòng)條,方法是在窗體的OnCreate事件處理程序中加入如下代碼:
procedure TForm1.FormCreate(Sender: TObject);
var
i, MaxWidth: integer;
begin
MaxWidth := 0;
for i := 0 to ListBox1.Items.Count - 1 do
if MaxWidth < ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]) then
MaxWidth := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[i]);
閱讀全文
posted @
2010-05-19 11:45 Ke 閱讀(373) |
評論 (0) 編輯
Delphi中Format與FormatDateTime函數(shù)詳解
摘要: 總結(jié)一下Format的用法:
Format('x=%d',[12]);//'x=12'//最普通
Format('x=%3d',[12]);//'x=12'//指定寬度
Format('x=%f',[12.0]);//'x=12.00'//浮點(diǎn)數(shù)
Format('x=%.3f',[12.0]);//'x=12.000'//指定小數(shù)
Format('x=%8.2f'[12.0])//'x=12.00';
Format('x=%.*f',[5,12.0]);//'x=12.00000'//動(dòng)態(tài)配置
Format('x=%.5d',[12]);//'x=00012'//前面補(bǔ)充0
Format('x=%.5x',[12]);//'x=0000C'//十六進(jìn)制
Format('x=%1:d%0:d',[12,13]);//'x=1312'//使用索引
Format('x=%p',[nil]);//'x=00000000'//指針
Format('x=%1.1e',[12.0]);//'x=1.2E
閱讀全文
posted @
2010-05-19 10:08 Ke 閱讀(29890) |
評論 (0) 編輯
Delphi+Codesoft 7.0
摘要: // 變量賦值
if chkParam.Checked then
begin
BarDoc.Variables.Item('var1').Value:= edtPN.Text;
BarDoc.Variables.Item('var2').Value:= edtPartName.Text;
BarDoc.Variables.Item('var3').Value:= edtDesc.Text;
end;
// 打印標(biāo)簽
Bardoc.Printlabel(seqty.Value);
// Feed
BarDoc.FormFeed;
// 關(guān)閉
Bardoc.Close;
BarApp.Quit;
閱讀全文
posted @
2010-05-14 08:12 Ke 閱讀(1310) |
評論 (0) 編輯
ODAC的安裝和使用(odac570src_0.28)
摘要: 第一步:在odac570src_0.28\Source\Delphi7打開dac70.dpk,然后編譯
第二步:打開dacvcl70.dpk,然后編譯
第三步:打開dcldac70.dpk,然后編譯
第四步:打開odac70.dpk,然后編譯
閱讀全文
posted @
2010-05-06 20:10 Ke 閱讀(1828) |
評論 (0) 編輯
Delphi 日誌記錄相關(guān)
摘要: //sDir:=ExtractFilePath(Application.ExeName)+'\';
ForceDirectories(sDir + 'TESTLOG');
sBackupFile := sDir + 'TESTLOG\'+FormatDateTime('YYYYMMDDHH',now())+'.log';
AssignFile(vFile, sBackupFile);
if FileExists(sBackupFile) then
Append(vFile)
else
Rewrite(vFile);
閱讀全文
posted @
2010-02-19 14:50 Ke 閱讀(538) |
評論 (0) 編輯
Delphi 常用函數(shù)整理
摘要: Delphi提供的字符串函數(shù)里有一個(gè)Pos函數(shù),它的定義是:
function Pos(Substr: string; S: string): Integer;
它的作用是在字符串S中查找字符串Substr,返回值是Substr在S中第一次出現(xiàn)的位置,如果沒有找到,返回值為0。
閱讀全文
posted @
2010-02-11 13:59 Ke 閱讀(270) |
評論 (0) 編輯
AssignFile Procedure Assigns a file handle to a binary or text file
摘要: AssignFile
Procedure Assigns a file handle to a binary or text file
閱讀全文
posted @
2010-02-09 15:42 Ke 閱讀(286) |
評論 (0) 編輯