在delphi7.0下如何判断窗体是否已加载
编号:QA004668
建立日期: 2003年1月4日 最后修改日期:2003年7月27日
所属类别:
Q
zyl:
操作系统: pwin2000
编程工具: delphi7.0
问题: 请问在delphi7.0下如何判断窗体是否已加载?
A回答:
没有直接的函数,不过Screen.Forms可能能帮助你。下面的例子在主窗体的菜单添加所有显示的窗体的名字:
var
NewItem: TMenuItem;
I : integer;
begin
{ first create the separator }
NewItem := TMenuItem.Create(Self);
NewItem.Caption := '-';
{ add the new item to the Windows menu }
Windows.Add(NewItem);
{ now create and add a menu item for each form }
for I := 0 to Screen.FormCount-1 do
begin
NewItem := TMenuItem.Create(Self);
NewItem.Caption := Screen.Forms[I].Name;
Windows.Add(NewItem);
end;
end;
远志的意见:
好像可以用一个API函数就可以了
BOOL IsWindow(
HWND hWnd //handle to window
);
如果窗体存在则返回True
另外你好可以通过以下的几个API判断窗体的状态
BOOL IsZoomed(
HWND hWnd // handle to window
);最大
BOOL IsWindowVisible(
HWND hWnd // handle to window
);可见
BOOL IsIconic(
HWND hWnd // handle to window
);最小
具体使用方法可以查MSDN。
此问题由李海回答。
附加关键字:编程, 源程序, programming, source code, Delphi, VCL, Borland, 窗体与菜单, form, window, tform。
| |
|
|
| |
|
|