www.pudn.com > MultiMonitor.rar > ScreenSaverDlg.cpp, change:2011-07-15,size:32789b


// ScreenSaverDlg.cpp : 实现文件 
// 
 
#include "stdafx.h" 
 
//#include <video.h> 
#include "ScreenSaver.h" 
#include "ScreenSaverDlg.h" 
#include "DisplayInfo.h" 
 
 
//#include <videoacc.h> 
//#include <WiaVideo.h> 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#endif 
 
 
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// 对话框数据 
	enum { IDD = IDD_ABOUTBOX }; 
 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 
 
// 实现 
protected: 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
END_MESSAGE_MAP() 
 
 
// CScreenSaverDlg 对话框 
 
 
 
 
CScreenSaverDlg::CScreenSaverDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CScreenSaverDlg::IDD, pParent) 
	, m_cx(0) 
	, m_cy(0) 
{ 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CScreenSaverDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	DDX_Text(pDX, IDC_EDIT1, m_cx); 
	DDX_Text(pDX, IDC_EDIT2, m_cy); 
	DDX_Control(pDX, IDC_COMBO1, m_lst); 
} 
 
BEGIN_MESSAGE_MAP(CScreenSaverDlg, CDialog) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	//}}AFX_MSG_MAP 
	ON_BN_CLICKED(IDC_BUTTON1, &CScreenSaverDlg::OnBnClickedButton1) 
	ON_BN_CLICKED(IDC_BUTTON2, &CScreenSaverDlg::OnBnClickedButton2) 
	//ON_WM_SETTINGCHANGE() 
	ON_BN_CLICKED(IDC_BUTTON3, &CScreenSaverDlg::OnBnClickedButton3) 
	ON_BN_CLICKED(IDC_BUTTON4, &CScreenSaverDlg::OnBnClickedButton4) 
	ON_BN_CLICKED(IDC_BUTTON5, &CScreenSaverDlg::OnBnClickedButton5) 
	ON_BN_CLICKED(IDC_BUTTON6, &CScreenSaverDlg::OnBnClickedButton6) 
	ON_BN_CLICKED(IDC_BUTTON7, &CScreenSaverDlg::OnBnClickedButton7) 
	ON_BN_CLICKED(IDC_BTN_EXTEND, &CScreenSaverDlg::OnBnClickedBtnExtend) 
	ON_BN_CLICKED(IDC_BTN_SINGLE, &CScreenSaverDlg::OnBnClickedBtnSingle) 
	ON_BN_CLICKED(IDC_BTN_CLONE, &CScreenSaverDlg::OnBnClickedBtnClone) 
	ON_BN_CLICKED(IDC_BTN_EXTEND_IN, &CScreenSaverDlg::OnBnClickedBtnExtendIn) 
	ON_BN_CLICKED(IDC_BUTTON8, &CScreenSaverDlg::OnBnClickedButton8) 
END_MESSAGE_MAP() 
 
 
// CScreenSaverDlg 消息处理程序 
 
BOOL CScreenSaverDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// 将“关于...”菜单项添加到系统菜单中。 
 
	// IDM_ABOUTBOX 必须在系统命令范围内。 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 
	//  执行此操作 
	SetIcon(m_hIcon, TRUE);			// 设置大图标 
	SetIcon(m_hIcon, FALSE);		// 设置小图标 
 
	// TODO: 在此添加额外的初始化代码 
 
	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE 
} 
 
void CScreenSaverDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		if(nID==SC_SCREENSAVE || nID==SC_MONITORPOWER) 
		{ 
			OutputDebugString(TEXT("syscmd 屏保或者电源消息")); 
		} 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// 如果向对话框添加最小化按钮,则需要下面的代码 
//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, 
//  这将由框架自动完成。 
 
void CScreenSaverDlg::OnPaint() 
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // 用于绘制的设备上下文 
 
		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); 
 
		// 使图标在工作区矩形中居中 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// 绘制图标 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
//当用户拖动最小化窗口时系统调用此函数取得光标 
//显示。 
HCURSOR CScreenSaverDlg::OnQueryDragIcon() 
{ 
	return static_cast<HCURSOR>(m_hIcon); 
} 
 
 
int SetScreenSaver(BOOL bCancle/* =TRUE */) 
{ 
	static int ScrSaverTimeOut=600; 
	if(bCancle) 
	{ 
		//读取原来的屏保时间,以便恢复 
		::SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT,0,&ScrSaverTimeOut,0); 
 
		//取消屏保. 
		::SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,FALSE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
	} 
	else 
	{ 
		//设置原来的屏保时间 
		::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,ScrSaverTimeOut,NULL,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
		//激活屏保. 
		::SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,TRUE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
	} 
	return 1; 
} 
 
int SetPowerSaver(BOOL bCancle/* =TRUE */) 
{ 
	static int PowerTimeout=10; 
	if(bCancle) 
	{ 
		//获得原来电源时间. 
		::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,0,&PowerTimeout,0); 
		//取消自动关闭显示器 
		::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,FALSE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE);//取消电源管理 用SPI_SETPOWEROFFACTIVE不能执行. 
	} 
	else 
	{ 
		//设置原来的电源时间. 
		::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,PowerTimeout,NULL,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
		//激活自动关闭显示器. 
		::SystemParametersInfo(SPI_SETPOWEROFFACTIVE,TRUE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
	} 
	return 1; 
} 
 
