资源简介
多台显示器的时候,怎样设置主显示器..及相关显示器信息的获得..
代码片段和文件信息
#include “stdafx.h“
#include “CMonitorList.h“
vector hMonitorGroup;
int CALLBACK MonitorEnumProc(HMONITOR hMonitor
HDC hdc
LPRECT lpRMonitor
LPARAM dwData)
{
hMonitorGroup.push_back(hMonitor);
return 1;
}
CMonitorList::CMonitorList()
{
// hMonitorGroup.clear();
}
CMonitorList::~CMonitorList()
{
m_miGroup.clear();
}
int CMonitorList::EnumDevicePort()
{
BOOL bFlag = FALSE;
DWORD m_dwDevicePortNum; //设备输出端口,包含虚拟端口
m_dwDevicePortNum = 0;
do
{
DISPLAY_DEVICE dd_temp;
ZeroMemory(&dd_temp sizeof(dd_temp));
dd_temp.cb = sizeof(DISPLAY_DEVICE);
bFlag = FALSE;
bFlag = ::EnumDisplayDevices(NULL m_dwDevicePortNum &dd_temp 0);
if(bFlag)
{
if(!((dd_temp.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) == DISPLAY_DEVICE_MIRRORING_DRIVER))//判断不是虚拟接口
{
RECT rcTemp = {0 0 0 0};
//st_MI miTemp = {TEXT(““) TEXT(““) FALSE FALSE 0 rcTemp 0 0 0 0};
st_MI miTemp;
memset(&miTemp 0 sizeof(st_MI));
miTemp.mi_DeviceActive = FALSE;
miTemp.mi_DevicePrimary = FALSE;
miTemp.mi_rcWork = rcTemp;
//WideCharToMultiByte(CP_ACP 0 dd_temp.DeviceName -1 miTemp.mi_DeviceName sizeof(miTemp.mi_DeviceName) NULL NULL);
//WideCharToMultiByte(CP_ACP 0 dd_temp.DeviceString -1 miTemp.mi_DeviceString sizeof(miTemp.mi_DeviceString) NULL NULL);
_tcscpy(miTemp.mi_wDeviceName dd_temp.DeviceName);
//strcpy(miTemp.mi_DeviceNamedd_temp.DeviceName);
//strcpy(miTemp.mi_DeviceString dd_temp.DeviceString);
miTemp.mi_StateFlags = dd_temp.StateFlags;
if((dd_temp.StateFlags & DISPLAY_DEVICE_ACTIVE) == DISPLAY_DEVICE_ACTIVE)//判断接口激活状态
miTemp.mi_DeviceActive = TRUE;
m_miGroup.push_back(miTemp);
}
m_dwDevicePortNum++;
}
} while (bFlag);
return 1;
}
int CMonitorList::EnumMonitor()
{
::EnumDisplayMonitors(NULL NULL MonitorEnumProc 0);
for(vector::iterator itehMoniter = hMonitorGroup.begin(); itehMoniter != hMonitorGroup.end(); itehMoniter++)
{
MONITORINFOEX mixTemp;
memset(&mixTemp 0 sizeof(MONITORINFOEX));
mixTemp.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(*itehMoniter &mixTemp);
vector::iterator iteMI = m_miGroup.begin();
for(; iteMI != m_miGroup.end(); iteMI++)
{
//char cTemp[32];
//WideCharToMultiByte(CP_ACP 0 mixTemp.szDevice -1 cTemp sizeof(cTemp) NULL NULL);
//strcpy(mixTemp.szDevice cTemp);
if(!_tcscmp(iteMI->mi_wDeviceName mixTemp.szDevice))
{
iteMI->mi_rcMonitor = mixTemp.rcMonitor;
iteMI->mi_rcWork = mixTemp.rcWork; // 这个工作区域指除了任务栏之外的区域
break;
}
if((iteMI->mi_StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) == DISPLAY_DEVICE_PRIMARY_DEVICE)//判断主显示器
iteMI->mi_DevicePrimary = TRUE;
HDC hdcMonitor = CreateDC(TEXT(“Display“) mixTemp.szDevice NULL NULL);
iteMI->mi_nColorDepth = GetDeviceCaps(hdcMonitor BITSPIXEL) * GetDeviceCaps(h
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-01-25 09:14 设置主显示器\
文件 14225 2013-01-25 09:12 设置主显示器\CMonitorList.cpp
文件 2711 2013-01-25 09:13 设置主显示器\CMonitorList.h
文件 166 2013-01-25 09:18 设置主显示器\说明.txt
- 上一篇:某学校信息化建设软件参数
- 下一篇:超级终端,亲测win7,win10可用
评论
共有 条评论