delphi中application.processmessages的作用
delphi中application.processmessages的作用
procedure TForm1.Button2Click(Sender: TObject);
var
I, J, X, Y: Word;
begin
I := 0;
J := 0;
while I < 64000 do
begin
Randomize;
while J < 64000 do
begin
Y := Random(J);
Inc(J);
Application.ProcessMessages;
end;
X := Random(I);
Inc(I);
end;
Canvas.TextOut(10, 10, 'The Button2Click handler is finished');
end;
代码中红色的一行的作用:
如果你运行一个非常耗时的循环,那么在这个循环结束前,你的程序可能不会响应任何事件,你按按钮没有反应,程序设置无法绘制窗体,看上去就如同死了一样,
这有时不是很方便,例如于终止循环的机会都没有了。这时你就可以在循环中加上这么一句,每次程序运行到这句时,程序就会让系统响应一下消息,从而使你有机
会按按钮,窗体有机会绘制。
相关文档:
procedure TForm_BaseMDI.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SendMessage(Handle, 48384, 9, 0);
end;
end; ......
Borland出品的Delphi,有着闪电般的编译速度,但是在界面控件使用较多、工程项目较大的时候,编译一个工程仍需要一段时间,打开庞大的Delphi IDE,也需要时间。其实,在一个工程开发结束,调试完成之后的Release编译,完全可以用命令行来执行,因为Delphi的编译器参数不像C++编译器那样复杂。
笔者把Delphi联机手册 ......
关于IntraWeb程序在编译时出现错误的解决方法
错误提示:[Error] IWLicenseKey.pas(12): Undeclared identifier: 'SetLicenseKey'
处理方法:进入菜单Tools->Environment Options,选择‘Library’,将'Library path'参数中有关intraweb的目录放在前面即可。
使用&n ......
program PureAPIWindow;
uses
SysUtils,
Windows,
Messages;
const
WinClassName = 'DvsClass';
StrOut = 'Davis TextOut';
//窗口回调函数
function MyWinProc(
hWindow: HWND;
aMessage: UINT;
WParam: WPARAM;
LParam: LPARAM): LRESULT; stdcall; export;
......
http://developer.51cto.com/art/200510/7205.htm
[DELPHI]网络邻居复制文件
uses shellapi;
copyfile(pchar('newfile.txt'),pchar('//computername/direction/targer.txt'),false);
[DELPHI]产生鼠标拖动效果
通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL:
var xpanel,ypanel,xlabel,yla ......