03 2008 档案
SysUtils.FmtStr、SysUtils.Format - 格式化输出
摘要:FmtStr 是个过程, 它是用第一个参数来返回结果的; Format 是个函数, 返回值就是格式后的结果. 举例: var str: string; begin FmtStr(str, '最大整数是: %d', [MaxInt]); ShowMessage(str); {最大整数是: 2147483647} str := F... 阅读全文
posted @ 2008-03-31 22:49 万一 阅读(4855) 评论(1) 推荐(0) 编辑
SysUtils.IsDelimiter - 判断字符串的某个位置是不是指定的字符串
摘要:举例: var s: string; b: Boolean; begin s := 'CodeDear Delphi'; b := IsDelimiter('de', s, 3); ShowMessage(BoolToStr(b)); {返回 -1, 就是 True} end; SysUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 22:44 万一 阅读(2959) 评论(0) 推荐(0) 编辑
SysUtils.LastDelimiter - 判断一个字符串在另一个字符串中最后出现的位置
摘要:该函数不区分大小写, 举例: var s: string; i: Integer; begin s := 'CodeDear Delphi'; i := LastDelimiter('Del',s); ShowMessage(IntToStr(i)); {12} end; SysUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 22:38 万一 阅读(5291) 评论(0) 推荐(0) 编辑
StrUtils.DupeString - 反复字符串
摘要:举例: var s: string; begin s := 'Delphi'; s := DupeString(s,3); ShowMessage(s); //DelphiDelphiDelphi end; StrUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 22:36 万一 阅读(3775) 评论(0) 推荐(0) 编辑
SysUtils.Trim、SysUtils.TrimLeft、SysUtils.TrimRight - 删除空格
摘要:举例: var ss,s: string; begin ss := ' Delphi '; s := Trim(ss); {删除两边空格} ShowMessage('^' + s + '$'); {^Delphi$} s := TrimLeft(ss); {删除左空格} ShowMessage('^' + s + '$')... 阅读全文
posted @ 2008-03-31 22:32 万一 阅读(2639) 评论(0) 推荐(0) 编辑
StrUtils.LeftStr、StrUtils.RightStr - 提取左右字符串
摘要:举例: var ss,s: string; begin ss := 'CodeGear Delphi 2007'; s := RightStr(ss,4); ShowMessage(s); {2007} s := LeftStr(ss,4); ShowMessage(s); {Code} end; StrUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 21:47 万一 阅读(6933) 评论(0) 推荐(0) 编辑
StrUtils.ReverseString - 翻转字符串
摘要:举例: var ss,s: string; begin ss := 'Delphi'; s := ReverseString(ss); ShowMessage(s); {ihpleD} end; StrUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 21:45 万一 阅读(4197) 评论(1) 推荐(0) 编辑
SysUtils.QuotedStr - 加单引号
摘要:举例: var ss,s: string; begin ss := 'Delphi'; s := QuotedStr(ss); ShowMessage(s); {'Delphi'} end; SysUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 21:44 万一 阅读(2881) 评论(0) 推荐(0) 编辑
SysUtils.AdjustLineBreaks - Unix 与 Windows 的换行符互换
摘要:举例: var s: string; i: Integer; begin s := 'Delphi'#10'2007'; ShowMessage(IntToStr(Length(s))); {11} s := AdjustLineBreaks(s); //s := AdjustLineBreaks(s,tlbsCRLF); {tlbsCRLF 是默认的} Sh... 阅读全文
posted @ 2008-03-31 21:42 万一 阅读(2233) 评论(0) 推荐(0) 编辑
SysUtils.CompareStr、SysUtils.CompareText - 字符串比较
摘要:CompareStr 区分大小写; CompareText 不区分大小写. 举例: var s1,s2: string; i: Integer; begin s1 := 'abc'; s2 := 'adc'; i := CompareStr(s1,s2); ShowMessage(IntToStr(i)); {-2} i := CompareText(s1,s2)... 阅读全文
posted @ 2008-03-31 21:38 万一 阅读(4327) 评论(0) 推荐(0) 编辑
SysUtils.WrapText - 换行
摘要:举例: var ss,s: string; begin ss := 'aa.bb e-ff'; s := WrapText(ss, #13#10, ['.',' ',#9,'-'], 0); ShowMessage(s); {aa.} {bb } {e- } {ff... 阅读全文
posted @ 2008-03-31 21:34 万一 阅读(3209) 评论(1) 推荐(1) 编辑
SysUtils.UpperCase、SysUtils.LowerCase - 大小写转换
摘要:举例: var ss,s: string; begin ss := 'Delphi'; s := UpperCase(ss); ShowMessage(s); //DELPHI s := LowerCase(ss); ShowMessage(s); //delphi end; SysUtils 单元下的公用函数目录 阅读全文
posted @ 2008-03-31 21:32 万一 阅读(3244) 评论(0) 推荐(0) 编辑
SysUtils.StringReplace - 替换
摘要:举例: var ss,s: string; begin ss := '2007-2008'; s := StringReplace(ss,'00','x',[rfReplaceAll]); ShowMessage(s); //2x7-2x8 s := StringReplace(ss,'00','x',[rfIgnoreCase]); ShowMessage(s); ... 阅读全文
posted @ 2008-03-31 21:31 万一 阅读(5484) 评论(4) 推荐(0) 编辑
事件自调用 - 回复 maxcool 的问题
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; ... 阅读全文
posted @ 2008-03-31 16:48 万一 阅读(2143) 评论(8) 推荐(0) 编辑
问与答[2008-3-31]
摘要:经 MaxCool 的提议, 专门开辟了这个专栏! 记得, 我刚刚接触 Delphi 时, 在某论坛上请教了一个问题: 在 Delphi 的代码中, 为什么 end 后面有些是 ";" 号、有些是 "." 号、而有些后面什么也没有? 你知道我得到的答复是什么? 令人伤心的回复, 永远也不会忘记: "看书去!". 今天万一掌握了一点点基础知识, 所以说: "万一虽然浅薄, 但乐于助人; 有什么... 阅读全文
posted @ 2008-03-31 14:57 万一 阅读(3319) 评论(88) 推荐(0) 编辑
学习 TList 类的实现[8]
摘要:现在准备建立 Items 数组属性; 在 public 区输入下面代码: property Items[Index: Integer]: Pointer; 执行 Shift+Ctrl+C 后的代码是: ... TMyList = class(TObject) private ... function GetItems(Index: Integer): Pointer;... 阅读全文
posted @ 2008-03-31 14:41 万一 阅读(3830) 评论(14) 推荐(0) 编辑
学习 TList 类的实现[7]
摘要:总结目前 TMyList 已具备的功能(3 个方法、3 个属性): Add: 添加; Delete: 删除; Clear: 清空; Count: 元素总数; Capacity: 已存在的所有元素位置数; List: 指向核心数组的指针(只读). 举例测试如下: unit Unit1; interface uses Windows, Messages, SysUtils, Varia... 阅读全文
posted @ 2008-03-31 11:27 万一 阅读(3338) 评论(11) 推荐(0) 编辑
System.Odd - 判断一个整数是不是奇数
摘要:举例: var i: Integer; b: Boolean; begin i := 11; b := Odd(i); {是奇数返回真} ShowMessage(BoolToStr(b)); {True} i := 12; b := Odd(i); ShowMessage(BoolToStr(b)); {False} end; ... 阅读全文
posted @ 2008-03-30 23:13 万一 阅读(4279) 评论(2) 推荐(0) 编辑
System.Sqr、System.Sqrt - 平方与平方根
摘要:举例: var d: Real; begin d := Sqr(6); ShowMessage(FloatToStr(d)); {36} end; var d: Real; begin d := Sqrt(81); ShowMessage(FloatToStr(d)); {9} end; System 单元下的公用函数目录 阅读全文
posted @ 2008-03-30 23:12 万一 阅读(4780) 评论(0) 推荐(0) 编辑
System.Trunc、System.Round、System.Int - 返回整数部分
摘要:举例:var i: Integer; d: Real;begin i := Trunc(1234.5678); {截取整数} ShowMessage(IntToStr(i)); {1234} i := Trunc(-1234.5678); ShowMessage(IntTo... 阅读全文
posted @ 2008-03-30 23:09 万一 阅读(3129) 评论(2) 推荐(0) 编辑
System.Abs - 绝对值
摘要:举例: var d: Real; v: Variant; begin d := Abs(-1.2); ShowMessage(FloatToStr(d)); {1.2} v := '-100'; ShowMessage(v); {-100; v 是变体类型可以直接显示} v := Abs(v); ShowMessage(v); ... 阅读全文
posted @ 2008-03-30 22:55 万一 阅读(3707) 评论(0) 推荐(0) 编辑
System.SetString - 获取字符串
摘要:举例: var ss,s: string; begin ss := 'CodeGear Delphi 2007'; SetString(s,PChar(ss),4); ShowMessage(s); {Code} end; var s: string; arr: array[0..6] of Char; i: Integer; begin for i := 0... 阅读全文
posted @ 2008-03-29 22:58 万一 阅读(7076) 评论(3) 推荐(0) 编辑
System.Val - 将字符串转换为数字
摘要:举例: var s: string; i: Real; j: Integer; begin s := '13.2435'; Val(s,i,j); ShowMessage(FloatToStr(i)); {13.2435} ShowMessage(IntToStr(j)); {返回 0 表示转换成功} s := '13_2435'; Val(s,i,... 阅读全文
posted @ 2008-03-29 22:50 万一 阅读(5276) 评论(0) 推荐(0) 编辑
System.Str - 将数字格式化为字符串
摘要:举例: var s: string; begin Str(123, s); ShowMessage(s); {123} Str(PI, s); ShowMessage(s); {3.14159265358979E+0000} Str(PI:0:2, s); ShowMessage(s); {3.14} Str(9.1:1:3, s); ShowMe... 阅读全文
posted @ 2008-03-29 22:43 万一 阅读(2948) 评论(0) 推荐(1) 编辑
System.FillChar - 填充字节
摘要:举例: var s: array[0..9] of Char; begin FillChar(s,SizeOf(s),'a'); ShowMessage(s); {aaaaaaaaaa} end; var arr: array[0..3] of Word; i: Integer; begin FillChar(arr, Length(arr) * SizeOf(Wor... 阅读全文
posted @ 2008-03-29 22:36 万一 阅读(5408) 评论(2) 推荐(1) 编辑
System.StringOfChar - 反复字符
摘要:举例: var s: string; begin s := StringOfChar('G', 5); ShowMessage(s); {GGGGG} end; var s: string; begin s := StringOfChar(#65, 5); ShowMessage(s); {AAAAA} end; var s: string; begin ... 阅读全文
posted @ 2008-03-29 22:23 万一 阅读(4274) 评论(3) 推荐(0) 编辑
System.Pos - 搜索子串的位置
摘要:举例: var ss,s: string; i: Integer; begin ss := 'CodeGear Delphi 2007'; s := 'Gear'; i := Pos(s,ss); ShowMessage(IntToStr(i)); {5} s := '2008'; i := Pos(s,ss); ShowMessage(IntToStr(... 阅读全文
posted @ 2008-03-29 22:21 万一 阅读(3807) 评论(0) 推荐(0) 编辑
System.Concat - 连接字符串
摘要:举例: var s: string; begin s := Concat('CodeGear', #32 ,'Delphi', #32 ,'2007'); ShowMessage(s); {CodeGear Delphi 2007} end; System 单元下的公用函数目录 阅读全文
posted @ 2008-03-29 22:17 万一 阅读(3111) 评论(13) 推荐(1) 编辑
学习 TList 类的实现[6]
摘要:实现 TMyList.Add 函数. TList 中的 Add 函数用到了一个 Grow 方法, 它的原理是元素越多就为以后准备更多内存, 我们这里省略为预留 4 个元素的内存; TList 中的 Add 函数还同时触动了一个 Notify 方法, 这应该是为它们的子类准备的(估计是用它来激发一个事件的), 也不要了. function TMyList.Add(Item: Pointer): ... 阅读全文
posted @ 2008-03-28 15:54 万一 阅读(3731) 评论(14) 推荐(0) 编辑
学习 TList 类的实现[5]
摘要:先来实现 TMyList.SetCapacity. 马上会想到下面代码: procedure TMyList.SetCapacity(const Value: Integer); begin if FCapacity Value then FCapacity := Value; end; 但这样是远远不够的, 关键是需要分配内存, 像这样: ReallocMem(数组的起点... 阅读全文
posted @ 2008-03-28 14:06 万一 阅读(3443) 评论(6) 推荐(1) 编辑
学习 TList 类的实现[4]
摘要:现在准备一步步地模拟 TList 类, 建立一个自己的 TMyList. 首先, 这个类中应该包括前面提到的那个 Pointer 数组(TPointerList)的指针(PPointerList): TMyList = class(TObject) FList: PPointerList; end; 既然是一个列表, 应该有 Count 字段: TMyList = class(TO... 阅读全文
posted @ 2008-03-28 11:09 万一 阅读(4376) 评论(1) 推荐(0) 编辑
raise 语句: 抛出异常
摘要://例1: begin raise Exception.Create('抛出异常'); end; //例2: begin raise Exception.CreateFmt('%s %d', ['错误代码:', 999]); end; //例3: var exc: Exception; begin exc := Exception.Create('发现异常'); ra... 阅读全文
posted @ 2008-03-27 23:26 万一 阅读(10161) 评论(2) 推荐(0) 编辑
System.Move - 移动内存块
摘要:举例: var Source,Dest: string; begin Source := '123456789'; Dest := '---------'; Move(Source[5], Dest[3], 4); ShowMessage(Dest); {--5678---} end; System 单元下的公用函数目录 阅读全文
posted @ 2008-03-27 23:18 万一 阅读(7156) 评论(8) 推荐(0) 编辑
System.ReallocMem - 重新申请内存
摘要:本例是顺着 GetMem 的例子往下做的: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Send... 阅读全文
posted @ 2008-03-27 22:39 万一 阅读(4523) 评论(3) 推荐(0) 编辑
System.GetMem、System.FreeMem - 申请和释放内存
摘要:如果只为单个指针分配内存, 和 New 和 Dispose 是一样的; 与之不同的是: GetMem 可以申请连续的多个内存块. 举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TFor... 阅读全文
posted @ 2008-03-27 18:09 万一 阅读(10002) 评论(11) 推荐(2) 编辑
System.New、System.Dispose - 为某个指针申请和释放内存
摘要:举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TB... 阅读全文
posted @ 2008-03-27 17:41 万一 阅读(4902) 评论(4) 推荐(0) 编辑
学习 TList 类的实现[3] - 不能回避的话题: 内存分配
摘要:在 Delphi 中, 几乎所有的类型都有对应的指针类型, 譬如:Char PCharWord PWORDDouble PDoubleTPoint PPoint甚至一种类型对应这着几种指针类型, 譬如:Integer PInteger PINTWideChar PWideChar PWChar即使它没有定义, 我也可以直接使用一个类型的指针, 譬如声明一个整数的指针变量:var px: ^In... 阅读全文
posted @ 2008-03-27 16:13 万一 阅读(5649) 评论(13) 推荐(1) 编辑
学习 TList 类的实现[2]
摘要:我原来以为 TList 可能是一个链表, 其实只是一个数组而已. 你知道它包含着多大一个数组吗? MaxListSize 个! MaxListSize 是 Delphi 在 Classes 单元定义的一个常量: MaxListSize = Maxint div 16; 也就是 134217727; 这也是 TList 的最大容量. 其中的 Maxint(2147483647) 也就是 2个G, 这... 阅读全文
posted @ 2008-03-27 11:53 万一 阅读(7124) 评论(22) 推荐(0) 编辑
学习 TList 类的实现[1]
摘要:最近整理了一些函数列表, 算是一个宏观的安排; 等以后再碰到一些函数时就可以放置的更有次序一些. 我对函数与类的理解是: 函数是一个功能模块, 类是一个更强大的功能模块; Delphi 已经提供了很多的函数与类, 但很多时候我们却视而不见, 重新"刀耕火种". 曾记得网上有一个 Delphi 行家连续几年开发与升级一个"通配符"相关的函数, 终于有一天他说: 原来 Delphi 有这个函数. 也见... 阅读全文
posted @ 2008-03-26 00:02 万一 阅读(9689) 评论(16) 推荐(0) 编辑
System.Insert - 插入字符串
摘要:procedure Insert( Substr: String; {要插入的字符串; 可以是常量} var Dest: String; {源字符串} Index: Integer {从第几个字符前插入} ); 举例: var ss,s: WideString; begin ss := '万一的博客'; s := ' Delphi '; Insert(... 阅读全文
posted @ 2008-03-25 23:19 万一 阅读(5544) 评论(2) 推荐(1) 编辑
System.Delete - 从字符串中删除
摘要:procedure Delete( var S: String; {源字符串; 因为是 var 参数, 不可能是个常量} Index: Integer; {起始位置; 第一个字符的位置是 1, 起始位置不能小于 1 } Count: Integer {要删除的字数} ); 举例: var s: string; begin s := 'Delphi 2007'; ... 阅读全文
posted @ 2008-03-25 23:03 万一 阅读(4481) 评论(0) 推荐(0) 编辑
System.Copy - 从字符串或数组中复制
摘要:function Copy( S: String; {字符串或动态数组} Index: Integer; {起始位置} Count: Integer {Copy 个数} ): String; {如果参数 S 是动态数组, 这里也应该返回动态数组} 举例: //从字符串中提取 var ss,s: string; begin ss := 'Code... 阅读全文
posted @ 2008-03-25 14:03 万一 阅读(8060) 评论(6) 推荐(0) 编辑
System.Length - 获取字符串或数组的长度
摘要:function Length( S: String {字符串; 也可以是数组} ): Integer; 举例: //string(在 Delphi 2007 下同 AnsiString) var s: string; i: Integer; begin s := 'Delphi'; i := Length(s); ShowMessage(IntToStr(i));... 阅读全文
posted @ 2008-03-24 22:49 万一 阅读(6653) 评论(11) 推荐(1) 编辑
Variants 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 DynArrayFromVariant DynArrayToVariant FindCustomVariantType FindVarData HandleConversionException Null Unassigned VarArrayAsPSafeArray VarArrayCreate VarArrayCreat... 阅读全文
posted @ 2008-03-24 17:29 万一 阅读(7073) 评论(5) 推荐(0) 编辑
Graphics 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 AllocPatternBitmap BytesPerScanline CharsetToIdent ColorToIdent ColorToRGB ColorToString CopyPalette CreateGrayMappedBmp CreateGrayMappedRes CreateMappedBmp Create... 阅读全文
posted @ 2008-03-24 17:28 万一 阅读(4962) 评论(2) 推荐(0) 编辑
StrUtils 单元下的公用函数目录
摘要:有简单提示的链接有效.过程或函数名分类 简单提示 AnsiContainsStrAnsiContainsTextAnsiEndsStrAnsiEndsTextAnsiIndexStrAnsiIndexTextAnsiLeftStrAnsiMatchStrAnsiMatchTextAnsiMidStrAnsiReplaceStrAnsiReplaceTextAnsiResemblesTextAnsi... 阅读全文
posted @ 2008-03-24 17:26 万一 阅读(6007) 评论(5) 推荐(0) 编辑
Math 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 ArcCos ArcCosh ArcCot ArcCotH ArcCsc ArcCscH ArcSec ArcSecH ArcSin ArcSinh ArcTan2 ArcTanh Ceil ClearExceptions CompareValue Cosecant Cosh Cot Cotan CotH Csc CscH ... 阅读全文
posted @ 2008-03-24 17:25 万一 阅读(4643) 评论(2) 推荐(0) 编辑
DateUtils 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 CompareDate CompareDateTime CompareTime DateOf DateTimeToJulianDate DateTimeToModifiedJulianDate DateTimeToUnix DayOf DayOfTheMonth DayOfTheWeek DayOfTheYear DaysB... 阅读全文
posted @ 2008-03-24 17:22 万一 阅读(3468) 评论(0) 推荐(0) 编辑
Classes 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 ActivateClassGroup ActiveClassGroup AllocateHWnd AncestorIsValid BeginGlobalLoading BinToHex Bounds CheckSynchronize ClassGroupOf CollectionsEqual CountGenerations... 阅读全文
posted @ 2008-03-24 17:20 万一 阅读(5030) 评论(0) 推荐(0) 编辑
Windows 单元下的公用函数目录(R-Z_)
摘要:有简单提示的链接有效. 函数名 类别 简单提示 RaiseException ReadConsole ReadConsoleInput ReadConsoleOutput ReadConsoleOutputAttribute ReadConsoleOutputCharacter ReadDirectoryChanges ReadEventLog ReadFile ReadFil... 阅读全文
posted @ 2008-03-24 15:47 万一 阅读(4671) 评论(1) 推荐(0) 编辑
Windows 单元下的公用函数目录(G-Q)
摘要:有简单提示的链接有效. 函数名 类别 简单提示 GdiComment GdiFlush GdiGetBatchLimit GdiSetBatchLimit GenerateConsoleCtrlEvent GET_APPCOMMAND_LPARAM GET_DEVICE_LPARAM GET_FLAGS_LPARAM GET_KEYSTATE_LPARAM GET_MOUSEO... 阅读全文
posted @ 2008-03-24 15:43 万一 阅读(4019) 评论(0) 推荐(0) 编辑
Windows 单元下的公用函数目录(A-F)
摘要:有简单提示的链接有效. 函数名 类别 简单提示 AbortDoc AbortPath AbortSystemShutdown AccessCheck AccessCheckAndAuditAlarm AccessCheckByType AccessCheckByTypeAndAuditAlarm AccessCheckByTypeResultList AccessCheckBy... 阅读全文
posted @ 2008-03-24 14:49 万一 阅读(5994) 评论(0) 推荐(0) 编辑
CnPack 使用的组件命名约定
摘要:类名前缀 TActionact TActionListactlst TActionMainMenuBaractmmb TActionManageractmgr TActionToolBaracttb TADOCommandcmd TADOConnectioncon TADODataSetds TADOQueryqry TADOStoredProcsp TADOTabletbl TAnimatea... 阅读全文
posted @ 2008-03-24 13:38 万一 阅读(5085) 评论(0) 推荐(0) 编辑
SysUtils 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 Abort AddExitProc AddTerminateProc AdjustLineBreaksUnix 与 Windows 的换行符互换 AnsiCompareFileName AnsiCompareStr AnsiCompareText AnsiDequotedStr AnsiExtractQuotedStr An... 阅读全文
posted @ 2008-03-23 22:47 万一 阅读(6264) 评论(2) 推荐(0) 编辑
System 单元下的公用函数目录
摘要:有简单提示的链接有效. 过程或函数名 分类 简单提示 Abs绝对值 AcquireExceptionObject AddModuleUnloadProc Addr AllocMem AnsiToUtf8 Append ArcTan Assert Assign Assigned AssignFile AttemptToUseSharedMemoryManager BeginThr... 阅读全文
posted @ 2008-03-21 17:30 万一 阅读(6729) 评论(6) 推荐(0) 编辑
颜色选取 - 权当给 supperment 的回复吧, 你的要求要用到"种子算法", 我暂时还没算明白.
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; ... 阅读全文
posted @ 2008-03-21 15:47 万一 阅读(2687) 评论(3) 推荐(0) 编辑
学习 TTreeView [15] - 连接数据库 (作为给 "丁永其" 和 "DELPHI万岁" 两位朋友的回复)
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, DBClient, StdCtrls, ComCtrls, ExtCtrls; type TForm1... 阅读全文
posted @ 2008-03-20 11:30 万一 阅读(9962) 评论(43) 推荐(0) 编辑
快捷键设置控件: THotKey [2] - 自定义菜单快捷键
摘要:运行效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) HotKey1: THotKey; ... 阅读全文
posted @ 2008-03-20 10:45 万一 阅读(3175) 评论(8) 推荐(0) 编辑
关于十六进制转十进制 - 回复 MaxCool 的问题
摘要:这不需要写函数. //如果十六进制非字符串, 无须转换, 直接赋值即可 var i: Integer; begin i := $FF; ShowMessage(IntToStr(i)); {255} end; //如果十六进制是字符串, 用 StrToInt 即可 var s: string; i: Integer; begin s := '$FF'; i :=... 阅读全文
posted @ 2008-03-19 15:20 万一 阅读(6014) 评论(23) 推荐(1) 编辑
快捷键设置控件: THotKey [1]
摘要:运行效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) HotKey1: THotKey; ... 阅读全文
posted @ 2008-03-19 15:19 万一 阅读(5461) 评论(11) 推荐(2) 编辑
《Delphi 算法与数据结构》学习与感悟[10]: 双向链表
摘要:如果在结构中再拿出 4 个字节的地址空间指向上一个节点, 就成了双向链表了. 本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(... 阅读全文
posted @ 2008-03-19 13:32 万一 阅读(4792) 评论(8) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[9]: 循环链表
摘要:前面例子中, 链表的尾节点都再没有链接其他节点; 如果让尾节点再链接首节点, 不就是循环链表了吗? 本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFor... 阅读全文
posted @ 2008-03-19 13:30 万一 阅读(3219) 评论(0) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[8]: 单向链表的添加、删除与遍历
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TBu... 阅读全文
posted @ 2008-03-18 23:58 万一 阅读(4016) 评论(4) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[7]: 链表与数组的异同
摘要:首先, 上一个例子, 用数组也可以实现, 并且更简单: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: ... 阅读全文
posted @ 2008-03-18 23:24 万一 阅读(3703) 评论(10) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[6]: 一个简单的"单向链表"
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton... 阅读全文
posted @ 2008-03-18 14:23 万一 阅读(3682) 评论(3) 推荐(2) 编辑
《Delphi 算法与数据结构》学习与感悟[5]: 定位一个字符位置时, Pos 函数为什么不是最快的?
摘要:如果 Pos 函数的第一个参数是 Char 而非 String, 那么编译器也会先把 Char 转换为 String; 从内存结构到管理机制, String 远比 Char 要复杂. 因此, 面对这种情况(要定位的是 Char) Pos 还有优化的余地; 优化后速度会提升 5 倍左右. 测试效果图: unit Unit1; interface uses Windows, Mess... 阅读全文
posted @ 2008-03-18 12:53 万一 阅读(3720) 评论(2) 推荐(2) 编辑
《Delphi 算法与数据结构》学习与感悟[4]: 关于 const
摘要:如果参数在函数中不可能修改, 一定要使用 const; 不然, 编译器就会: 假定先修改, 先要备份; 使用前后要增减引用计数; 还要套上 try finally. 指定了 const 就可以避免以上过程从而提高效率. 测试效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes... 阅读全文
posted @ 2008-03-18 10:55 万一 阅读(3208) 评论(6) 推荐(2) 编辑
《Delphi 算法与数据结构》学习与感悟[3]: 获取一个字节中非空位的个数
摘要:一个字节有 8 个位, 这些位可能是 0 也可能是 1; 现在要算出一个字节中是 1 的位共有多少个. 第一种方法是一个函数; 第二种方法笨了点, 是先把 256 种可能值给一个数组, 随时调取. 第一种方法虽然灵巧, 但不如第二种方法快(作者书中说: 在非特殊情况下, 一般要快到 10 倍左右); 第二种方法虽然快捷, 并且使用方便, 但要以 256 个字节的数组空间为代价. uni... 阅读全文
posted @ 2008-03-17 23:27 万一 阅读(3184) 评论(10) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[2]: 数据对齐
摘要:为了加快硬件的访问速度, 编译器通常要使用"数据对齐", 譬如: //下面结构中: SizeOf(TRec) = 6; 因为 b 在这里也要占 2 字节. TRec = record a: Word; b: Byte; c: Word; end; //下面结构中: SizeOf(TRec) = 16; 这里的 a 和 b 共占了 8 个字节. TRec = record a:... 阅读全文
posted @ 2008-03-17 18:28 万一 阅读(3934) 评论(12) 推荐(1) 编辑
《Delphi 算法与数据结构》学习与感悟[1]: 通过 "顺序查找" 与 "二分查找" 说明算法的重要性
摘要:测试效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: T... 阅读全文
posted @ 2008-03-17 10:41 万一 阅读(8213) 评论(20) 推荐(1) 编辑
《Delphi 算法与数据结构》简介及下载
摘要:相比其他编程语言, Delphi 的名著可不算多呀; Julian Bucknall[巴克纳尔(美)] 所著的《Delphi 算法与数据结构》就是不可多得的一本! 算法与数据结构是早就该学得, 能有幸同时接近大师的思想, 太幸运了. 目录 前 言 致 谢 第1章 什么是算法 1. 1 什么是算法 1. 2 算法和平台 1. 3 调试与测试 1. 4 小结 第2章 数组 2. 1 数组 2.... 阅读全文
posted @ 2008-03-17 00:59 万一 阅读(7020) 评论(9) 推荐(2) 编辑
学习 TTreeView [14] - StateIndex(状态图标)、OverlayIndex(叠加图标)
摘要:先给 ImageList1 添加图标如下: 关于 OverlayIndex 的提示: 在给一个节点指定 OverlayIndex 以前, 需要先用 ImageList1.Overlay 指定可用的 OverlayIndex 号. 测试效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, C... 阅读全文
posted @ 2008-03-16 00:42 万一 阅读(7688) 评论(13) 推荐(0) 编辑
学习 TTreeView [13] - 在 TTreeView 中显示目录结构(的函数)
摘要:测试效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type TForm1 = class(TForm) TreeView1... 阅读全文
posted @ 2008-03-15 00:27 万一 阅读(6744) 评论(23) 推荐(0) 编辑
学习 TTreeView [12] - FullExpand、FullCollapse、GetNodeAt
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) TreeView1: TTreeVie... 阅读全文
posted @ 2008-03-14 14:41 万一 阅读(5260) 评论(4) 推荐(0) 编辑
学习 TTreeView [11] - Images、ImageIndex、SelectedIndex、StateImages、StateIndex
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ImgList, ComCtrls; type TForm1 = class(TForm) TreeView1: TTreeView... 阅读全文
posted @ 2008-03-14 01:43 万一 阅读(7917) 评论(21) 推荐(0) 编辑
学习 TTreeView [10] - AutoExpand、HotTrack、ReadOnly、ShowButtons、ShowLines、ShowRoot、Indent
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm1 = class(TForm) TreeView1: TTreeVie... 阅读全文
posted @ 2008-03-13 23:24 万一 阅读(4794) 评论(6) 推荐(0) 编辑
学习 TTreeView [9] - OnDragDrop、OnDragOver
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm1 = class(TForm) TreeView1: TTreeVie... 阅读全文
posted @ 2008-03-13 17:16 万一 阅读(4533) 评论(9) 推荐(0) 编辑
学习 TTreeView [8] - AlphaSort、CustomSort、SortType
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm1 = class(TForm) TreeView1: TTreeVie... 阅读全文
posted @ 2008-03-13 11:42 万一 阅读(4661) 评论(1) 推荐(0) 编辑
学习 TTreeView [7] - Insert、Delete
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Grids, ExtCtrls; type TForm1 = class(TForm) Tr... 阅读全文
posted @ 2008-03-12 19:49 万一 阅读(4927) 评论(8) 推荐(0) 编辑
学习 TTreeView [6] - SaveToFile、LoadFromStream、SaveToStream、LoadFromFile
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Grids, ExtCtrls; type TForm1 = class(TForm) Tr... 阅读全文
posted @ 2008-03-12 15:31 万一 阅读(6026) 评论(15) 推荐(0) 编辑
学习 TTreeView [5] - TTreeNode.Level 属性
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Grids, ExtCtrls; type TForm1 = class(TForm) Tr... 阅读全文
posted @ 2008-03-12 13:17 万一 阅读(8892) 评论(7) 推荐(0) 编辑
判断一个对象是否存在, 谁更快?
摘要:判断一个对象是否存在(赋值)的三种办法如下: if obj nil then ... if Boolean(obj) then ... if Assigned(obj) then ... 通过下面的测试, 结论是 obj nil 最慢; Boolean(obj) 与 Assigned(btn) 相当! 测试图: 测试源码: unit Unit1; interface u... 阅读全文
posted @ 2008-03-12 09:03 万一 阅读(8685) 评论(16) 推荐(0) 编辑
学习 TTreeView [4] - TTreeNode 类的常用属性与 TTreeView 类的 OnChange 事件
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, Grids; type TForm1 = class(TForm) TreeView1: T... 阅读全文
posted @ 2008-03-12 01:59 万一 阅读(5865) 评论(8) 推荐(0) 编辑
看看我最关心的动态库中到底有多少函数 - winmm.dll
摘要:获取方法: 运行: tdump.exe C:\windows\system32\winmm.dll c:\temp\winmm.txt CloseDriver DefDriverProc DriverCallback DrvGetModuleHandle GetDriverModuleHandle MigrateAllDrivers MigrateSoundEvents NotifyCallb... 阅读全文
posted @ 2008-03-11 23:51 万一 阅读(2634) 评论(0) 推荐(0) 编辑
看看我最关心的动态库中到底有多少函数 - gdi32.dll
摘要:获取方法: 运行: tdump.exe C:\windows\system32\gdi32.dll c:\temp\gdi32.txt AbortDoc AbortPath AddFontMemResourceEx AddFontResourceA AddFontResourceExA AddFontResourceExW AddFontResourceTracking AddFontReso... 阅读全文
posted @ 2008-03-11 23:49 万一 阅读(6625) 评论(2) 推荐(0) 编辑
看看我最关心的动态库中到底有多少函数 - gdiplus.dll
摘要:获取方法: 运行: tdump.exe C:\windows\system32\gdiplus.dll c:\temp\gdiplus.txt GdipAddPathArc GdipAddPathArcI GdipAddPathBezier GdipAddPathBezierI GdipAddPathBeziers GdipAddPathBeziersI GdipAddPathClosedCu... 阅读全文
posted @ 2008-03-11 23:46 万一 阅读(7249) 评论(4) 推荐(0) 编辑
学习 TTreeView [3] - Add、AddChild、AddFirst、AddChildFirst、Parent
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm1 = class(TForm) TreeView1: TTreeVie... 阅读全文
posted @ 2008-03-11 15:14 万一 阅读(8233) 评论(3) 推荐(0) 编辑
学习 TTreeView [2] - Items.Item[i]、Items[i]、.Text、SetFocus(设置焦点)、Select(选择)
摘要:本例效果图: 源码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm1 = class(TForm) TreeView1: TT... 阅读全文
posted @ 2008-03-11 02:44 万一 阅读(8350) 评论(7) 推荐(0) 编辑
学习 TTreeView [1] - TTreeNodes、TTreeNode 与 Items、Items.Count、Items.Clear
摘要:填写 TTreeView 的内容一般是这样开始的(下图), 不过我觉得最好习惯用动态建立. 打个比方: 譬如 TreeView 是一个军营的"营部"! 这里会有营长、连长、排长、班长、战士等等. 我们把它们分成三种对象: 营部、营长(总当家)、营长的下属. 在这里的对应关系是: TTreeView - 营部 TTreeNodes - 营长 TTreeNode - 营长的下属 上面... 阅读全文
posted @ 2008-03-10 14:56 万一 阅读(10163) 评论(27) 推荐(0) 编辑
WinAPI: OpenProcess、GetExitCodeProcess、TerminateProcess (测试强制关闭 OICQ)
摘要://声明: {返回进程的句柄} OpenProcess( dwDesiredAccess: DWORD; {访问选项} bInheritHandle: BOOL; {能否继承; True 表示能用 CreateProcess 继承句柄创建新进程} dwProcessId: DWORD {指定进程 ID} ): THandle; {成... 阅读全文
posted @ 2008-03-10 12:19 万一 阅读(18371) 评论(17) 推荐(0) 编辑
WinAPI: GetWindowThreadProcessId - 获取指定窗口的进程 ID 或线程 ID
摘要://声明: GetWindowThreadProcessId( hWnd: HWND; {指定窗口句柄} lpdwProcessId: Pointer = nil {返回进程 ID 的指针} ): DWORD; {返回线程 ID} //举例: unit Unit1; interface uses Wi... 阅读全文
posted @ 2008-03-10 11:59 万一 阅读(17934) 评论(1) 推荐(0) 编辑
WinAPI: GetCurrentThread、GetCurrentThreadId、GetCurrentProcess、GetCurrentProcessId
摘要:{返回当前线程的虚拟句柄} GetCurrentThread: THandle; {返回当前线程 ID} GetCurrentThreadId: DWORD; {返回当前进程的虚拟句柄} GetCurrentProcess: THandle; {返回当前进程 ID} GetCurrentProcessId: DWORD; 提示: ID 是系统唯一的标识. 所谓虚拟句柄, 就是该句柄只... 阅读全文
posted @ 2008-03-10 10:43 万一 阅读(19862) 评论(0) 推荐(0) 编辑
WinApi: GetParent、SetParent、MoveWindow - 获取、指定父窗口和移动窗口
摘要:提示: SetParent 应该 Windows.SetParent, 因为 TForm 的父类有同名方法. //声明: {获取父窗口句柄} GetParent(hWnd: HWND): HWND; {指定父窗口} SetParent( hWndChild: HWND; {子句柄} hWndNewParent: HWND {父句柄} ): HWND; ... 阅读全文
posted @ 2008-03-10 00:39 万一 阅读(10338) 评论(6) 推荐(0) 编辑
WinAPI: GetWindowRect、GetClientRect - 获取窗口的外部与内部矩形
摘要:提示: 1、其实用 Delphi 内部同类函数很方便的, 但系统函数是全局的; 2、使用 GetClientRect 时, 一般要 Windows.GetClientRect, 因为 TForm 的父类有同名函数. //声明: {获取窗口外部矩形(相对于屏幕)} GetWindowRect( hWnd: HWND; {窗口句柄} var lpRect: TRect {用... 阅读全文
posted @ 2008-03-10 00:19 万一 阅读(8772) 评论(0) 推荐(0) 编辑
WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
摘要://声明: WindowFromPoint(Point: TPoint): HWND; //举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TF... 阅读全文
posted @ 2008-03-09 23:32 万一 阅读(11010) 评论(19) 推荐(2) 编辑
说到"计算器", 建议大家用它进行"进制转换"
摘要:博客上有很多地方需要进制转换, 特提示一下, 是不是太多余了? 阅读全文
posted @ 2008-03-09 21:56 万一 阅读(4387) 评论(5) 推荐(0) 编辑
用鼠标获取任意窗口的句柄, 并把它当作"干儿子"
摘要:首先建议初学者不要在这些小的技巧上下太多功夫, 学好基础才是根本; 我的博客上这种东西不多, 这是大家讨论时, 话赶话赶出来的, 知道有这种可行性即可, 没有多少实用价值. 本例效果图: 此例回复来宾在 http://www.cnblogs.com/del/archive/2008/02/26/1081644.html 碰到的问题. 全部代码如下(测试时注意给主窗体焦点): uni... 阅读全文
posted @ 2008-03-09 21:27 万一 阅读(8834) 评论(6) 推荐(3) 编辑
全局探色器
摘要:本例效果图: 此例回复 maxcool(我坚定的支持者与监督者, 离不开你呀!) 在 http://www.cnblogs.com/del/archive/2008/03/09/1096874.html#1097203 提出的问题. 全部代码如下: unit Unit1; interface uses Windows, Messages, SysUtils, Variants,... 阅读全文
posted @ 2008-03-09 12:57 万一 阅读(3614) 评论(38) 推荐(0) 编辑
WinAPI: SetLayeredWindowAttributes - 设置窗口的透明
摘要:这是来宾 Dolby 在 http://www.cnblogs.com/del/archive/2008/03/08/1081295.html#1096814 询问的问题. //声明: SetLayeredWindowAttributes( Hwnd: THandle; {窗口句柄} crKey: COLORREF; {透明色} bAlpha: Byte; {Alpha ... 阅读全文
posted @ 2008-03-08 22:23 万一 阅读(13247) 评论(27) 推荐(0) 编辑
谈谈 Delphi 的类型与指针[2]
摘要:内存中的数据除了 0 便是 1, 你把它当作图片、字符、数字等等, 那是你的事, 内存只认识 0 和 1. Win32 系统除了使用硬内存以外, 还可以从硬盘上开辟虚拟内存; 因为 Win32 的内存地址范围在 4 个 G 以内(0..232-1), 所以它最多能够给一个应用程序分配 4G 的运行空间; 并且其中的 2G 有系统管理, 实际上程序只有 2G 的自主空间. 还记得有说 Strin... 阅读全文
posted @ 2008-03-07 12:10 万一 阅读(8056) 评论(29) 推荐(1) 编辑
谈谈 Delphi 的类型与指针[1]
摘要:先声明: 不要把我说的这些个东西当作教科书, 这都是自己的浅见; 同时希望得到指正. Delphi 的指针分为 "类型指针" 和 "无类型指针" 两类. Delphi 中的类型, 常用的也得有几百个, 我们可以给每种类型定义相应的类型指针. 其实 Delphi 已经为很多类型预定义了指针, 譬如数据类型: Integer 有对应的 PInteger; Char 有对应的 PChar; stri... 阅读全文
posted @ 2008-03-07 10:08 万一 阅读(30405) 评论(8) 推荐(4) 编辑
学用 TStringGrid [9] - OnDrawCell
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids; type TForm1 = class(TForm) StringGrid1:... 阅读全文
posted @ 2008-03-06 23:05 万一 阅读(10318) 评论(25) 推荐(0) 编辑
学用 TStringGrid [8] - 字体列表
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids; type TForm1 = class(TForm) StringGrid1:... 阅读全文
posted @ 2008-03-06 21:42 万一 阅读(5207) 评论(5) 推荐(0) 编辑
学用 TStringGrid [7] - ColWidths[0]、RowHeights[0]、GridLineWidth
摘要:本例效果图: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids; type TForm1 = class(TForm) StringGrid1:... 阅读全文
posted @ 2008-03-06 21:18 万一 阅读(5099) 评论(0) 推荐(0) 编辑
学用 TStringGrid [6] - Options
摘要:本例运行效果图: 一般修改 TStringGrid 的 Options 直接在设计时选一下 True 或 False 就行了; 代码中可以像下面操作: StringGrid1.Options := [goFixedVertLine]; StringGrid1.Options := [goFixedVertLine, goVertLine, goColSizing]; 做完这个例... 阅读全文
posted @ 2008-03-06 11:47 万一 阅读(11121) 评论(28) 推荐(0) 编辑
学用 TStringGrid [5] - FixedCols、FixedRows、Color、FixedColor
摘要:本例运行效果图: //示例代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids; type TForm1 = class(TForm) St... 阅读全文
posted @ 2008-03-05 16:42 万一 阅读(7059) 评论(2) 推荐(0) 编辑
学用 TStringGrid [4] - ColWidths、RowHeights
摘要:本例功能: 1、调整单元宽度; 2、调整单元高度. 运行效果图: //本例代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids; type TFo... 阅读全文
posted @ 2008-03-05 14:58 万一 阅读(5644) 评论(2) 推荐(0) 编辑
学用 TStringGrid [3] - Cols、Rows
摘要:须知: TStringGrid 的每行、每列都是一个 TStrings 对象. 本例功能: 1、分别按列与行修改; 2、分别按列与行读取 运行效果图: //本例代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Di... 阅读全文
posted @ 2008-03-05 12:15 万一 阅读(6850) 评论(3) 推荐(0) 编辑
学用 TStringGrid [2] - DefaultColWidth、DefaultRowHeight、Col、Row
摘要:本例功能: 1、修改 StringGrid 单元的默认宽与高; 2、添加行和列; 3、确认当前单元并赋值. 运行效果图: //本例代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ... 阅读全文
posted @ 2008-03-05 10:18 万一 阅读(7862) 评论(11) 推荐(1) 编辑
学用 TStringGrid [1] - ColCount、RowCount、Cells
摘要:本例功能: 1、获取 StringGrid 的行数、列数; 2、给单元赋值. 运行效果图: //示例代码: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Grids... 阅读全文
posted @ 2008-03-04 23:04 万一 阅读(12335) 评论(22) 推荐(1) 编辑
动画演示 Delphi 2007 IDE 功能[5] - 虚拟屏幕
摘要:动画剧本: 通过虚拟屏幕调整窗体运行后的位置; 鼠标对对虚拟屏幕双击放大、再单击会复原; 可以调整对虚拟屏幕的大小; 可以关掉或打开这个虚拟屏幕. 阅读全文
posted @ 2008-03-04 22:38 万一 阅读(6004) 评论(0) 推荐(0) 编辑
Delphi 的字符及字符串[6] - Char(AnsiChar)、WideChar 与其编码的相互转换
摘要://Char 类型与其编码值的转换: var b: Byte; c: Char; begin b := Ord('A'); {返回: 65} b := Ord(#65); {返回: 65} b := Ord($41); {返回: 65} b := Ord(#$41); {返回: 65} b := Byte('A'); {返回: 65} b := ... 阅读全文
posted @ 2008-03-04 11:47 万一 阅读(9870) 评论(16) 推荐(0) 编辑
Delphi 的字符及字符串[5] - 字符串与 Windows API
摘要:Windows API 中的字符串对应这 Delphi 的 PChar(PAnsiChar); 在 API 中使用 Delphi 的字符串还是比较灵活的. 先说赋值: //赋值方法1: 给直接量 begin SetWindowText(Handle, '新标题'); end; //赋值方法2: 定义它要的类型 var p: PChar; begin p := '新标题'; ... 阅读全文
posted @ 2008-03-04 00:28 万一 阅读(8278) 评论(13) 推荐(0) 编辑
Delphi 的字符及字符串[4] - 字符串、字符指针与字符数组
摘要://字符串 字符数组 var arr: array[0..5] of Char; str: string; begin {可以把字符串常量直接赋给字符数组; 但超界不行} arr := 'Delphi'; ShowMessage(arr); {Delphi} {可以把字符数组直接赋给字符串变量} str := arr; ShowMessage(str); {... 阅读全文
posted @ 2008-03-03 22:30 万一 阅读(15868) 评论(24) 推荐(0) 编辑
Delphi 的字符及字符串[3] - String 中的秘密
摘要://String 的指针地址及实际的内存地址 var str: string; pstr: PString; pc: PChar; begin {在没有给 str 赋值以前, 既然声明了, 就有了指针地址(@str):} ShowMessage(IntToStr(Integer(@str))); {1244652; 这是在栈中的 str 的指针地址} {但现在还没有分配... 阅读全文
posted @ 2008-03-03 16:43 万一 阅读(12811) 评论(20) 推荐(0) 编辑
Delphi 的字符及字符串[2] - Char、AnsiChar、WideChar、PChar、PAnsiChar、PWideChar
摘要://单字符 Char、AnsiChar (在目前版本(2007)中, 它们是一回事, 只有 1 字节大小) var c: Char; {Char 类型的取值范围是: #0..#255, 用十六进制表示是: #$0..#$FF} begin {用十进制方式赋值:} c := #65; ShowMessage(c); {A} {用十六进制方式赋值:} c := #$41; ... 阅读全文
posted @ 2008-03-03 16:25 万一 阅读(34309) 评论(43) 推荐(1) 编辑
Delphi 的字符及字符串[1] - string、AnsiString、WideString、String[n]、ShortString
摘要://最常用的 string var str: string; {定义} begin str := '万一'; {赋值} ShowMessage(IntToStr(Length(str))); {长度是: 4} end; //长字符串 AnsiString; 在当前版本(2007)中的默认状态下, String 就是 AnsiString var str: AnsiStri... 阅读全文
posted @ 2008-03-03 16:22 万一 阅读(26820) 评论(13) 推荐(0) 编辑
控件的 Owner 属性演示
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Panel1: TPanel; Button1:... 阅读全文
posted @ 2008-03-02 22:40 万一 阅读(2856) 评论(2) 推荐(0) 编辑
控件的 Parent 属性演示
摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Panel1: TPanel; Button1:... 阅读全文
posted @ 2008-03-02 21:29 万一 阅读(3659) 评论(3) 推荐(0) 编辑