:< 怎么没有人回答 (急)关于数据库和线程的问题,各位大富翁请进! (50分)

D

delhong

Unregistered / Unconfirmed
GUEST, unregistred user!
我在作一个多用户的图书馆管理系统,想实现当某一用户登录后
他所打开的form的caption显示他的代号(或姓名),我采用线程
来解决,我只知道如何改变一个form的caption,但我不知道如何
动态的改变多个form的caption,所以想象大家学习,请帖出你的
方法,谢谢给位高手.

type
tusenumthread = class(TThread)
private
{ Private declarations }
newcaption:string;
protected
procedure Execute; override;
procedure updatecaption;
end;

implementation
uses unit1,unit7,unit4,unit8,unit9,unit10;

procedure tusenumthread.Execute;
var num:string;
begin
{ Place thread code here }
while not terminated do
begin
num:='';
with unit2.DataModule2.tstudent do
begin
open;
first;
while not eof do
begin
num:=fieldbyname('snum').asstring;
end;
close;
end;
newcaption:='谢谢'+num+'的使用';
synchronize(updatecaption);
suspend;
end;
end;

procedure tusenumthread.updatecaption;
begin
form1.Caption :=newcaption;
end;

end.


这是我的执行线程句子
procedure TForm8.FormCreate(Sender: TObject);
var i:integer;
datethread:tusenumthread;
begin
datethread:=tusenumthread.Create(true) ;
unit2.DataModule2.qylib.close;
edit3.Text :=datetostr(date);
combobox1.Items.Clear;
combobox2.Items.Clear;
...................
end;
 
试试看:
//uses Forms;

procedure tusenumthread.updatecaption;
var
I: Integer;
begin
with Application do
for I:= 0 to ComponentCount -1 do
if Components is TCustomForm then
begin
TCustomForm(Components).Caption := NewCaption;
end;
end;
 
或者:
procedure tusenumthread.updatecaption;
begin
form1.Caption :=newcaption;
form2.Caption :=newcaption;
form3.Caption :=newcaption;
...
end;
 
to huzzz:
谢谢您的解答,我试过,一个都不行,我现在在看MIDAS,由于我也是自学的还没学到MIDAS
这来,谢谢你,如果你好有好的答案,请帖上来好吗?再次感谢
 
顶部