我在有些delphi经典示例中经常看到一个现象,我无法完全理解,所以想请教请教大家.
程序中声明了一个TServerSocket(stThreadBlocking)实例,当触发GetThread事件后在ClientExecute中同步执行在窗体的ListView中添加该线程.主要代码如下:
procedure TfrmMain.AddClient(Thread: TServerClientThread);
var
Item: TListItem;
begin
Item := ConnList.Items.Add;
Item.Caption := IntToStr(Thread.ClientSocket.LocalPort);
Item.SubItems.Add(Thread.ClientSocket.RemoteAddress);
if AShowHost.Checked then
begin
Item.SubItems.Add(Thread.ClientSocket.RemoteHost);
if Item.SubItems[1] = '' then Item.SubItems[1] := SHostUnknown;
end else
Item.SubItems.Add(SNotShown);
if Thread is TServSocketThread then
begin
Item.SubItems.Add(DateTimeToStr(TServSocketThread(Thread).LastActivity));
end;
Item.Data := Pointer(Thread);
UpdateStatus;
end;代码中最后第五行为什么不用Thread.LastActivity来引用属性呢?
程序中声明了一个TServerSocket(stThreadBlocking)实例,当触发GetThread事件后在ClientExecute中同步执行在窗体的ListView中添加该线程.主要代码如下:
procedure TfrmMain.AddClient(Thread: TServerClientThread);
var
Item: TListItem;
begin
Item := ConnList.Items.Add;
Item.Caption := IntToStr(Thread.ClientSocket.LocalPort);
Item.SubItems.Add(Thread.ClientSocket.RemoteAddress);
if AShowHost.Checked then
begin
Item.SubItems.Add(Thread.ClientSocket.RemoteHost);
if Item.SubItems[1] = '' then Item.SubItems[1] := SHostUnknown;
end else
Item.SubItems.Add(SNotShown);
if Thread is TServSocketThread then
begin
Item.SubItems.Add(DateTimeToStr(TServSocketThread(Thread).LastActivity));
end;
Item.Data := Pointer(Thread);
UpdateStatus;
end;代码中最后第五行为什么不用Thread.LastActivity来引用属性呢?
解决方案 »
- 为什么dbgrid放入Tpagecontrol中无数据显示的
- 请高手指教将如下函数声明变成delphi的函数声明,谢谢
- 编写一个Label组件
- 快郁闷死了!!!快点来救我啊。
- 碰到一打印问题,请大虾们帮忙.(delphi调用EXCEL)
- 完整的程序文件
- 请教一个问题:当Timer.Enalbed:=True时,OnTimer过程是怎么工作的???
- 关于窗口隐藏
- 请问广州哪个书店提供网上订购李维的《Delphl5.x ADO/MTS/CoM+高级程序设计篇》?
- 如何让 insert into 插入的纪录在最后(相当与append)
- 在哪里可以下载比较新的ziptv控件
- 圣诞节快乐 ,下班后跟女朋友看<功夫>哈哈 散100分 ,什么?太小气!不回吧..........
////// 看这句
LastActivity是这个线程类的用户定义属性..而传入参数类型是TServerClientThread,
Thread: TServerClientThread它自已是没有LastActivity属性..