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 );
    }
  • 相关阅读:
    Maven 梳理
    Maven 梳理
    Maven 梳理-自动创建Maven项目(非web)
    Maven 梳理-手动创建Maven项目(非web),使用Maven编译、测试、打包、安装、引用
    Maven 梳理 -目录结构
    Maven 梳理-安装配置
    Spring 梳理-数据访问-DB
    JNDI数据源的配置
    Spring 梳理-JdbcTemplate简介
    Docker常用命令
  • 原文地址:https://www.cnblogs.com/ransn/p/8110852.html
Copyright © 2011-2022 走看看