/*设置屏幕分辨率 width,Height,Color->SetPixelAndColor(1024,768,32)*/
bool SetPixelAndColor(HDC hdc,unsigned int Width,unsigned int Height,int BitsPerPixel)
{
DEVMODE CurMode;
int result=1;
for(int i=0;result;i++)
result = EnumDisplaySettings(NULL,i,&CurMode);
CurMode.dmPelsWidth = Screen-> Width;
CurMode.dmPelsHeight = Screen-> Height;
if(CurMode.dmPelsWidth!=Width ||CurMode.dmPelsHeight!=Height)
{
CurMode.dmPelsWidth = Width;
CurMode.dmPelsHeight = Height;
CurMode.dmBitsPerPel = BitsPerPixel;
CurMode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
result = ChangeDisplaySettings(&CurMode, CDS_UPDATEREGISTRY);
return (result==DISP_CHANGE_SUCCESSFUL);
}
else
return false;
}
SetPixelAndColor(1024,768,32);
/*首先得到窗体的默认分辨率,在程序关闭的时候恢复默认分辨率*/
int sx=Screen->Width;
int sy=Screen->Height;
SetPixelAndColor(NULL,sx,sy,32);