新建一程序
添加 PageControl控件
在PageControl1上添加5个页面
在每个页面上添加一个ListView控件
在主窗体上添加一个button按钮
代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
ListView1: TListView;
ListView2: TListView;
ListView3: TListView;
ListView4: TListView;
ListView5: TListView;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure lvadd;
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.lvadd;
var
i : integer;
begin
for i := 1 to 50 do
begin
with Form1.ListView1.Items.Insert(Form1.ListView1.Items.Count) do
begin
Caption := '1首'+IntToStr(i);
SubItems.Insert(0,'1次'+IntToStr(i));
SubItems.Insert(1,'1中'+IntToStr(i));
SubItems.Insert(2,'1末'+IntToStr(i));
SubItems.Insert(3,'1尾'+IntToStr(i));
end;
with Form1.ListView2.Items.Insert(Form1.ListView2.Items.Count) do
begin
Caption := '2首'+IntToStr(i);
SubItems.Insert(0,'2次'+IntToStr(i));
SubItems.Insert(1,'2中'+IntToStr(i));
SubItems.Insert(2,'2末'+IntToStr(i));
SubItems.Insert(3,'2尾'+IntToStr(i));
end;
with Form1.ListView3.Items.Insert(Form1.ListView3.Items.Count) do
begin
Caption := '3首'+IntToStr(i);
SubItems.Insert(0,'3次'+IntToStr(i));
SubItems.Insert(1,'3中'+IntToStr(i));
SubItems.Insert(2,'3末'+IntToStr(i));
SubItems.Insert(3,'3尾'+IntToStr(i));
end;
with Form1.ListView4.Items.Insert(Form1.ListView4.Items.Count) do
begin
Caption := '4首'+IntToStr(i);
SubItems.Insert(0,'4次'+IntToStr(i));
SubItems.Insert(1,'4中'+IntToStr(i));
SubItems.Insert(2,'4末'+IntToStr(i));
SubItems.Insert(3,'4尾'+IntToStr(i));
end;
with Form1.ListView5.Items.Insert(Form1.ListView5.Items.Count) do
begin
Caption := '5首'+IntToStr(i);
SubItems.Insert(0,'5次'+IntToStr(i));
SubItems.Insert(1,'5中'+IntToStr(i));
SubItems.Insert(2,'5末'+IntToStr(i));
SubItems.Insert(3,'5尾'+IntToStr(i));
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
hh : THandle;
Id : DWord;
begin
hh := Windows.CreateThread(nil,0,@TForm1.lvadd,nil,0,Id);
Windows.CloseHandle(hh);
end;end.
奇怪的问题就是PageControl1的5个页面,在程序打开时直接点BUTTON1 你看下PageControl1的其他页面 不显示了!!而且在关闭的时候会提示一堆错误!!
如果在程序打开后 先把5个页面都点一下,然后在点BUTTON1 就正常了.不用线程的话就没有这个问题.现在就是想用线程添加数据呀,因为数据比较多呀.所以 这个问题要解决,各位朋友帮忙看看 什么原因?或怎么解决?
添加 PageControl控件
在PageControl1上添加5个页面
在每个页面上添加一个ListView控件
在主窗体上添加一个button按钮
代码如下:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
ListView1: TListView;
ListView2: TListView;
ListView3: TListView;
ListView4: TListView;
ListView5: TListView;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure lvadd;
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.lvadd;
var
i : integer;
begin
for i := 1 to 50 do
begin
with Form1.ListView1.Items.Insert(Form1.ListView1.Items.Count) do
begin
Caption := '1首'+IntToStr(i);
SubItems.Insert(0,'1次'+IntToStr(i));
SubItems.Insert(1,'1中'+IntToStr(i));
SubItems.Insert(2,'1末'+IntToStr(i));
SubItems.Insert(3,'1尾'+IntToStr(i));
end;
with Form1.ListView2.Items.Insert(Form1.ListView2.Items.Count) do
begin
Caption := '2首'+IntToStr(i);
SubItems.Insert(0,'2次'+IntToStr(i));
SubItems.Insert(1,'2中'+IntToStr(i));
SubItems.Insert(2,'2末'+IntToStr(i));
SubItems.Insert(3,'2尾'+IntToStr(i));
end;
with Form1.ListView3.Items.Insert(Form1.ListView3.Items.Count) do
begin
Caption := '3首'+IntToStr(i);
SubItems.Insert(0,'3次'+IntToStr(i));
SubItems.Insert(1,'3中'+IntToStr(i));
SubItems.Insert(2,'3末'+IntToStr(i));
SubItems.Insert(3,'3尾'+IntToStr(i));
end;
with Form1.ListView4.Items.Insert(Form1.ListView4.Items.Count) do
begin
Caption := '4首'+IntToStr(i);
SubItems.Insert(0,'4次'+IntToStr(i));
SubItems.Insert(1,'4中'+IntToStr(i));
SubItems.Insert(2,'4末'+IntToStr(i));
SubItems.Insert(3,'4尾'+IntToStr(i));
end;
with Form1.ListView5.Items.Insert(Form1.ListView5.Items.Count) do
begin
Caption := '5首'+IntToStr(i);
SubItems.Insert(0,'5次'+IntToStr(i));
SubItems.Insert(1,'5中'+IntToStr(i));
SubItems.Insert(2,'5末'+IntToStr(i));
SubItems.Insert(3,'5尾'+IntToStr(i));
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
hh : THandle;
Id : DWord;
begin
hh := Windows.CreateThread(nil,0,@TForm1.lvadd,nil,0,Id);
Windows.CloseHandle(hh);
end;end.
奇怪的问题就是PageControl1的5个页面,在程序打开时直接点BUTTON1 你看下PageControl1的其他页面 不显示了!!而且在关闭的时候会提示一堆错误!!
如果在程序打开后 先把5个页面都点一下,然后在点BUTTON1 就正常了.不用线程的话就没有这个问题.现在就是想用线程添加数据呀,因为数据比较多呀.所以 这个问题要解决,各位朋友帮忙看看 什么原因?或怎么解决?
解决方案 »
- dxDBGrid中如何让被选中(locate)的行出现整行高亮的效果?
- 兄弟们是否知道WebBrowser已经显示好的页面转换成图片的方法,我阅读网络杂志想复制下来几页以后看。
- 超级简单的问题!!XMLDocument加载一次以后如何清空?
- 如何实现类似Visio的那种流程图,高手请进,分不够可加
- 如何将数据库中的纪录一条一条读出?
- 大家好!
- Delphi中有关Tcombox控件的问题~
- 关于用InstallShield Express制作安装文件的请教!!!
- 哪位仁兄有FOXPRO2。6 的反编工具请来一份,谢谢,[email protected]
- 快來拿分﹗
- ClientDataSet,DataSource,DataSetProvider这3个控件怎么用
- 问个基础问题FORM1,FORM2互相USES的问题
TabSheet4.Show;
TabSheet3.Show;
TabSheet2.Show;
TabSheet1.Show;这样就不会有问题了,但是想知道为什么??
...
...
s := xxxxxxx;
postmessage(formhandle,WM_MYMSG,0,Integer(PChar(s)));
...
...主窗体消息处理过程:
procedure WNMYMSG(var msg: TMessage);
var s: string;
begin
s := StrPas(Pchar(PInteger(msg.lparam)^));
memo1.lines.add(s);
end;
或者你就用Synchronize;具体使用方法看看书吧~~涉及到界面操作的,需要同步处理……-_-!!! 这20分挣的,费了老劲了
var
s:char;
p:^Char;
begin
s := char('s');
p := @s;
end;
这个P 怎么看它地址??
showmessage(strpas(pchar(@s)));