void CScreenSaverDlg::OnBnClickedButton1() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	int time=0; 
	BOOL bActive=FALSE; 
	::SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,&bActive,0); 
	if(bActive) 
	::SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT,0,&time,0); 
	CString Str; 
	Str.Format(TEXT("screen timeout :%d"),time); 
	OutputDebugString(Str); 
 
	::SystemParametersInfo(SPI_GETLOWPOWERACTIVE,0,&bActive,0); 
	if(bActive) 
	{ 
		::SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,0,&time,0); 
		Str.Format(TEXT("low power timeout :%d"),time); 
		OutputDebugString(Str); 
	} 
 
	::SystemParametersInfo(SPI_GETPOWEROFFACTIVE,0,&bActive,0); 
	if(bActive) 
	{ 
		::SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT,0,&time,0); 
		Str.Format(TEXT("power timeout :%d"),time); 
		OutputDebugString(Str); 
	} 
} 
 
void CScreenSaverDlg::OnBnClickedButton2() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	BOOL bActive=FALSE; 
	::SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,&bActive,0);//屏保是否激活. 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("取消屏保")); 
		/*if(0==::SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,FALSE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE))//取消屏幕 
		{ 
			 
			OutputDebugString(TEXT("设置失败")); 
		}*/ 
		SetScreenSaver(TRUE); 
	} 
	else 
	{ 
		OutputDebugString(TEXT("设置屏保")); 
		/*::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,10,NULL,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE);//设置屏保时间为10秒,如果不需要改变屏保时间,可以不要. 
		if(0==::SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,TRUE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE))//激活屏保. 
		{ 
			OutputDebugString(TEXT("设置失败")); 
		}*/ 
		SetScreenSaver(FALSE); 
	} 
 
	/*::SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,0,&bActive,0); 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("取消电源")) 
	}*/ 
} 
 
LRESULT CScreenSaverDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{ 
	// TODO: 在此添加专用代码和/或调用基类 
 
	if (message == WM_POWERBROADCAST && wParam == PBT_APMQUERYSUSPEND)  
	{ 
		OutputDebugString(TEXT("电源消息")); 
	} 
	return CDialog::WindowProc(message, wParam, lParam); 
} 
 
//注意,此消息可能导致不能 恢复到复制模式. 
void CScreenSaverDlg::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) 
{ 
	if(uFlags==SPI_GETLOWPOWERACTIVE || uFlags==SPI_GETPOWEROFFACTIVE || uFlags==SPI_SETLOWPOWERACTIVE || uFlags==SPI_SETPOWEROFFACTIVE ||uFlags==SPI_GETSCREENSAVEACTIVE || uFlags==SPI_SETSCREENSAVEACTIVE) 
	{ 
		OutputDebugString(TEXT("on Setting 消息")); 
	} 
	CString Str; 
	Str.Format(TEXT("%d %s"),uFlags,lpszSection); 
	OutputDebugString(Str); 
 
	BOOL bActive=FALSE; 
	::SystemParametersInfo(SPI_GETLOWPOWERACTIVE,0,&bActive,0); 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("检测到修改 激活低电源")); 
		::SystemParametersInfo(SPI_SETLOWPOWERACTIVE,FALSE,NULL,0); 
	} 
 
	::SystemParametersInfo(SPI_GETPOWEROFFACTIVE,0,&bActive,0); 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("检测到修改 激活电源")); 
		::SystemParametersInfo(SPI_SETPOWEROFFACTIVE,FALSE,NULL,0); 
	} 
 
	::SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,&bActive,0); 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("检测到修改 激活屏保")); 
		::SystemParametersInfo(SPI_SETSCREENSAVEACTIVE,FALSE,NULL,0); 
	} 
	CDialog::OnSettingChange(uFlags, lpszSection); 
	// TODO: 在此处添加消息处理程序代码 
} 
 
