|
// PSLMonitors.cpp : Implementation of CPSLMonitors
#include "stdafx.h"
#include "PSLMonitor.h"
#include "PSLMonitors.h"
CPSLMonitors::CPSLMonitors()
{
}
HRESULT CPSLMonitors::OnIndexOutOfRange()
{
return MakeException(exIndexOutOfRange);
}
HRESULT CPSLMonitors::FinalConstruct()
{
PSL_BEGIN
InternalUpdate();
PSL_END
}
void CPSLMonitors::FinalRelease()
{
}
BOOL CALLBACK CPSLMonitors::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
vector<HMONITOR> * pMonitors = (vector<HMONITOR>*)dwData;
pMonitors->push_back(hMonitor);
return TRUE;
}
void CPSLMonitors::InternalUpdate()
{
CCritSecLock cs(m_csCollection);
m_coll.clear();
vector<HMONITOR> monitors;
::EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&monitors);
CComObject<CPSLMonitor> * pMonitor = NULL;
for(vector<HMONITOR>::iterator i = monitors.begin();i != monitors.end();i ++)
{
if(CComObject<CPSLMonitor>::CreateInstance(&pMonitor) == S_OK)
{
pMonitor->Initialize((*i));
m_coll.push_back(CComPtr<IPSLMonitor>(pMonitor));
}
}
}
////////////////////////////////////////////////////////////////////////
// Interface Implementation;
////////////////////////////////////////////////////////////////////////
STDMETHODIMP CPSLMonitors::Update()
{
PSL_BEGIN
InternalUpdate();
PSL_END
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.