zoukankan      html  css  js  c++  java
  • 怎么获得任一窗口的指针

    你创建的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 );
    }
  • 相关阅读:
    python中的编码问题
    CVPR2018 Tutorial 之 Visual Recognition and Beyond
    hdu 1376 Octal Fractions
    hdu 1329 Hanoi Tower Troubles Again!
    hdu 1309 Loansome Car Buyer
    hdu 1333 Smith Numbers
    hdu 1288 Hat's Tea
    hdu 1284 钱币兑换问题
    hdu 1275 两车追及或相遇问题
    hdu 1270 小希的数表
  • 原文地址:https://www.cnblogs.com/ransn/p/8110852.html
Copyright © 2011-2022 走看看