void CScreenSaverDlg::OnBnClickedButton3() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	UpdateData(); 
	DEVMODE DevMode;  //屏幕信息结构体 
	/*EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&DevMode);  //获取当前的数据 
	DevMode.dmPelsWidth = m_cx;  //修改成你想要的分辨率 
	DevMode.dmPelsHeight = m_cy; 
	if(DISP_CHANGE_SUCCESSFUL!=ChangeDisplaySettings(&DevMode, CDS_UPDATEREGISTRY))  //设置生效 
	{ 
		OutputDebugString(TEXT("失败")); 
	}*/ 
 
	int i=-1;//ENUM_REGISTRY_SETTINGS 
	BOOL Result=EnumDisplaySettings(NULL,ENUM_REGISTRY_SETTINGS,&DevMode); //-1是当前设置 
	CString Str; 
 
	m_cx=DevMode.dmPelsWidth; 
	m_cy=DevMode.dmPelsHeight; 
	//int Pixel=DevMode.dmBitsPerPel; 
	UpdateData(FALSE); 
	int cx=0,cy=0; 
	int CurSel=0; 
	m_lst.ResetContent(); 
	while(Result)  
	{  
		++i; 
		Result=EnumDisplaySettings(NULL,i,&DevMode); 
		Str.Format(TEXT("%d*%d  %d 色"),DevMode.dmPelsWidth,DevMode.dmPelsHeight,DevMode.dmBitsPerPel); 
		OutputDebugString(Str); 
		if(cx!=DevMode.dmPelsWidth || cy!=DevMode.dmPelsHeight) 
		{ 
			cx=DevMode.dmPelsWidth; 
			cy=DevMode.dmPelsHeight; 
			Str.Format(TEXT("%d*%d"),DevMode.dmPelsWidth,DevMode.dmPelsHeight);  
			m_lst.AddString(Str); 
			if(m_cx==DevMode.dmPelsWidth && m_cy==DevMode.dmPelsHeight ) 
			{ 
				CurSel=m_lst.GetCount()-1; 
			} 
		} 
		 
	} 
	m_lst.SetCurSel(CurSel); 
} 
 
 
BOOL AddUnattachedDisplayDeviceToDesktop(int iSingle) 
{ 
 
	//此代码设置是能成功,只是没有枚举显示器数据,而是直接写的.应该要枚举. 
	int nRet =0; 
	int nOffSet = 0; 
	DEVMODE dm1; 
	memset(&dm1, 0, sizeof(dm1)); 
	dm1.dmSize = sizeof(dm1); 
	dm1.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION ; 
	//dm1.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; 
	dm1.dmPelsWidth = 1920; 
	dm1.dmPelsHeight = 1080; 
	dm1.dmPosition.x = nOffSet; 
	dm1.dmPosition.y = 0; 
	/*dm1.dmBitsPerPel = 32; 
	dm1.dmFields |= DM_BITSPERPEL; 
	dm1.dmDisplayFrequency = 60; 
	dm1.dmFields |= DM_DISPLAYFREQUENCY;*/ 
 
	DEVMODE dm2; 
	memset(&dm2, 0, sizeof(DEVMODE)); 
	dm2.dmSize = sizeof(DEVMODE); 
	dm2.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION ; 
	//dm2.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; 
	if(iSingle==0) 
	{ 
		dm2.dmPelsWidth = 1920; 
		dm2.dmPelsHeight = 1080; 
		nOffSet=1920; 
	} 
	else 
	{ 
		dm2.dmPelsWidth = 0; 
		dm2.dmPelsHeight = 0; 
	} 
	//dm2.dmPelsWidth = 1680;//设置成0,0,则disable掉幅显示器,否则靠下面的pos来设置扩展模式. 
	//dm2.dmPelsHeight = 1050; 
	dm2.dmPosition.x = nOffSet; 
	dm2.dmPosition.y = 0; 
	/*dm2.dmBitsPerPel = 32; 
	dm2.dmFields |= DM_BITSPERPEL; 
	dm2.dmDisplayFrequency = 60; 
	dm2.dmFields |= DM_DISPLAYFREQUENCY;*/ 
	if (ChangeDisplaySettingsEx(L"\\\\.\\Display1", &dm1, NULL, CDS_SET_PRIMARY | CDS_NORESET | CDS_UPDATEREGISTRY, 0) == DISP_CHANGE_SUCCESSFUL) { 
		OutputDebugString(L"extendstest"); 
		nRet=ChangeDisplaySettingsEx(L"\\\\.\\Display2", &dm2, NULL, CDS_NORESET | CDS_UPDATEREGISTRY , 0); 
		DWORD dw=GetLastError(); 
		nRet = ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, 0);//使有效 
	} 
	return TRUE; 
 
 
 
