我想列举拨号上网窗体中的控件,一共用到了GetWindow,FindWindow,GetWindowLong      
程序为:      
HWND hWnd=FindWindow(NULL,"连接 拨号连接");      
HWND hWnd1=GetWindow(hWnd,GW_CHILD);      
HWND hWnd2=hWnd1;      
do      
{      
hWnd2=GetWindow(hWnd2,GW_HWNDNEXT);      
dwStyle=GetWindowLong(hWnd2,GWL_STYLE);      
if(dwStyle & ES_PASSWORD){      
cprintf(_T(  "find a passwd edit!\n "));}      
                                             }      
}while(hWnd2!=NULL);      
可是得不到想要的“find a passwd edit”结果,无论我怎样修改都不行,请问应该怎样      
写呀?如果哪位大虾赐教,感激不尽(最好能编译通)      
运行环境:windows2000+vc6.0+ c++source file

解决方案 »

  1.   

    use EnumChildWindows,such as 
    EnumChildWindows(hwnd,EnumChildProc,0);BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) 
    {
    char temp[100];
    memset(temp,0,100);
    GetClassName(hwndChild, temp, sizeof(temp));
    long l =GetWindowLong(hwndChild, GWL_STYLE);
             ...}
      

  2.   

    HWND hWnd=FindWindow(NULL,"连接 拨号连接");
    HWND hwndChild = GetWindow(hWnd,GW_CHILD|GW_HWNDFIRST);
    while(hwndChild != NULL)
    {
       //Do your thing;
       hwndChild = GetWindow(hwndChild,GW_HWNDNEXT);
    }