在win2k下,如何实现刷新频率的变更及恢复?(100分)

  • 主题发起人 主题发起人 Ares
  • 开始时间 开始时间
A

Ares

Unregistered / Unconfirmed
GUEST, unregistred user!
我在win2k中改变了屏幕的分辨率后,发现刷新频率却变成了默认值(60Hz)。<br>请问如何保存当前的刷新频率呢?<br>我的代码如下:<br><br>procedure ResizeScreen; //更改<br>var<br>&nbsp; CurrentScreenMode: TDeviceMode;<br>begin<br>&nbsp; //保存当前屏幕分辨率<br>&nbsp; OldScreenMode.dmPelsWidth:=Screen.Width;<br>&nbsp; OldScreenMode.dmPelsHeight:=Screen.Height;<br><br>&nbsp; //修改当前屏幕分辨率为800*600<br>&nbsp; CurrentScreenMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT;<br>&nbsp; CurrentScreenMode.dmPelsWidth:=800;<br>&nbsp; CurrentScreenMode.dmPelsHeight:=600;<br>&nbsp; ChangeDisplaySettings(CurrentScreenMode,0);<br>end;<br><br>procedure RestoreScreen; &nbsp;//恢复<br>var<br>&nbsp; CurrentScreenMode: TDeviceMode;<br>begin<br>&nbsp; CurrentScreenMode.dmFields:=DM_PELSWIDTH or DM_PELSHEIGHT;<br>&nbsp; CurrentScreenMode.dmPelsWidth:=OldScreenMode.dmPelsWidth;<br>&nbsp; CurrentScreenMode.dmPelsHeight:=OldScreenMode.dmPelsHeight;<br>&nbsp; ChangeDisplaySettings(CurrentScreenMode,0);<br>end;<br><br>附:有时无法改变分辨率,不知何故?请各位大侠指教!
 
procedure ResizeScreen; //更改<br>var<br>&nbsp; CurrentScreenMode: TDeviceMode;<br>begin<br>&nbsp; //保存当前屏幕分辨率<br>&nbsp; OldScreenMode.dmPelsWidth:=Screen.Width;<br>&nbsp; OldScreenMode.dmPelsHeight:=Screen.Height;<br><br>&nbsp; //修改当前屏幕分辨率为800*600<br>&nbsp; CurrentScreenMode.dmFields:=DM_PELSWIDTH + DM_PELSHEIGHT;<br>&nbsp; EnumDisplaySettings(nil,0,CurrentScreenMode);<br>&nbsp; ChangeDisplaySettings(CurrentScreenMode,CDS_RESET);<br>end;
 
function EnumDisplaySettingsM(lpszDeviceName: PChar; iModeNum: Integer;<br>&nbsp; &nbsp; var lpDevMode: TDeviceMode): Integer; stdcall; external 'User32.DLL' name 'EnumDisplaySettingsA';<br><br>procedure ResizeScreen; //更改<br>var<br>&nbsp; CurrentScreenMode: TDeviceMode;<br>&nbsp; bNoFound,bEnd : boolean;<br>&nbsp; iNum : Integer;<br>begin<br>&nbsp; //保存当前屏幕分辨率<br>&nbsp; OldScreenMode.dmFields:= DM_PELSWIDTH + DM_PELSHEIGHT<br>&nbsp; &nbsp; + DM_DISPLAYFREQUENCY;<br>&nbsp; OldScreenMode.dmSize := SizeOf(OldScreenMode);<br>&nbsp; EnumDisplaySettingsM(nil,-1,OldScreenMode);<br><br>&nbsp; //修改当前屏幕分辨率为800*600<br>&nbsp; bNoFound := True;<br>&nbsp; bEnd := False;<br>&nbsp; iNum := 0;<br>&nbsp; CurrentScreenMode.dmFields:=DM_PELSWIDTH + DM_PELSHEIGHT;<br>&nbsp; OldScreenMode.dmSize := SizeOf(CurrentScreenMode);<br>&nbsp; while bNoFound And (Not bEnd) do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; bEnd := EnumDisplaySettingsM(nil,iNum,CurrentScreenMode)=0;<br>&nbsp; &nbsp; &nbsp; iNum := iNum + 1;<br>&nbsp; &nbsp; &nbsp; if (CurrentScreenMode.dmPelsWidth = 800) AND<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(CurrentScreenMode.dmPelsHeight = 600) &nbsp;then<br>&nbsp; &nbsp; &nbsp; &nbsp; bNoFound := False;<br>&nbsp; &nbsp; end;<br>&nbsp; CurrentScreenMode.dmDisplayFrequency := OldScreenMode.dmDisplayFrequency;<br><br>&nbsp; if (Not bNoFound) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; CurrentScreenMode.dmFields:=DM_PELSWIDTH + DM_PELSHEIGHT +<br>&nbsp; &nbsp; &nbsp; &nbsp; + DM_DISPLAYFREQUENCY;<br>&nbsp; &nbsp; &nbsp; ChangeDisplaySettings(CurrentScreenMode,CDS_RESET);<br>&nbsp; &nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; ShowMessage('Not support');<br>&nbsp; &nbsp; end;<br>end;<br><br>procedure RestoreScreen; &nbsp;//恢复<br>begin<br>&nbsp; ChangeDisplaySettings(OldScreenMode,CDS_RESET);<br>end;<br>
 
接受答案了.
 
后退
顶部