// 	DWORD DispNum = 0; 
// 	DISPLAY_DEVICE DisplayDevice; 
// 	DEVMODE defaultMode; 
// 	HDC hdc; 
// 	int nWidth; 
// 	BOOL bFoundSecondary = FALSE; 
//  
// 	hdc = GetDC(0); 
// 	nWidth = GetDeviceCaps(hdc,HORZRES); 
// 	ReleaseDC(0,hdc); 
//  
// 	// Initialize DisplayDevice. 
// 	ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 
// 	DisplayDevice.cb = sizeof(DisplayDevice); 
//  
// 	// Get display devices. 
// 	while ((EnumDisplayDevices(NULL, DispNum, &DisplayDevice, 0)) && 
// 		(bFoundSecondary == FALSE)) 
// 	{   
// 		ZeroMemory(&defaultMode, sizeof(DEVMODE)); 
// 		defaultMode.dmSize = sizeof(DEVMODE); 
// 		if (!EnumDisplaySettings(DisplayDevice.DeviceName, 
// 			ENUM_REGISTRY_SETTINGS, &defaultMode)) 
// 			return FALSE; // Store default failed 
//  
// 		if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) 
// 		{ 
// 			//Found the first secondary device. 
// 			bFoundSecondary = TRUE; 
// 			defaultMode.dmPosition.x += nWidth; 
// 			defaultMode.dmFields = DM_POSITION;   
// 			ChangeDisplaySettingsEx(DisplayDevice.DeviceName,   
// 				&defaultMode, NULL, CDS_NORESET|CDS_UPDATEREGISTRY, NULL);   
//  
// 			// A second call to ChangeDisplaySettings updates the monitor. 
// 			ChangeDisplaySettings(NULL, 0);   
// 		}   
//  
// 		// Reinitialize DisplayDevice.   
// 		ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 
// 		DisplayDevice.cb = sizeof(DisplayDevice); 
// 		DispNum++; 
// 	} // End while the display devices.   
// 	return TRUE; 
} 
 
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo) 
{ 
	 
	DISPLAY_DEVICE DispDev;  
	TCHAR szSaveDeviceName[0x60]={0}; 
	BOOL bRet = TRUE; 
 
	DEVMODE dvm; 
	dvm.dmSize=sizeof(DEVMODE); 
	dvm.dmDriverExtra=0; 
	dvm.dmFields=DM_POSITION; 
 
	ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE)); 
	DispDev.cb = sizeof(DISPLAY_DEVICE);  
 
 
	DWORD d1=0,d2=0,d1m0=0,d1m1=0,d2m0=0,d2m1=0; 
 
	CString Str,outStr; 
	int i=0,j=0; 
	BOOL bRet2=TRUE; 
	DWORD erro=0; 
	int jDev=0; 
	while(bRet) 
	{ 
		bRet=EnumDisplayDevices(NULL,i,&DispDev,0); 
		if(bRet) 
		{ 
			memset(szSaveDeviceName,0,0x60); 
			lstrcpy(szSaveDeviceName, DispDev.DeviceName); 
			bRet2=TRUE; 
			j=0; 
			OutputDebugString(TEXT("------------------------------------------------")); 
			OutputDebugString(szSaveDeviceName); 
			OutputDebugString(DispDev.DeviceString); 
			//OutputDebugString(DispDev.DeviceID); 
			//OutputDebugString(DispDev.DeviceKey); 
			Str.Format(TEXT("%08X "),DispDev.StateFlags); 
			OutputDebugString(Str); 
			if(i==0) 
			{ 
				d1=DispDev.StateFlags; 
			} 
			else if(i==1) 
			{ 
				d2=DispDev.StateFlags; 
			} 
			while(bRet2) 
			{ 
				 
				bRet2=EnumDisplayDevices(szSaveDeviceName,j,&DispDev,0); 
				BOOL t=EnumDisplaySettings(szSaveDeviceName,ENUM_CURRENT_SETTINGS,&dvm); 
				if(t==FALSE) 
				{ 
					erro=GetLastError(); 
				} 
				if(bRet2) 
				{ 
					j++; 
					if(_tcsstr(DispDev.DeviceID,TEXT("Default"))!=NULL) 
					{ 
						continue; 
					} 
					OutputDebugString(DispDev.DeviceName); 
					//OutputDebugString(DispDev.DeviceString); 
					OutputDebugString(DispDev.DeviceID);//LED 
					//OutputDebugString(DispDev.DeviceKey); 
					//OutputDebugString(dvm.dmDeviceName); 
					Str.Format(TEXT("%08X  %d,%d-%d,%d\r\n"),DispDev.StateFlags, 
						dvm.dmPosition.x,dvm.dmPosition.y,dvm.dmPelsWidth,dvm.dmPelsHeight); 
					OutputDebugString(Str); 
					BOOL bRet3=ChangeDisplaySettingsEx(DispDev.DeviceName,&dvm,NULL, CDS_SET_PRIMARY | CDS_NORESET | CDS_UPDATEREGISTRY, 0); 
					DWORD dw=GetLastError(); 
					if(i==0) 
					{ 
						if(jDev==0) 
						{ 
							d1m0=DispDev.StateFlags; 
						} 
						else if(jDev==1) 
						{ 
							d1m1=DispDev.StateFlags; 
						} 
					} 
					else if(i==1) 
					{ 
						if(jDev==0) 
						{ 
							d2m0=DispDev.StateFlags; 
						} 
						else if(jDev==1) 
						{ 
							d2m1=DispDev.StateFlags; 
						} 
					} 
					//j++; 
					jDev++; 
				} 
				 
			} 
		} 
		++i; 
	} 
	 
	//Display1和Display2都有DISPLAY_DEVICE_ATTACHED_TO_DESKTOP,则是扩展模式. 
	if((d1&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP &&  
		(d2&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) 
	{ 
		OutputDebugString(TEXT("扩展模式")); 
		return bRet; 
	} 
 
	//Display1有DISPLAY_DEVICE_PRIMARY_DEVICE,并且其中的monitor0和monitor1都有DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 
	//或者Display2有以上条件,,,也许还有其它情况,只是没有测试到. 
	if( (d1&DISPLAY_DEVICE_PRIMARY_DEVICE)==DISPLAY_DEVICE_PRIMARY_DEVICE && 
		(d1m0&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP && 
		(d1m1&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP ) 
	{ 
		OutputDebugString(TEXT("复制模式")); 
		return bRet; 
	} 
 
	if( (d2&DISPLAY_DEVICE_PRIMARY_DEVICE)==DISPLAY_DEVICE_PRIMARY_DEVICE && 
		(d2m0&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP && 
		(d2m1&DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)==DISPLAY_DEVICE_ATTACHED_TO_DESKTOP ) 
	{ 
		OutputDebugString(TEXT("复制模式")); 
		return bRet; 
	} 
 
 
	//其它条件下即为单显示器 
	OutputDebugString(TEXT("单显示器")); 
	// After the first call to EnumDisplayDevices,  
	// DispDev.DeviceString is the adapter name 
	/*if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) {   
		lstrcpy(szSaveDeviceName, DispDev.DeviceName); 
		OutputDebugString(szSaveDeviceName); 
		// After second call, DispDev.DeviceString is the  
		// monitor name for that device  
		EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);    
 
		//lstrcpy(lpszMonitorInfo, DispDev.DeviceString); 
		OutputDebugString(DispDev.DeviceString); 
	} else    { 
		bRet = FALSE; 
	}*/ 
 
	//FreeLibrary(hInstUser32); 
 
	return bRet; 
} 
 
 
int GetDisplayMonitorState(int Index) 
{ 
	DISPLAY_DEVICE DispDev;  
	TCHAR szSaveDeviceName[32]={0}; 
	BOOL bRet = TRUE; 
	ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE)); 
	DispDev.cb = sizeof(DISPLAY_DEVICE);  
	bRet=EnumDisplayDevices(NULL,Index,&DispDev,0); 
	if(bRet) 
	{ 
		_tcscpy_s(szSaveDeviceName,32, DispDev.DeviceName); 
		bRet=EnumDisplayDevices(szSaveDeviceName,Index,&DispDev,0); 
		if(bRet) 
		{ 
			return DispDev.StateFlags; 
		} 
	} 
	return 0; 
} 
 
BOOL CALLBACK MonitorEnumProc( 
							  HMONITOR hMonitor, // handle to display monitor 
							  HDC hdcMonitor, // handle to monitor DC 
							  LPRECT lprcMonitor, // monitor intersection rectangle 
							  LPARAM dwData // data 
							  ) 
{ 
//	RECT Rect; 
	MONITORINFO mi; 
 
	mi.cbSize = sizeof( mi ); 
	//Rect = *lprcMonitor; 
	GetMonitorInfo( hMonitor, &mi ); 
	CString Str; 
	Str.Format(TEXT("monitor:(%d,%d,%d,%d)  work(%d,%d,%d,%d)"),mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right,mi.rcMonitor.bottom, 
		mi.rcWork.left,mi.rcWork.top,mi.rcWork.right,mi.rcWork.bottom); 
	OutputDebugString(Str); 
	//lMonitorsX = max( lMonitorsX, mi.rcMonitor.right ); 
	//lMonitorsY = max( lMonitorsY, mi.rcMonitor.bottom ); 
	return TRUE; 
} 
 
void AnExampleFunction( HWND hWnd ) 
 
{ 
 
	// work out how big we have to be to cover all the screens. 
	//lMonitorsX = 0; 
	//lMonitorsY = 0; 
	EnumDisplayMonitors( 
		NULL, // handle to display DC  
		NULL, // clipping rectangle  
		MonitorEnumProc, // callback function 
		0 // data for callback function  
		); 
} 
 
void GetMyMonitor() 
{ 
	int nDisplayCnt =2;// GetSystemMetrics(SM_CMONITORS);   
 
	if ( nDisplayCnt >= 2 ) 
	{ 
 
		for ( int i = 0; i < nDisplayCnt; i++) 
		{ 
			DISPLAY_DEVICE dd; 
 
			dd.cb = sizeof(dd); 
 
			if ( EnumDisplayDevices(NULL,i,&dd,0) == TRUE )  
 
			{ 
				DEVMODE dm; 
 
				dm.dmSize = sizeof(DEVMODE); 
 
				if ( EnumDisplaySettingsEx(TEXT("\\\\.\\Display2"),ENUM_CURRENT_SETTINGS,&dm,0 ) == TRUE ) 
				{ 
					CString Str; 
					Str.Format(TEXT("%d,%d  Num:%ld\tWidth:%ld\tHeight:%ld\n"),dm.dmPosition.x,dm.dmPosition.y,i,dm.dmPelsWidth,dm.dmPelsHeight); 
					OutputDebugString(Str); 
 
				} 
			} 
 
		} 
	} 
 
} 
 
#define BUFSIZE 80 
 
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); 
 
int GetMySystemVersion() 
{ 
	CString Str; 
	OSVERSIONINFOEX osvi; 
	SYSTEM_INFO si; 
	PGNSI pGNSI; 
	BOOL bOsVersionInfoEx; 
 
	ZeroMemory(&si, sizeof(SYSTEM_INFO)); 
	ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); 
 
	// Try calling GetVersionEx using the OSVERSIONINFOEX structure. 
	// If that fails, try using the OSVERSIONINFO structure. 
 
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 
 
	if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) 
	{ 
		osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); 
		if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )  
			return FALSE; 
	} 
 
	// Call GetNativeSystemInfo if supported 
	// or GetSystemInfo otherwise. 
 
	pGNSI = (PGNSI) GetProcAddress( 
		GetModuleHandle(TEXT("kernel32.dll")),  
		"GetNativeSystemInfo"); 
	if(NULL != pGNSI) 
		pGNSI(&si); 
	else GetSystemInfo(&si); 
 
	switch (osvi.dwPlatformId) 
	{ 
		// Test for the Windows NT product family. 
 
	case VER_PLATFORM_WIN32_NT: 
 
		// Test for the specific product. 
 
		if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) 
		{ 
			if( osvi.wProductType == VER_NT_WORKSTATION ) 
				OutputDebugStringA("Windows Vista "); 
			else OutputDebugStringA ("Windows Server \"Longhorn\" " ); 
		} 
 
		if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) 
		{ 
			if( GetSystemMetrics(SM_SERVERR2) ) 
				OutputDebugStringA( "Microsoft Windows Server 2003 \"R2\" "); 
			else if( osvi.wProductType == VER_NT_WORKSTATION && 
				si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) 
			{ 
				OutputDebugStringA( "Microsoft Windows XP Professional x64 Edition "); 
			} 
			else OutputDebugStringA ("Microsoft Windows Server 2003, "); 
		} 
 
		if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) 
			OutputDebugStringA ("Microsoft Windows XP "); 
 
		if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) 
			OutputDebugStringA ("Microsoft Windows 2000 "); 
 
		if ( osvi.dwMajorVersion <= 4 ) 
			OutputDebugStringA ("Microsoft Windows NT "); 
 
		// Test for specific product on Windows NT 4.0 SP6 and later. 
		if( bOsVersionInfoEx ) 
		{ 
			// Test for the workstation type. 
			if ( osvi.wProductType == VER_NT_WORKSTATION && 
				si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64) 
			{ 
				if( osvi.dwMajorVersion == 4 ) 
					OutputDebugStringA ( "Workstation 4.0 " ); 
				else if( osvi.wSuiteMask & VER_SUITE_PERSONAL ) 
					OutputDebugStringA ( "Home Edition " ); 
				else OutputDebugStringA ( "Professional " ); 
			} 
 
			// Test for the server type. 
			else if ( osvi.wProductType == VER_NT_SERVER ||  
				osvi.wProductType == VER_NT_DOMAIN_CONTROLLER ) 
			{ 
				if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2) 
				{ 
					if ( si.wProcessorArchitecture == 
						PROCESSOR_ARCHITECTURE_IA64 ) 
					{ 
						if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) 
							OutputDebugStringA ( "Datacenter Edition "\ 
							"for Itanium-based Systems" ); 
						else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) 
							OutputDebugStringA ( "Enterprise Edition "\ 
							"for Itanium-based Systems" ); 
					} 
 
					else if ( si.wProcessorArchitecture == 
						PROCESSOR_ARCHITECTURE_AMD64 ) 
					{ 
						if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) 
							OutputDebugStringA ( "Datacenter x64 Edition " ); 
						else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) 
							OutputDebugStringA ( "Enterprise x64 Edition " ); 
						else OutputDebugStringA( "Standard x64 Edition " ); 
					} 
 
					else 
					{ 
						if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) 
							OutputDebugStringA ( "Datacenter Edition " ); 
						else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) 
							OutputDebugStringA ( "Enterprise Edition " ); 
						else if ( osvi.wSuiteMask & VER_SUITE_BLADE ) 
							OutputDebugStringA ( "Web Edition " ); 
						else OutputDebugStringA ( "Standard Edition " ); 
					} 
				} 
				else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0) 
				{ 
					if( osvi.wSuiteMask & VER_SUITE_DATACENTER ) 
						OutputDebugStringA ( "Datacenter Server " ); 
					else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) 
						OutputDebugStringA ( "Advanced Server " ); 
					else OutputDebugStringA ( "Server " ); 
				} 
				else  // Windows NT 4.0  
				{ 
					if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE ) 
						OutputDebugStringA ("Server 4.0, Enterprise Edition " ); 
					else OutputDebugStringA ( "Server 4.0 " ); 
				} 
			} 
		} 
		// Test for specific product on Windows NT 4.0 SP5 and earlier 
		else   
		{ 
			HKEY hKey; 
			TCHAR szProductType[BUFSIZE]; 
			DWORD dwBufLen=BUFSIZE*sizeof(TCHAR); 
			LONG lRet; 
 
			lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
				TEXT("SYSTEM\\CurrentControlSet\\Control\\")\ 
				TEXT("ProductOptions"), 0, KEY_QUERY_VALUE, &hKey ); 
			if( lRet != ERROR_SUCCESS ) 
				return FALSE; 
 
			lRet = RegQueryValueEx( hKey, TEXT("ProductType"), 
				NULL, NULL, (LPBYTE) szProductType, &dwBufLen); 
			RegCloseKey( hKey ); 
 
			if( (lRet != ERROR_SUCCESS) || 
				(dwBufLen > BUFSIZE*sizeof(TCHAR)) ) 
				return FALSE; 
 
			if ( lstrcmpi( TEXT("WINNT"), szProductType) == 0 ) 
				OutputDebugStringA( "Workstation " ); 
			if ( lstrcmpi( TEXT("LANMANNT"), szProductType) == 0 ) 
				OutputDebugStringA( "Server " ); 
			if ( lstrcmpi( TEXT("SERVERNT"), szProductType) == 0 ) 
				OutputDebugStringA( "Advanced Server " ); 
			Str.Format(TEXT("%d.%d ") , osvi.dwMajorVersion, osvi.dwMinorVersion ); 
			OutputDebugString(Str); 
		} 
 
		// Display service pack (if any) and build number. 
 
		if( osvi.dwMajorVersion == 4 &&  
			lstrcmpi( osvi.szCSDVersion, TEXT("Service Pack 6") ) == 0 ) 
		{  
			HKEY hKey; 
			LONG lRet; 
 
			// Test for SP6 versus SP6a. 
			lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
				TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\")\ 
				TEXT("Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey ); 
			if( lRet == ERROR_SUCCESS ) 
			{ 
				Str.Format( TEXT("Service Pack 6a (Build %d)\n"),  
				osvi.dwBuildNumber & 0xFFFF );    
				OutputDebugString(Str); 
			} 
			 
			else // Windows NT 4.0 prior to SP6a 
			{ 
				Str.Format( TEXT("%s (Build %d)\n"), 
					osvi.szCSDVersion, 
					osvi.dwBuildNumber & 0xFFFF); 
				OutputDebugString(Str); 
			} 
 
			RegCloseKey( hKey ); 
		} 
		else // not Windows NT 4.0  
		{ 
			Str.Format( TEXT("%s (Build %d)\n"), 
				osvi.szCSDVersion, 
				osvi.dwBuildNumber & 0xFFFF); 
			OutputDebugString(Str); 
		} 
 
		break; 
 
		// Test for the Windows Me/98/95. 
	case VER_PLATFORM_WIN32_WINDOWS: 
 
		if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) 
		{ 
			OutputDebugStringA ("Microsoft Windows 95 "); 
			if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B') 
				OutputDebugStringA("OSR2 " ); 
		}  
 
		if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) 
		{ 
			OutputDebugStringA ("Microsoft Windows 98 "); 
			if ( osvi.szCSDVersion[1]=='A' || osvi.szCSDVersion[1]=='B') 
				OutputDebugStringA("SE " ); 
		}  
 
		if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) 
		{ 
			OutputDebugStringA ("Microsoft Windows Millennium Edition\n"); 
		}  
		break; 
 
	case VER_PLATFORM_WIN32s: 
 
		OutputDebugStringA ("Microsoft Win32s\n"); 
		break; 
	} 
	return TRUE;  
} 
 
 
 
