博文
判断WebBrowser控件是否已经下载完成一个网页(2007-12-11 14:35:00)
摘要:procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);var CurWebrowser: IWebBrowser; TopWebBrowser: IWebBrowser; Document: OleVariant; WindowName: string;begin CurWebrowser := pDisp as IWebBrowser; TopWebBrowser := (Sender as TWebBrowser).DefaultInterface; if CurWebrowser = TopWebBrowser then ShowMessage('Complete document was loaded') else begin Document := CurWebrowser.Document; WindowName := Document.ParentWindow.Name; ShowMessage(Format('Frame "%s" was loaded', [WindowName])); end;end;......
[ZT]Delphi字符串函数3(2007-10-08 14:11:00)
摘要:adjustlinebreaks 函数 将给定字符串的行分隔符调整为cr/lf序列
ansicomparestr 函数 比较字符串(区分大小写)
ansicomparetext 函数 比较字符串(不区分大小写)
ansilowercase 函数 将字符转换为小写
ansiuppercase 函数 将字符转换为大写
chr 函数 返回指定序数的字符
comparestr 函数 比较字符串(区分大小写)
concat 函数 合并字符串
copy 函数 返回一字符串的子串
datetimetostr 函数 将日期时间格式转换为字符串
datetimetostring 函数 将日期时间格式转换为字符串
datetostr 函数 将日期格式转换为字符串
delete 函数 从字符串中删除子串
disposestr 函数 释放字符串在堆栈中的内存空间
expandfilename 函数 返回包含绝对路径的字符串
floattostrf 函数 将浮点数转换为字符串
floattostr 函数 将浮点数转换为字符串
fmtloadstr 函数 从程序的资源字符串表中装载字符串
format 函数 格式化一系列的参数并返回pascal字符串
insert 在字符串中插入子串
inttohex 将整型数转换为十六进制数
inttostr 将整型数转换为字符串
ioresult 返回最新的i/o操作完成状态
isvalidident 测试字符串是否为有效的标识符
length 函数 返回字符串的动态长度
lowercase 函数 将给定的字符串变为小写
newstr 函数 在堆栈上分配新的字符串
pos 函数 在字符串中搜索子串
str 函数 将数值转换为字符串
stralloc 函数 给以null结束的字符串分配最大长度-1的缓冲区
strbufsize 函数 返回存储在由stralloc分配的字符缓冲区的最大字符数
strcat 函数 将一字符串附加到另一字符串尾并返回合并的字符串
strcomp 函数 比较两个字符串
strcopy 函数 将一个字符串复制到另一个字符串中
strdispose 函数 释放堆栈上的字符串
strecopy 函数 ......
[ZT]Delphi字符串函数2(2007-10-08 14:06:00)
摘要: 首部 function AnsiResemblesText(const AText, AOther: string): Boolean; $[StrUtils.pas 功能 返回两个字符串是否相似 说明 ANSI(American National Standards Institute)美国国家标准协会;不区分大小写 参考 function StrUtils.SoundexProc; var StrUtils.AnsiResemblesProc 例子 CheckBox1.Checked := AnsiResemblesText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━━━━━━━━━━━ 首部 function AnsiContainsText(const AText, ASubText: string): Boolean; $[StrUtils.pas 功能 返回字符串AText是否包含子串ASubText 说明 不区分大小写 参考 function StrUtils.AnsiUppercase; function StrUtils.AnsiPos 例子 CheckBox1.Checked := AnsiContainsText(Edit1.Text, Edit2.Text); ━━━━━━━━━━━......
[ZT]Delphi字符串函数1(2007-10-08 14:03:00)
摘要: 首部 function CharLength(const S: String; Index: Integer): Integer; $[SysUtils.pas 功能 返回字符串中指定位置的字符宽度 说明 CharLength(‘English汉‘, 1) = 1;CharLength(‘English汉‘, 8) = 2 参考 function System.Assert;function SysUtils.StrCharLength 例子 SpinEdit1.Value := CharLength(Edit1.Text, SpinEdit2.Value); ━━━━━━━━━━━━━━━━━━━━━ 首部 function NextCharIndex(const S: String; Index: Integer): Integer; $[SysUtils.pas 功能 返回下一个字符的位置 说明 CharLength(‘你好‘, 1) = 3;CharLength(‘你好‘, 3) = 5 参考 function System.Assert;function SysUtils.StrCharLength 例子 SpinEdit1.Value := NextCharIndex(Edit1.Text, SpinEdit2.Value);  ......
[ZT]程序只允许运行一个实例的三种例子(2007-08-31 17:23:00)
摘要:程序只允许运行一个实例的三种例子
一:互斥体
program test;uses Windows;
var MutexHandle: Longword;
begin if OpenMutex(MUTEX_ALL_ACCESS, FALSE, 'test')=0 then begin MutexHandle := CreateMutex(nil,TRUE,'test'); //创建一个互斥体,禁止重复运行 MessageBox(0, pchar('try run another?'), pchar('It Works'), 0); ReleaseMutex(MutexHandle); //关闭互斥体 end;end.
异常退出了,互斥体还不消失
二:全局原子
program test;
Uses Windows
const iAtom=‘SingleApp’;
begin if GlobalFindAtom(iAtom)=0 then begin GlobalAddAtom(iAtom); MessageBox(0, pchar('only 1'), pchar('It Works'), 0); GlobalDeleteAtom(GlobalFindAtom(iAtom)); end;end.
三:内存影射
除了能保存全局变量,还可以唯一标志,但异常退出的话也不能消失
program test;
Uses Windows
var hMappingFile: THandle; ......
在DELPHI中实现控件的多样性编程(2007-07-23 14:00:00)
摘要:用delphi也可以象C++一样,通过定义类,派生,重写函数等,制作出具控件有多样性的程序来,下面是一个文本编辑器的编程笔记。
定义一个接口类(祖先),只有定义而没有任何实际内容的类,所有实际的控件的类都从它那里派生,它不能用来产生具体的控件。例子:unit IddEditor;interface
uses Controls,Graphics;
type Idd_Editor=classPublicFunction Save():boolean;Virtual;abstract;//纯虚函数,用于给继承者重写,并且没有任何内容Procedure Copy(); Virtual;abstract;Function CanCopy():boolean; Virtual;abstract;Procedure SelectAll(); Virtual;abstract;end;
implementation
end.
从接口类可以派生出具体一点的类了(父亲),(当然接口类也会派生出其他的类,这些类之间由于拥有共同的祖先,所以沟通成为可能)父亲把接口类的纯虚函数内容定义具体,同时也根据需要,生成一些新的虚函数,父亲把自己能做的都摆出来了,但是具体怎么做,留给儿子们去重写吧。例子:unit Editor;
interface
uses Controls,Graphics,Classes,IddEditor;
type
TddEditor=Class(Idd_Editor) Private m_FileName:string;//多了一个成员变量,用来记录文件名字 Protected Procedure OnEditorSelectionChange(Sender:Tobject);//这是这个类自己特有的函数 Function GetText():String;Virtual;abstract;//新增加的纯虚函数 Public Constructor Create(ParentCtrl:TwinControl);//构造函数,是必须的 &nbs......
