void CChange_display_modeDlg::adulst_display(WORD x,WORD y)
{
DEVMODE DevMd;
DevMd.dmSize=sizeof(DevMd);
DevMd.dmPelsWidth=x; //水平像素
DevMd.dmPelsHeight=y; //垂直像素
DevMd.dmBitsPerPel=32; //32位真彩
DevMd.dmDisplayFrequency = 75; //刷新率Hz
DevMd.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;// | DM_DISPLAYFREQUENCY;// | DM_DISPLAYFLAGS;// | dmPosition;
//EnumDisplaySettings(NULL,0,&DevMd);
//DevMd.dmPelsWidth=x; //水平像素
//DevMd.dmPelsHeight=y;
long v=ChangeDisplaySettings(&DevMd,0); //临时修改设置
if(v==DISP_CHANGE_SUCCESSFUL)
{
ChangeDisplaySettings(&DevMd,CDS_UPDATEREGISTRY); //永久的修改设置
}
else
{
MessageBox("不支持!");
ChangeDisplaySettings(NULL,0);
}
}
void CChange_display_modeDlg::OnBtn1024()
{
// TODO: Add your control notification handler code here
adulst_display(1024,768);
HWND hWnd;
hWnd=::GetDesktopWindow();
CRect rect1;
::GetWindowRect(hWnd,&rect1);
CRect rect2;
GetWindowRect(&rect2);
int x=(rect1.Width() - rect2.Width())/2;
int y=(rect1.Height() - rect2.Height())/2;
MoveWindow(x,y,rect2.Width(),rect2.Height());
}
void CChange_display_modeDlg::OnBtn1600()
{
// TODO: Add your control notification handler code here
adulst_display(1600,1200);
HWND hWnd;
hWnd=::GetDesktopWindow();
CRect rect1;
::GetWindowRect(hWnd,&rect1);
CRect rect2;
GetWindowRect(&rect2);
int x=(rect1.Width() - rect2.Width())/2;
int y=(rect1.Height() - rect2.Height())/2;
MoveWindow(x,y,rect2.Width(),rect2.Height());
}
void CChange_display_modeDlg::OnBtn800()
{
// TODO: Add your control notification handler code here
adulst_display(800,600);
HWND hWnd;
hWnd=::GetDesktopWindow();
CRect rect1;
::GetWindowRect(hWnd,&rect1);
CRect rect2;
GetWindowRect(&rect2);
int x=(rect1.Width() - rect2.Width())/2;
int y=(rect1.Height() - rect2.Height())/2;
MoveWindow(x,y,rect2.Width(),rect2.Height());
}