void CScreenSaverDlg::OnBnClickedButton4() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	//VideoPortDDCMonitorHelper(); 
	//AddUnattachedDisplayDeviceToDesktop(); 
 
	//遍历设备信息 
	GetDisplayMonitorInfo(0,NULL); 
	//CDisplayInfo::GetDisplayCardType(); 
	//GetMySystemVersion(); 
	//WinVerDef winVer; 
	//CDisplayInfo::GetWindowsVersion(&winVer); 
 
	//AnExampleFunction(NULL); 
 
	//GetMyMonitor(); 
 
	/*int ret=GetDisplayMonitorState(0); 
	switch(ret) 
	{ 
	case 1: 
		OutputDebugString(TEXT("扩展模式")); 
		break; 
	case 2: 
		OutputDebugString(TEXT("单显示器")); 
		break; 
	case 3: 
		OutputDebugString(TEXT("复制模式")); 
		break; 
	} 
 
	ret=GetDisplayMonitorState(1); 
	switch(ret) 
	{ 
	case 1: 
		OutputDebugString(TEXT("扩展模式")); 
		break; 
	case 2: 
		OutputDebugString(TEXT("单显示器")); 
		break; 
	case 3: 
		OutputDebugString(TEXT("复制模式")); 
		break; 
	}*/ 
	//AddUnattachedDisplayDeviceToDesktop(); 
} 
 
