如何修改第二块屏幕的分辨率?不是第一块哦 ( 积分: 200 )

  • 主题发起人 主题发起人 crazycock
  • 开始时间 开始时间
C

crazycock

Unregistered / Unconfirmed
GUEST, unregistred user!
显卡有双头,可以在第二个头显示屏幕2的内容。程序里面需要控制屏幕2的分辨率,从桌面-属性-设置-屏幕分辨率里可以手工设置。<br><br>我的代码:<br>function&nbsp;ChgDisplaySetting():Boolean;<br>var<br>&nbsp;&nbsp;DevMode:TDeviceMode;<br>&nbsp;&nbsp;dd:TDisplayDevice;<br>&nbsp;&nbsp;ScreenNo:Integer;<br>&nbsp;&nbsp;ret:Boolean;<br>begin<br>//&nbsp;&nbsp;ScreenNo:=0;<br>//&nbsp;&nbsp;repeat<br>//&nbsp;&nbsp;&nbsp;&nbsp;ZeroMemory(@dd,SizeOf(TDisplayDevice));<br>//&nbsp;&nbsp;&nbsp;&nbsp;dd.cb&nbsp;:=&nbsp;&nbsp;SizeOf(TDisplayDevice);<br>//&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;:=&nbsp;EnumDisplayDevices(nil,ScreenNo,dd,0);<br>//&nbsp;&nbsp;&nbsp;&nbsp;Form1.Memo1.Lines.Add(dd.DeviceName);<br>//&nbsp;&nbsp;&nbsp;&nbsp;Form1.Memo1.Lines.Add(dd.DeviceString);<br>//&nbsp;&nbsp;&nbsp;&nbsp;Form1.Memo1.Lines.Add('--------------------');<br>//&nbsp;&nbsp;&nbsp;&nbsp;Inc(ScreenNo);<br>//&nbsp;&nbsp;until&nbsp;not&nbsp;ret;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;ScreenNo:=1;<br>&nbsp;&nbsp;&nbsp;&nbsp;ZeroMemory(@dd,SizeOf(TDisplayDevice));<br>&nbsp;&nbsp;&nbsp;&nbsp;dd.cb&nbsp;:=&nbsp;&nbsp;SizeOf(TDisplayDevice);<br>&nbsp;&nbsp;&nbsp;&nbsp;ret&nbsp;:=&nbsp;EnumDisplayDevices(nil,ScreenNo,dd,0);<br><br>&nbsp;&nbsp;ZeroMemory(@DevMode,Sizeof(TDeviceMode));<br>&nbsp;&nbsp;DevMode.dmSize&nbsp;:=&nbsp;Sizeof(TDeviceMode);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;EnumDisplaySettings(dd.DeviceName,4294967295-1,DevMode);<br>&nbsp;&nbsp;if&nbsp;Result&nbsp;then<br>&nbsp;&nbsp;begin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;DevMode.dmFields&nbsp;:=&nbsp;DM_PELSWIDTH&nbsp;or&nbsp;DM_PELSHEIGHT&nbsp;or&nbsp;DM_DISPLAYFLAGS;<br>&nbsp;&nbsp;&nbsp;&nbsp;DevMode.dmPelsWidth&nbsp;:=&nbsp;800;<br>&nbsp;&nbsp;&nbsp;&nbsp;DevMode.dmPelsHeight&nbsp;:=&nbsp;600;<br>&nbsp;&nbsp;&nbsp;&nbsp;StrPCopy(DevMode.dmDeviceName,dd.DeviceName);<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;ChangeDisplaySettingsEx(dd.DeviceName,DevMode,0,CDS_NORESET&nbsp;or&nbsp;CDS_UPDATEREGISTRY,0)=DISP_CHANGE_SUCCESSFUL;<br>&nbsp;&nbsp;&nbsp;&nbsp;//ChangeDisplaySettings(DevMode,0);<br>&nbsp;&nbsp;end;<br>end;<br><br>代码不管怎么改,修改的总是第一块屏幕的分辨率,不知道哪个地方没写对。希望大家指点一下。
 
问题解决!哈哈哈·~~<br><br>帖子先留着,能够解决问题的人可以接到分数。结贴时候给答案。
 
我留个名,以后方便查找这方面的问题
 
我也留个名,以后方便查找这方面的问题
 
结帖了。<br><br>Result&nbsp;:=&nbsp;ChangeDisplaySettingsEx(dd.DeviceName,DevMode,0,CDS_NORESET&nbsp;or&nbsp;CDS_UPDATEREGISTRY,0)=DISP_CHANGE_SUCCESSFUL;<br><br>把CDS_NORESET&nbsp;or&nbsp;CDS_UPDATEREGISTRY去掉即可。原因参考MSDN:<br>CDS_NORESET&nbsp;The&nbsp;settings&nbsp;will&nbsp;be&nbsp;saved&nbsp;in&nbsp;the&nbsp;registry,&nbsp;but&nbsp;will&nbsp;not&nbsp;take&nbsp;effect.&nbsp;This&nbsp;flag&nbsp;is&nbsp;only&nbsp;valid&nbsp;when&nbsp;specified&nbsp;with&nbsp;the&nbsp;CDS_UPDATEREGISTRY&nbsp;flag.&nbsp;&nbsp;<br>CDS_UPDATEREGISTRY&nbsp;The&nbsp;graphics&nbsp;mode&nbsp;for&nbsp;the&nbsp;current&nbsp;screen&nbsp;will&nbsp;be&nbsp;changed&nbsp;dynamically&nbsp;and&nbsp;the&nbsp;graphics&nbsp;mode&nbsp;will&nbsp;be&nbsp;updated&nbsp;in&nbsp;the&nbsp;registry.&nbsp;The&nbsp;mode&nbsp;information&nbsp;is&nbsp;stored&nbsp;in&nbsp;the&nbsp;USER&nbsp;profile.&nbsp;<br><br>谢谢大家关注。
 
多人接受答案了。
 
后退
顶部