如果获取桌面区域大小,除去任务栏,注意任务栏是否隐藏?

解决方案 »

  1.   

    SystemParametersInfo,用SPI_GETWORKAREA
      

  2.   

    桌面区域大小:
    int cx = GetSystemMetrics(SM_CXSCREEN);
    int cy = GetSystemMetrics(SM_CYSCREEN);

    HDC hdcScreen = GetDC( NULL );
    int cx = GetDeviceCaps( hdcScreen, HORZRES );
    int cy = GetDeviceCaps( hdcScreen, VERTRES );
    DeleteObject( hdcScreen );任务栏:
    CWnd* pTaskWnd = FindWindow( _T("Shell_TrayWnd"), NULL );
    if( pTaskWnd ) pTaskWnd->ShowWindow( FALSE );
      

  3.   

    RECT rc;
    SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID) &rc, 0);
      

  4.   

    任务栏是否隐藏:
    LONG lStyle = GetWindowLong( pTaskWnd->GetSafeHwnd(), GWL_STYLE );
    if( lStyle & WS_VISIBLE )
    {
            //可见
    }
    else
    {
            //隐藏
    }
      

  5.   

    羽战士的方法光荣又正确,搂主理解能力怎么样?SPI_GETWORKAREA Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in virtual screen coordinates. 
    To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.
      

  6.   

    BOOL flag;
    LPDEVMODE gpCurrentMode; 
    gpCurrentMode = new DEVMODE; 
    flag = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, gpCurrentMode); 
    gpCurrentMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | 
    DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY ;  //格式化字符串
    m_CurrentColorMode.Format(
    "%d",gpCurrentMode->dmBitsPerPel);
    m_CurrentDifferency.Format(
    "%d * %d",
    gpCurrentMode->dmPelsWidth,
    gpCurrentMode->dmPelsHeight);
    m_CurrentFrequency.Format(
    "%d",gpCurrentMode->dmDisplayFrequency);
    AfxMessageBox(m_CurrentDifferency);   //显示分辨率
    AfxMessageBox(m_CurrentColorMode);    //色彩位数
      

  7.   

    不好意思,前面的代码忘了释放指针了,在最后加上:
    delete gpCurrentMode;
    gpCurrentMode=NULL;
      

  8.   

    TO Mackz(在相互)
    我有说他的方法错吗?
    可在我的机器上得到的RECT是错的,上下左右都是-858993460,何故?
      

  9.   

    谢谢pomelowu(羽战士)
    已经OK了。