我想知道该函数的详细用法
还有第2个参数指向的回调函数在什么情况下会被调用。

解决方案 »

  1.   

    BOOL EnumChildWindows(
      HWND hWndParent,         // 已经获得的父窗口句柄。
      WNDENUMPROC lpEnumFunc,  // 回调函数地址。
      LPARAM lParam            // 自定义值
    );BOOL CALLBACK EnumChildProc(
      HWND hwnd,      // 子窗口句柄。
      LPARAM lParam   // 前面的自定义值。
    );加入已经获得了一个主窗口:hWnd,编写代码:
    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
    {
        //对窗口做出判断的代码
        return TRUE; //继续枚举,FALSE 停止.
    }
    EnumChildWindows(hWnd, EnumChildProc, 0);
      

  2.   

    例子:function EnumerateChildWindows(hWnd:HWND; lParam:LPARAM): BOOL; stdcall;var
      Form1: TForm1;implementationprocedure TForm1.EnumerateChildWindows1Click(Sender: TObject);
    begin
       {empty our list box}
       ListBox1.Items.Clear;   {enumerate all child windows belonging to Form1}
       EnumChildWindows(Form1.Handle,@EnumerateChildWindows,0);end;{these steps execute for every child window belonging to the parent}
    function EnumerateChildWindows(hWnd: HWND; lParam: LPARAM): BOOL;
    var
       ClassName: Array[0..255] of char;  // this holds the class name of our child windows
    begin
       {get the class name of the given child window}
       GetClassName(hWnd,ClassName,255);   {display it in the list box}
       Form1.ListBox1.Items.Add(ClassName);   {continue enumeration}
       Result:=TRUE;
    end;
    Re: 关于EnumChildWindows的用法!
    ID=230963, 发贴富翁: Billy, 2000-04-25 15:56:00 
    定义一个回调函数:
    function EnumChildProc(Myhwnd: HWND; lParam: LPARAM): Boolean;stdCall;
    begin
      //你的代码  
      Result:=False;//设为True则停止
    end;
    在程序中调用:
    enumchildwindows(hWndProgram,@EnumChildProc,0);//hWndProgram为父窗口的句柄
      

  3.   

    BOOL EnumChildWindows(    HWND hWndParent, // parent窗体的句柄
        WNDENUMPROC lpEnumFunc, // 回调函数
        LPARAM lParam  // 参数
       );BOOL CALLBACK EnumChildProc(    HWND hwnd, // 找到的窗体的句柄
        LPARAM lParam  // 参数(由EnumChildWindows传来的)
       );
    当找到窗体时调用回调函数,利用lparam可以传递任何东西,就当作指针用吧
      

  4.   

    yansea(思宏) 的代码简洁明了,先给一半分给你,接下的第2个问题就是 还有第2个参数指向的回调函数在什么情况下会被调用。是不是当EnumChildWindows函数执行的时候就顺便执行了EnumChildProc