你创建的IDD_Dialog1对话框,调用的实例如果是dlg
就用dlg.GetDlgItem(控件ID)
如果实例是指针,就用dlg->GetDlgItem(控件ID)
还有一个更加万能的方法,就是从桌面开始一层一层的找你要找的窗口句柄,提供一段代码供参考:
hWnd = ::GetWindow( ::GetDesktopWindow(), GW_CHILD );
while ( hWnd != NULL)
{
memset( szTittleInfo , NULL , 255 );
::GetWindowText( hWnd, szTittleInfo , 255 );
szInfo.Format( "%s" , szTittleInfo ) ;
if( szInfo.GetLength() > 0 )
{
if( szInfo.CompareNoCase( "YabooPanoramic - [四分镜头]") == 0 )
{
TarghWnd = hWnd ;
break ;
}
}
hWnd =::GetWindow( hWnd , GW_HWNDNEXT );
}

if( TarghWnd == NULL && m_CameraNo < 5 && m_nRunMode == 1 )
{
AfxMessageBox( "没有找到应用程序!" );

OnOK();
//return FALSE ;

return TRUE ;
}

m_AppHWnd = TarghWnd ;

//MdiClient ;
hWnd = ::GetWindow( TarghWnd , GW_CHILD );
//子框架句柄
hWnd = ::GetWindow( hWnd , GW_CHILD );
//视图句柄
TarghWnd = ::GetWindow( hWnd , GW_CHILD );

int nValue ;
hWnd = ::GetWindow( TarghWnd , GW_CHILD );
while( hWnd != NULL )
{
szInfo.Format( "%d" , hWnd ) ;
nValue = atoi( szInfo );
if( nValueA == nValue )
{
m_wndCameraA = hWnd ;
break ;
}
hWnd = ::GetWindow( hWnd , GW_HWNDNEXT );
}

hWnd = ::GetWindow( TarghWnd , GW_CHILD );
while( hWnd != NULL )
{
szInfo.Format( "%d" , hWnd ) ;
nValue = atoi( szInfo );
if( nValueB == nValue )
{
m_wndCameraB = hWnd ;
break ;
}

hWnd = ::GetWindow( hWnd , GW_HWNDNEXT );
}

hWnd = ::GetWindow( TarghWnd , GW_CHILD );
while( hWnd != NULL )
{
szInfo.Format( "%d" , hWnd ) ;
nValue = atoi( szInfo );
if( nValueA2 == nValue )
{
m_wndCameraA2 = hWnd ;
break ;
}
hWnd = ::GetWindow( hWnd , GW_HWNDNEXT );
}

hWnd = ::GetWindow( TarghWnd , GW_CHILD );
while( hWnd != NULL )
{
szInfo.Format( "%d" , hWnd ) ;
nValue = atoi( szInfo );
if( nValueB2 == nValue )
{
m_wndCameraB2 = hWnd ;
break ;
}

hWnd = ::GetWindow( hWnd , GW_HWNDNEXT );
}
posted on 2017-12-25 19:30  windy_net  阅读(247)  评论(0编辑  收藏  举报