I have written a small program, which changes the screen resolution from 1024*768 @ 70Hz to 800*600 @ 60Hz and back, to play a video in 800*600 res. And the program works fine so far; but only in Debug mode. If I change settings to Release mode, the resolution does not change to 800*600. But later on, when called, it tries to "switch back" to 1024*768. Does anyone know how to solve this Problem? (here are the codes
void CTvdiagDlg::OnMin()
{
LPDEVMODE lpDev=new DEVMODE;
lpDev->dmFields=DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
lpDev->dmPelsHeight=600;
lpDev->dmPelsWidth=800;
lpDev->dmDisplayFrequency= 60;
if(ChangeDisplaySettings(lpDev, CDS_UPDATEREGISTRY)!=DISP_CHANGE_SUCCESSFUL)
{
MessageBox("error changing resolution"
}
delete lpDev;
lpDev=NULL;
}
void CTvdiagDlg::OnMax()
{
LPDEVMODE lpDev=new DEVMODE;
lpDev->dmFields=DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
lpDev->dmPelsHeight=768;
lpDev->dmPelsWidth=1024;
lpDev->dmDisplayFrequency= 70;
if(ChangeDisplaySettings(lpDev, CDS_UPDATEREGISTRY)!=DISP_CHANGE_SUCCESSFUL)
{
MessageBox("error changing resolution"
}
delete lpDev;
lpDev=NULL;
}
void CTvdiagDlg::OnMin()
{
LPDEVMODE lpDev=new DEVMODE;
lpDev->dmFields=DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
lpDev->dmPelsHeight=600;
lpDev->dmPelsWidth=800;
lpDev->dmDisplayFrequency= 60;
if(ChangeDisplaySettings(lpDev, CDS_UPDATEREGISTRY)!=DISP_CHANGE_SUCCESSFUL)
{
MessageBox("error changing resolution"
}
delete lpDev;
lpDev=NULL;
}
void CTvdiagDlg::OnMax()
{
LPDEVMODE lpDev=new DEVMODE;
lpDev->dmFields=DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
lpDev->dmPelsHeight=768;
lpDev->dmPelsWidth=1024;
lpDev->dmDisplayFrequency= 70;
if(ChangeDisplaySettings(lpDev, CDS_UPDATEREGISTRY)!=DISP_CHANGE_SUCCESSFUL)
{
MessageBox("error changing resolution"
}
delete lpDev;
lpDev=NULL;
}