用CB动态改变显示器分辨率
2008-03-08 12:52:38 来源:WEB开发网核心提示:void __fastcall TForm1::BTnGetClick(TObject *Sender){int x,y;x = GetSystemMetrics(SM_CXSCREEN);y = GetSystemMetrics(SM_CYSCREEN);ShowMessage("显示器水平分辨率:&quo
void __fastcall TForm1::BTnGetClick(TObject *Sender)
{
int x,y;
x = GetSystemMetrics(SM_CXSCREEN);
y = GetSystemMetrics(SM_CYSCREEN);
ShowMessage("显示器水平分辨率:" + AnsiString(x) + "\n\n显示器垂直分辨率:" + AnsiString(y));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DynamicResolution(int x,int y)
{
TDeviceMode lpDevMode;
bool Result;
Result = EnumDisplaySettings(NULL,0,&lpDevMode);
if (Result)
{
lpDevMode.dmFields = DM_PELSWIDTH DM_PELSHEIGHT;
lpDevMode.dmPelsWidth = x;
lpDevMode.dmPelsHeight = y;
Result = ChangeDisplaySettings(&lpDevMode,0);
// = DISP_CHANGE_SUCCESSFUL;
}
}
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
DynamicResolution(800,600);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
DynamicResolution(1024,768);
}
更多精彩
赞助商链接