如何列出某个项目中的所有窗体的名称?(10分)

J

jybd

Unregistered / Unconfirmed
GUEST, unregistred user!
如何获得本项目的所有窗体的名称,最好能将他的caption显示出来!我下面列出了两种方法:
一、for i:=0 to Application.ComponentCount-1 do
begin
CheckListBox1.Items.Add(Application.Components.Name)
end;

二、for i:=0 to Screen.FormCount-1 do
begin
CheckListBox1.Items.Add(Screen.Forms.Name);
end;
以上两种方法得出的结果都是一样的只能列出系统中自动创建的窗体,若需要程序控制创建的窗体就不能列出来!而且列出的都是窗体的名称name,而不是caption!希望大虾们能帮我解决以上两个问题:1、列出系统中非自动创建的窗体;2、将窗体的caption列出!
 
先列出系统中的所有窗体句柄,然后依次得到每个窗体的caption
 
lhlh_0_0:
你好!我现在的关键问题也就是你所说的“先列出系统中的所有窗体句柄”,现在我不知
如何获得项目中的所有窗体的句柄,我用api函数getwindow等函数多不行,不知你知道还有
其他函数没有?请指教!
 
没人懂吗?
高手赐教!
 
procedure TForm1.Button1Click(Sender: TObject);
var
first:hwnd;
cption:pchar;
begin
getmem(cption,255);
first:=gettopwindow(0);
getwindowtext(first,cption,255);
memo1.Lines.Add(string(cption));
while first<>0 do
begin
first:=getnextwindow(first,GW_HWNDNEXT);
getwindowtext(first,cption,255);
memo1.Lines.Add(string(cption));
end;
freemem(cption);
end;
仅供参考
 
The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window.

LONG GetWindowLong(

HWND hWnd, // handle of window
int nIndex // offset of value to retrieve
);


Parameters

hWnd

Identifies the window and, indirectly, the class to which the window belongs.

nIndex
 
to:jybd,我不知道你的具体意思,是不是上面的程序不能以项目为界将窗体区别开来呢。
 
你修改form的create/free的方法,增加一个保存的小动作不就行了,

偶只会说,不会做哦
 
顶部