void CScreenSaverDlg::OnBnClickedButton5() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	int time=0; 
	BOOL bActive=FALSE; 
	CString Str; 
	::SystemParametersInfo(SPI_GETLOWPOWERACTIVE,0,&bActive,0); 
	if(1) 
	{ 
		::SystemParametersInfo(SPI_GETLOWPOWERTIMEOUT,0,&time,0); 
		Str.Format(TEXT("low power timeout :%d"),time); 
		OutputDebugString(Str); 
	} 
 
	::SystemParametersInfo(SPI_GETPOWEROFFACTIVE,0,&bActive,0); 
	if(1) 
	{ 
		::SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT,0,&time,0); 
		Str.Format(TEXT("power timeout :%d"),time); 
		OutputDebugString(Str); 
	} 
} 
 
void CScreenSaverDlg::OnBnClickedButton6() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	BOOL bActive=FALSE; 
	::SystemParametersInfo(SPI_GETPOWEROFFACTIVE,0,&bActive,0);//电源激活. 
	if(bActive) 
	{ 
		OutputDebugString(TEXT("取消电源")); 
		/*if(0==::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,FALSE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE))//取消电源 
		{ 
 
			OutputDebugString(TEXT("设置失败")); 
		}*/ 
		SetPowerSaver(TRUE); 
	} 
	else 
	{ 
		OutputDebugString(TEXT("设置电源")); 
		//设置电源时间,如果不设置电源时间,则不能激活电源.和屏保不同. 
		/*::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,600,NULL,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE); 
		if(0==::SystemParametersInfo(SPI_SETPOWEROFFACTIVE,TRUE,0,SPIF_UPDATEINIFILE|SPIF_SENDCHANGE))//激活电源时间. 
		{ 
			OutputDebugString(TEXT("设置失败")); 
		}*/ 
		SetPowerSaver(FALSE); 
	} 
} 
void DetachDisplay(BOOL bSingle) 
{ 
	BOOL            FoundSecondaryDisp = FALSE; 
	DWORD           DispNum = 0; 
	DISPLAY_DEVICE  DisplayDevice; 
	LONG            Result; 
//	TCHAR           szTemp[200]; 
	int             i = 0; 
	DEVMODE   defaultMode; 
 
	// initialize DisplayDevice 
	ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 
	DisplayDevice.cb = sizeof(DisplayDevice); 
 
	// get all display devices 
	while (EnumDisplayDevices(NULL, DispNum, &DisplayDevice, 0)) 
	{ 
		ZeroMemory(&defaultMode, sizeof(DEVMODE)); 
		defaultMode.dmSize = sizeof(DEVMODE); 
		if ( !EnumDisplaySettings(DisplayDevice.DeviceName, ENUM_REGISTRY_SETTINGS, &defaultMode) ) 
			OutputDebugString(TEXT("Store default failed\n")); 
 
		if ((DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) && 
			!(DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) 
		{ 
			DEVMODE    DevMode; 
			ZeroMemory(&DevMode, sizeof(DevMode)); 
			DevMode.dmSize = sizeof(DevMode); 
			DevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_POSITION 
				| DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS ; 
			if(bSingle) 
			{ 
				Result = ChangeDisplaySettingsEx(DisplayDevice.DeviceName, &DevMode, NULL, CDS_UPDATEREGISTRY, NULL); 
				Result = ChangeDisplaySettingsEx(DisplayDevice.DeviceName, &DevMode, NULL, CDS_UPDATEREGISTRY, NULL); 
			} 
			 
 
			//The code below shows how to re-attach the secondary displays to the desktop 
			else 
			{ 
				ChangeDisplaySettingsEx(DisplayDevice.DeviceName, &defaultMode, NULL, CDS_UPDATEREGISTRY, NULL); 
				ChangeDisplaySettingsEx(DisplayDevice.DeviceName, &defaultMode, NULL, CDS_UPDATEREGISTRY, NULL); 
			} 
			 
 
		} 
 
		// Reinit DisplayDevice just to be extra clean 
 
		ZeroMemory(&DisplayDevice, sizeof(DisplayDevice)); 
		DisplayDevice.cb = sizeof(DisplayDevice); 
		DispNum++; 
	} // end while for all display devices 
} 
 
void CScreenSaverDlg::OnBnClickedButton7() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	static int bSingle=0; 
	//AddUnattachedDisplayDeviceToDesktop(bSingle); 
	DetachDisplay( bSingle); 
	if(bSingle==0) 
	{ 
		bSingle=1; 
	} 
} 
 
