Esempio n. 1
0
void CMonitor::GetName(CString& string) const
{
    ASSERT(IsMonitor());

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

    string = mi.szDevice;
}
Esempio n. 2
0
void CMonitor::CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect ) const
{
	ASSERT( IsMonitor() );
	ASSERT( pWnd );
	ASSERT( ::IsWindow( pWnd->m_hWnd ) );

	CRect rect;
    pWnd->GetWindowRect( &rect );
    CenterRectToMonitor( &rect, UseWorkAreaRect );
    pWnd->SetWindowPos( NULL, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
}
Esempio n. 3
0
//
// is the instance the primary monitor
BOOL CMonitor::IsPrimaryMonitor() const
{
    ASSERT(IsMonitor());

    MONITORINFO mi;

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

    return mi.dwFlags == MONITORINFOF_PRIMARY;
}
Esempio n. 4
0
CMonitor CMonitors::GetPrimaryMonitor()
{
	HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
	ASSERT( IsMonitor( hMonitor ) );

	CMonitor monitor;
	monitor.Attach( hMonitor );
	ASSERT( monitor.IsPrimaryMonitor() );

	return monitor;
}
Esempio n. 5
0
//
// returns the primary monitor
CMonitor CMonitors::GetPrimaryMonitor()
{
	//the primary monitor always has its origin at 0,0
	HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
	ASSERT( IsMonitor( hMonitor ) );

	CMonitor monitor;
	monitor.Attach( hMonitor );
	ASSERT( monitor.IsPrimaryMonitor() );

	return monitor;
}
Esempio n. 6
0
//
// the work area does not include the start bar
void CMonitor::GetWorkAreaRect(LPRECT lprc) const
{
    ASSERT(IsMonitor());

    MONITORINFO mi;
    RECT        rc;

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

    ::SetRect(lprc, rc.left, rc.top, rc.right, rc.bottom);
}
Esempio n. 7
0
void CMonitor::CenterWindowToMonitor(CWnd* const pWnd, const BOOL UseWorkAreaRect) const
{
    ASSERT(IsMonitor());
    ASSERT(pWnd);
    ASSERT(::IsWindow(pWnd->m_hWnd));

    CRect rect;
    pWnd->GetWindowRect(&rect);
    CenterRectToMonitor(&rect, UseWorkAreaRect);
    // MPC-HC custom code start
    // Check if we are a child window and modify the coordinates accordingly
    if (pWnd->GetStyle() & WS_CHILD) {
        pWnd->GetParent()->ScreenToClient(&rect);
    }
    // MPC-HC custom code end
    pWnd->SetWindowPos(nullptr, rect.left, rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
Esempio n. 8
0
HDC CMonitor::CreateDC() const
{
	ASSERT( IsMonitor() );

	CString name;
	GetName( name );

	HDC hdc = ::CreateDC( name, name, NULL, NULL );
	ASSERT( hdc != NULL );

	CRect rect;
	GetMonitorRect( &rect );

	::SetViewportOrgEx( hdc, -rect.left, -rect.top, NULL );
	::SetViewportExtEx( hdc, rect.Width(), rect.Height(), NULL );

	return hdc;
}
Esempio n. 9
0
// creates an HDC for the monitor
// it is up to the client to call DeleteDC
//
// for normal multimonitor drawing it is not necessary to get a
// dc for each monitor. Windows takes care of drawing correctly
// on all monitors
//
// Only very exacting applications would need a DC for each monitor
HDC CMonitor::CreateDC() const
{
    ASSERT(IsMonitor());

    CString name;
    GetName(name);

    //create a dc for this display
    HDC hdc = ::CreateDC(name, name, nullptr, nullptr);
    ASSERT(hdc != nullptr);

    //set the viewport based on the monitor rect's relation to the primary monitor
    CRect rect;
    GetMonitorRect(&rect);

    ::SetViewportOrgEx(hdc, -rect.left, -rect.top, nullptr);
    ::SetViewportExtEx(hdc, rect.Width(), rect.Height(), nullptr);

    return hdc;
}