一、取得显示器的个数

GetSystemMetrics(SM_CMONITORS);

二、根据窗口句柄、矩形区域、点取得显示器的句柄

MonitorFromRect( lprc, MONITOR_DEFAULTTONULL )

MonitorFromPoint( pt, MONITOR_DEFAULTTONULL )

MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL )

三、取得主显示器的句柄

 //the primary monitor always has its origin at 0,0
 HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );

四、根据显示器的句柄返回显示区域

MONITORINFO mi;
    RECT        rc;

 mi.cbSize = sizeof( mi );
 ::GetMonitorInfo( m_hMonitor, &mi );
 rc = mi.rcMonitor;

 

参考代码:点击我 

相关文章:

  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-07-17
  • 2021-09-29
相关资源
相似解决方案