有没有可以设置屏幕分辨率的api函数,我有个程序在800*600下面有最好的效果,想在检测到当前分辨率不是800*600时把分辨率改变为800*600(100分

Y

ynfly

Unregistered / Unconfirmed
GUEST, unregistred user!
有没有可以设置屏幕分辨率的api函数,我有个程序在800*600下面有最好的效果,想在检测到当前分辨率不是800*600时把分辨率改变为800*600(100分)<br />有没有可以设置屏幕分辨率的api函数,我有个程序在800*600下面有最好的效果,想在检测到当前分辨率不是800*600时把分辨率改变为800*600
 
function &nbsp;ChangeResolution(X, Y: word): BOOL;<br>var lpDevMode: TDeviceMode;<br>begin<br>&nbsp; &nbsp;Result := EnumDisplaySettings(nil, 0, lpDevMode);<br>&nbsp; &nbsp;if Result then begin<br>&nbsp; &nbsp; &nbsp; lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT;<br>&nbsp; &nbsp; &nbsp; lpDevMode.dmPelsWidth := X;<br>&nbsp; &nbsp; &nbsp; lpDevMode.dmPelsHeight := Y;<br>&nbsp; &nbsp; &nbsp; Result := ChangeDisplaySettings(lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL;<br>&nbsp; &nbsp;end<br>end;<br>{ &nbsp;示例:if ChangeResolution(640, 480) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowMessage('Now is 640*480'); &nbsp; &nbsp; }<br><br>当前分辨率用Screen.width Screen.Height获得。
 
function Resolution(X,Y:word):boolean;<br>var<br>&nbsp; DevMode:TDeviceMode;<br>&nbsp; begin<br>&nbsp; &nbsp; Result:=EnumDisplaySettings(nil,0,DevMode);<br>&nbsp; &nbsp; if Result then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; DevMode.dmFields:=DM_PELSWIDTH Or DM_PELSHEIGHT;<br>&nbsp; &nbsp; &nbsp; DevMode.dmPelsWidth:=X;<br>&nbsp; &nbsp; &nbsp; DevMode.dmPelsHeight:=Y;<br>&nbsp; &nbsp; &nbsp; Result:=ChangeDisplaySettings(DevMode,0)=DISP_CHANGE_SUCCESSFUL;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; if Resolution(800,600) then ShowMessage('800×600模式!');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; if Resolution(1280,1024) then ShowMessage('1280X1024模式!');<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>&nbsp; if Resolution(1024,768) then ShowMessage('1024X768模式!');<br>end;<br><br>自己改改了。
 
谢谢两位
 
顶部