Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatmaul <matmaul@users.sourceforge.net>2008-06-30 01:09:05 +0400
committermatmaul <matmaul@users.sourceforge.net>2008-06-30 01:09:05 +0400
commit689431f063cd656897f06947c673001544e60aca (patch)
treef8c9e204786e1a8396e92419d7fbdcdbd5bcb4ee /src/apps/mplayerc/Monitors.cpp
parentec831110a811b9f2c812b7810aa314cb6be69a8c (diff)
move monitors files
change the license to GPL as it seems to be compatible http://forum.doom9.org/showthread.php?t=139082 git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@618 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/Monitors.cpp')
-rw-r--r--src/apps/mplayerc/Monitors.cpp198
1 files changed, 198 insertions, 0 deletions
diff --git a/src/apps/mplayerc/Monitors.cpp b/src/apps/mplayerc/Monitors.cpp
new file mode 100644
index 000000000..848bea8fa
--- /dev/null
+++ b/src/apps/mplayerc/Monitors.cpp
@@ -0,0 +1,198 @@
+/*
+ * $Id: Monitors.cpp 349 2007-12-27 00:07:03Z matmaul $
+ *
+ * Author: Donald Kackman
+ * Email: don@itsEngineering.com
+ * Copyright 2002, Donald Kackman
+ *
+ * This file is part of mplayerc.
+ *
+ * Mplayerc is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mplayerc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "StdAfx.h"
+#include "Monitors.h"
+
+
+// CMonitors
+
+CMonitors::CMonitors()
+{
+ m_MonitorArray.SetSize( GetMonitorCount() );
+
+ ADDMONITOR addMonitor;
+ addMonitor.pMonitors = &m_MonitorArray;
+ addMonitor.currentIndex = 0;
+
+ ::EnumDisplayMonitors( NULL, NULL, AddMonitorsCallBack, (LPARAM)&addMonitor );
+}
+
+CMonitors::~CMonitors()
+{
+ for ( int i = 0; i < m_MonitorArray.GetSize(); i++ )
+ delete m_MonitorArray.GetAt( i );
+}
+
+
+// CMonitors member functions
+
+BOOL CALLBACK CMonitors::AddMonitorsCallBack( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
+{
+ LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;
+
+ CMonitor* pMonitor = new CMonitor;
+ pMonitor->Attach( hMonitor );
+
+ pAddMonitor->pMonitors->SetAt( pAddMonitor->currentIndex, pMonitor );
+ pAddMonitor->currentIndex++;
+
+ return TRUE;
+}
+//
+// 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;
+}
+
+//
+// is the given handle a valid monitor handle
+BOOL CMonitors::IsMonitor( const HMONITOR hMonitor )
+{
+ if ( hMonitor == NULL )
+ return FALSE;
+
+ MATCHMONITOR match;
+ match.target = hMonitor;
+ match.foundMatch = FALSE;
+
+ ::EnumDisplayMonitors( NULL, NULL, FindMatchingMonitorHandle, (LPARAM)&match );
+
+ return match.foundMatch;
+}
+
+
+
+//this is the callback method that gets called via IsMontior
+BOOL CALLBACK CMonitors::FindMatchingMonitorHandle( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
+{
+ LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
+
+ if ( hMonitor == pMatch->target )
+ {
+ //found a monitor with the same handle we are looking for
+ pMatch->foundMatch = TRUE;
+ return FALSE; //stop enumerating
+ }
+
+ //haven't found a match yet
+ pMatch->foundMatch = FALSE;
+ return TRUE; //keep enumerating
+}
+
+
+BOOL CMonitors::AllMonitorsShareDisplayFormat()
+{
+ return ::GetSystemMetrics( SM_SAMEDISPLAYFORMAT );
+}
+
+//
+// the number of monitors on the system
+int CMonitors::GetMonitorCount()
+{
+ return ::GetSystemMetrics(SM_CMONITORS);
+}
+
+
+CMonitor CMonitors::GetMonitor( const int index ) const
+{
+#if _MFC_VER >= 0x0700
+ ASSERT( index >= 0 && index < m_MonitorArray.GetCount() );
+#else
+ ASSERT( index >= 0 && index < m_MonitorArray.GetSize() );
+#endif
+
+ CMonitor* pMonitor = (CMonitor*)m_MonitorArray.GetAt( index );
+
+ return *pMonitor;
+}
+
+//
+// returns the rectangle that is the union of all active monitors
+void CMonitors::GetVirtualDesktopRect( LPRECT lprc )
+{
+ ::SetRect( lprc,
+ ::GetSystemMetrics( SM_XVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_YVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_CXVIRTUALSCREEN ),
+ ::GetSystemMetrics( SM_CYVIRTUALSCREEN ) );
+
+}
+
+//
+// these methods determine wheter the given item is
+// visible on any monitor
+BOOL CMonitors::IsOnScreen( const LPRECT lprc )
+{
+ return ::MonitorFromRect( lprc, MONITOR_DEFAULTTONULL ) != NULL;
+}
+
+BOOL CMonitors::IsOnScreen( const POINT pt )
+{
+ return ::MonitorFromPoint( pt, MONITOR_DEFAULTTONULL ) != NULL;
+}
+
+BOOL CMonitors::IsOnScreen( const CWnd* pWnd )
+{
+ return ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONULL ) != NULL;
+}
+
+CMonitor CMonitors::GetNearestMonitor( const LPRECT lprc )
+{
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromRect( lprc, MONITOR_DEFAULTTONEAREST ) );
+
+ return monitor;
+
+}
+
+CMonitor CMonitors::GetNearestMonitor( const POINT pt )
+{
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ) );
+
+ return monitor;
+}
+
+CMonitor CMonitors::GetNearestMonitor( const CWnd* pWnd )
+{
+ ASSERT( pWnd );
+ ASSERT( ::IsWindow( pWnd->m_hWnd ) );
+
+ CMonitor monitor;
+ monitor.Attach( ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST ) );
+
+ return monitor;
+}
+
+