在CB中怎样检查一个form是否已被打开?

guorui 2001-11-22 11:48:44
刚学CB两星期,很多都不明白,所以请多指教。
1.在CB中怎样检查一个form是否已被打开?

2.另上次在论坛中看到findWindow(),但我在CB的帮助中却
没有查到这个function.
请问怎样才能得到它的用法呢?
(22分是我可以给的最高分啦!)
...全文
83 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
guorui 2001-11-22
  • 打赏
  • 举报
回复
谢谢两位的热情帮助。
每人11分如何?
bitfan 2001-11-22
  • 打赏
  • 举报
回复
何必如此麻烦?
给你一段简单的代码一次搞掂:
bool FormExist=false;
int i;
for(i=0;i<Screen->FormCount;i++)
{
if(Screen->Forms[i]->Name=="窗体的Name属性值")
{
FormExist=True;
break;
}
}
if(FormExist) //已打开了
{
Screen->Forms[i]->BringToFront();
Screen->Forms[i]->WindowState =wsMaximized;//使窗体最大化
return ;
}
gloom 2001-11-22
  • 打赏
  • 举报
回复
FindWindow
````````````````````````````````
The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows.

HWND FindWindow(

LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);


Parameters

lpClassName

Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero.

lpWindowName

Points to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.



Return Values

If the function succeeds, the return value is the handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.


FindWindowEx
``````````````````````
Now Supported on Windows NT]

The FindWindowEx function retrieves the handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the given child window.

HWND FindWindowEx(

HWND hwndParent, // handle to parent window
HWND hwndChildAfter, // handle to a child window
LPCTSTR lpszClass, // pointer to class name
LPCTSTR lpszWindow // pointer to window name
);


Parameters

hwndParent

Identifies the parent window whose child windows are to be searched.
If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop.

hwndChildAfter

Identifies a child window. The search begins with the next child window in the Z order. hwndChildAfter must be a direct child window of hwndParent, not just a descendant window.
If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level windows.

lpszClass

Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpszClass; the high-order word must be zero.

lpszWindow

Points to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.



Return Values

If the function succeeds, the return value is the handle to the window that has the specified class and window names.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
gloom 2001-11-22
  • 打赏
  • 举报
回复
看看Form->Visible是否是true;
Help->Windows SDK

前提是你在安装时选择安装了Win32 Help,否则只有重新安装HELP或找其它WIN API资料了。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