c++ builer 中如何读取系统显示设置
发布网友
发布时间:2023-11-18 22:03
我来回答
共1个回答
热心网友
时间:2024-01-17 00:46
你可以在cb的在线帮助中找 ChangeDisplaySettings ,可以找到所有的属性。
附上用CB动态改变显示器分辨率的代码:
void __fastcall TForm1::btnGetClick(TObject *Sender)
{<
void __fastcall TForm1::btnGetClick(TObject *Sender)
{
int x,y;
x = GetSystemMetrics(SM_CXSCREEN);
y = GetSystemMetrics(SM_CYSCREEN);
ShowMessage("显示器水平分辨率:" + AnsiString(x) + " 显示器垂直分辨率:" + AnsiString(y));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DynamicResolution(int x,int y)
{
TDeviceModelpDevMode;
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);
}