void CScreenSaverDlg::OnBnClickedBtnExtend() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	BOOL bCheck=IsDlgButtonChecked(IDC_CH_EXCHANGE); 
	CDisplayInfo::SetDisplayMode(CDisplayInfo::DISPLAY_TYPE_EXTEND,bCheck); 
} 
 
void CScreenSaverDlg::OnBnClickedBtnSingle() 
{ 
	BOOL bCheck=IsDlgButtonChecked(IDC_CH_EXCHANGE); 
	CDisplayInfo::SetDisplayMode(CDisplayInfo::DISPLAY_TYPE_SINGLE,bCheck); 
} 
 
void CScreenSaverDlg::OnBnClickedBtnClone() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	CDisplayInfo::SetDisplayMode(CDisplayInfo::DISPLAY_TYPE_CLONE); 
} 
 
void CScreenSaverDlg::OnBnClickedBtnExtendIn() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	CDisplayInfo::SetDisplayMode(1); 
} 
 
void CScreenSaverDlg::OnBnClickedButton8() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	static BOOL bMove=TRUE; 
	int iWidth=GetSystemMetrics(SM_CXSCREEN); 
	int iVirWidth=GetSystemMetrics(SM_CXVIRTUALSCREEN); 
	int iVirHeight=GetSystemMetrics(SM_CYVIRTUALSCREEN); 
	CString Str; 
	Str.Format(TEXT("iWidth=%d,iVirWidth=%d,iVirHeight=%d"),iWidth,iVirWidth,iVirHeight); 
	OutputDebugString(Str); 
	CRect rect; 
	GetWindowRect(&rect); 
	if(bMove) 
	{ 
		if(rect.left+iWidth<iVirWidth) 
		{ 
			MoveWindow(rect.left+iWidth,rect.top,rect.Width(),rect.Height()); 
		} 
		bMove=FALSE; 
	} 
	else 
	{ 
		if(rect.left>=iWidth) 
		{ 
			MoveWindow(rect.left-iWidth,rect.top,rect.Width(),rect.Height()); 
		} 
		 
		bMove=TRUE; 
	} 
}