HWND FindWindow( LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);
我的程序是
if FindWindow('progman',nil)<>0 then
begin
代码
end
运行正常 托盘可以看到图标
但我改为
if FindWindow('aaa',nil)<>0 then
begin
代码
end
随便的一个字符 托盘就看不到图标了
为什么呢
LPCTSTR lpWindowName // pointer to window name
);
我的程序是
if FindWindow('progman',nil)<>0 then
begin
代码
end
运行正常 托盘可以看到图标
但我改为
if FindWindow('aaa',nil)<>0 then
begin
代码
end
随便的一个字符 托盘就看不到图标了
为什么呢
解决方案 »
- 也许Delphi的春天不会再有,但它的秋天,还很长很长
- 帮我一下吧,大家们!关于读取URL不假死问题!
- 笨蛋问:如何把123456789转换成ABCDEFGHI?
- 有关数据插入问题
- DELPHI中代码编写有什么比较好的技巧?怎么自动弹出子对象或它的属性值选择的菜单?
- 【MIDAS问题醒目】动态库DLL中使用tSocketconnection,你用过没有
- delphi7中没有SOCKET控件??
- 在窗口中绘图,我这样使用 bitblt 函数 为什么没有任何效果?
- 用触发器能实现这样的业务吗?
- 请问怎样检测多余的DLL文件,并且删除多余的DLL文件?请举例说明。100分
- 如何限制DELPHI程序运行次数?
- 关于StringGrid的问题
LPCTSTR lpWindowName // pointer to window name
);
ParameterslpClassNamePoints 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. lpWindowNamePoints to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.
lpClassName, {窗口的类名}
lpWindowName: PChar {窗口的标题}
): HWND; {返回窗口的句柄; 失败返回 0}//FindWindowEx 比 FindWindow 多出两个句柄参数:
FindWindowEx(
Parent: HWND; {要查找子窗口的父窗口句柄}
Child: HWND; {子窗口句柄}
ClassName: PChar; {}
WindowName: PChar {}
): HWND;
{
如果 Parent 是 0, 则函数以桌面窗口为父窗口, 查找桌面窗口的所有子窗口;
如果 是 HWND_MESSAGE, 函数仅查找所有消息窗口;
子窗口必须是 Parent 窗口的直接子窗口;
如果 Child 是 0, 查找从 Parent 的第一个子窗口开始;
如果 Parent 和 Child 同时是 0, 则函数查找所有的顶层窗口及消息窗口.
}
--------------------------------------------------------------------------------//测试1: 试着找找新建程序主窗口的句柄
var
h: HWND;
begin
{现在我们知道窗口的标题是: Form1、窗口的类名是: TForm1}
h := FindWindow('TForm1', 'Form1');
ShowMessage(IntToStr(h)); {656180; 这是随机, 每次启动窗口肯定不一样} {假如不知道类名}
h := FindWindow(nil, 'Form1');
ShowMessage(IntToStr(h)); {656180} {假如不知道标题名}
h := FindWindow('TForm1', nil);
ShowMessage(IntToStr(h)); {656180} {其实这个窗口的句柄不就是 Self.Handle 吗}
ShowMessage(IntToStr(Handle)); {656180}
end;
--------------------------------------------------------------------------------//测试2: 找计算器窗口的句柄(先打开计算器)
var
h: HWND;
begin
{如果不是简体中文系统, 这样可能不灵}
h := FindWindow(nil, '计算器');
ShowMessage(IntToStr(h)); {1508334} {最好这样, 但你得提前知道计算器窗口的类名是: SciCalc}
h := FindWindow('SciCalc', nil);
ShowMessage(IntToStr(h)); {1508334}
end;