function DynamicResolution(X, Y: word): BOOL;
var
lpDevMode: TDeviceMode;
begin
Result := EnumDisplaySettings(nil, 0, lpDevMode);
if Result then
begin
lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;
lpDevMode.dmPelsWidth := X;
lpDevMode.dmPelsHeight := Y;
Result := ChangeDisplaySettings(lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if DynamicResolution(640, 480) then
ShowMessage('Now is 640*480');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if DynamicResolution(800, 600) then
ShowMessage('Now is 800*600');
end;
#
2002-12-05, 20:50
:
想button这种控件如果随窗体变化改变大小我想不太好看吧。我认为主要是那些大控件如ListBox、Panel、ListView等,随窗口大小改
变而适当改变是必要的,方法很简单,设置相应控件的anchors属性的值,就可以看到效果了。如果你一定要每个空间都随窗体改变而改变,需要拥到
ScaleBy方法。下面这个例子你运行一下就明白了
unit ScaleF;