我已经明白各个参数的意义,可是还是不会用。比方说是要在一个循环中调用EnumChildWindows么,有没有例子可以共享一下,谢谢了。我的目的是找到另外一个程序上的某个按钮的句柄,那我怎么确定现在搜到的就是我要找到的按钮呢,请高手指点啊。我QQ252726667,希望给我仔细讲解一下,谢谢了

解决方案 »

  1.   

    唉,又是一声叹息。为什么就不去查查MSDN呢?MSDN上的例子最能说明问题了。        case WM_SIZE:   // main window changed size 
     
                // Get the dimensions of the main window's client 
                // area, and enumerate the child windows. Pass the 
                // dimensions to the child windows during enumeration. 
     
                GetClientRect(hwnd, &rcClient); 
                EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient); 
                return 0;  
    BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) 

        LPRECT rcParent; 
        int i, idChild; 
     
        // Retrieve the child-window identifier. Use it to set the 
        // position of the child window. 
     
        idChild = GetWindowLong(hwndChild, GWL_ID); 
     
        if (idChild == ID_FIRSTCHILD) 
            i = 0; 
        else if (idChild == ID_SECONDCHILD) 
            i = 1; 
        else 
            i = 2; 
     
        // Size and position the child window.  
     
        rcParent = (LPRECT) lParam; 
        MoveWindow(hwndChild, 
                   (rcParent->right / 3) * i, 
                   0, 
                   rcParent->right / 3, 
                   rcParent->bottom, 
                   TRUE); 
     
        // Make sure the child window is visible. 
     
        ShowWindow(hwndChild, SW_SHOW); 
     
        return TRUE;
    }
      

  2.   

    不需要循環。要做你的事情,首先要知道你如何判斷是你要的按鈕,比如可能是按鈕的caption
    void find_button()
    {
    // hwnd is the handle of the parent
    // lpsz is the caption of the button
    EnumChildWindows(hwnd, EnumChildProc, (LPARAM)lpsz ); 
    }// callback
    BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) 
    {
    // GetWindowText 獲取子窗口Caption,與lParam比較,如果匹配,則是目標窗口,返回FALSE中止查找 return TRUE; // 繼續枚舉子窗口
    }
      

  3.   

    我也想看MSDN,可是我电脑上没有啊,安装比较麻烦,我没有,请赐给一个啊
      

  4.   

    可以上网吗?(废话):http://msdn.microsoft.com/zh-cn/default.aspx