为什么 IsWindowVisible 使 EnumDesktopWindows 的回调只运行一次? [英] Why IsWindowVisible makes callback of EnumDesktopWindows runs only once?

查看:29
本文介绍了为什么 IsWindowVisible 使 EnumDesktopWindows 的回调只运行一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请看下面的代码.

MyEnumProc 仅使用以下代码运行一次.但是如果我注释掉 IsWindowVisible(wnd);,它会运行很多次.

The MyEnumProc runs only one time with the following code. But if I commented out the IsWindowVisible(wnd);, it runs many times.

为什么 IsWindowVisible 会发生这种情况(只运行一次)?我以为 IsWindowVisible 只是一个检查 wnd 属性的函数?

Why IsWindowVisible make this happened(run only one time)? I thought IsWindowVisible just a function to check the wnd's attributes?

test.c 的代码:

codes of test.c:

#include <windows.h>
#include <stdio.h>
BOOL CALLBACK MyEnumProc( HWND wnd, LPARAM lParam )
{
    printf("run\n");
    IsWindowVisible(wnd);
}

int main( void )
{
    EnumDesktopWindows( NULL, MyEnumProc, 0 );
    printf("end\n");
    return 0;
}

我的环境是:

Windows XP SP3.

Windows XP SP3.

gcc 3.4.6(mingw)

gcc 3.4.6(mingw)

编译选项为:gcc -o test.exe test.c

compiled option is: gcc -o test.exe test.c

我编译并运行了 cmd.exe 中的 test.exe.

I did the compile and run the test.exe in the cmd.exe.

推荐答案

EnumDesktopWindows 期望您从 MyEnumProc 返回一个值:

EnumDesktopWindows expects you to return a value from your MyEnumProc:

return TRUE;

阅读文档了解更多信息.

Read the documentation for more information.

这篇关于为什么 IsWindowVisible 使 EnumDesktopWindows 的回调只运行一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