程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 用VB改變屏幕的分辨率和刷新頻率

用VB改變屏幕的分辨率和刷新頻率

編輯:VB綜合教程

  OptionExplicit

  PublicDeclareFunctionChangeDisplaySettingsLib"user32.dll"Alias"ChangeDisplaySettingsA"

  (ByReflpDevModeAsDEVMODE,ByValdwFlagsAsLong)AsLong
  PublicDeclareFunctionEnumDisplaySettingsLib"user32.dll"Alias"EnumDisplaySettingsA"(ByVal

  lpszDeviceNameAsString,ByValiModeNumAsLong,ByReflpDevModeAsDEVMODE)AsLong

  ConstDM_PELSHEIGHTAsLong=&H100000
  ConstDM_PELSWIDTHAsLong=&H80000
  ConstDM_BITSPERPELAsLong=&H40000
  ConstDM_DISPLAYFREQUENCYAsLong=&H400000

  ConstCCHDEVICENAMEAsLong=32
  ConstCCHFORMNAMEAsLong=32
  ConstCDS_TEST=&H4

  PrivateTypeDEVMODE
  dmDeviceNameAsString*CCHDEVICENAME
  dmSpecVersionAsInteger
  dmDriverVersionAsInteger
  dmSizeAsInteger
  dmDriverExtraAsInteger
  dmFieldsAsLong
  dmOrientationAsInteger
  dmPaperSizeAsInteger
  dmPaperLengthAsInteger
  dmPaperWidthAsInteger
  dmScaleAsInteger
  dmCopiesAsInteger
  dmDefaultSourceAsInteger
  dmPrintQualityAsInteger
  dmColorAsInteger
  dmDuplexAsInteger
  dmYResolutionAsInteger
  dmTTOptionAsInteger
  dmCollateAsInteger
  dmFormNameAsString*CCHFORMNAME
  dmUnusedPaddingAsInteger
  dmBitsPerPelAsInteger
  dmPelsWidthAsLong
  dmPelsHeightAsLong
  dmDisplayFlagsAsLong
  dmDisplayFrequencyAsLong
  EndType

  '-------------------------------------------------------------------------------------------
  'LngWidth//屏幕的寬(單位象素)
  'LngHeight//屏幕的高(單位象素)
  'IntColor//多少位顏色(e.g16or32)
  'LngFrequency//屏幕的刷新頻率
  '
  '聲明:
  '調用該函數時要確定所設置的值在系統所允許的設置范圍內,比如系統的最大刷新頻率位80,而你
  '用把LngFrequency設位85,這樣將帶來無法預測的後果。
  '------------------------------------------------------------------------------------------
  PublicFunctionSetDisplaymode(LngWidthAsLong,LngHeightAsLong,IntColorAsInteger,

  LngFrequencyAsLong)AsLong
  DimNewDevmodeAsDEVMODE
  DimlngPAsLong
  
  'obtainsinformation
  EnumDisplaySettings0&,0&,NewDevmode
  
  WithNewDevmode
  .dmFields=DM_PELSHEIGHTOrDM_PELSWIDTHOrDM_BITSPERPELOrDM_DISPLAYFREQUENCY
  .dmPelsWidth=LngWidth
  .dmPelsHeight=LngHeight
  .dmBitsPerPel=IntColor
  .dmDisplayFrequency=LngFrequency
  EndWith
  
  SetDisplaymode=ChangeDisplaySettings(NewDevmode,CDS_TEST)
  EndFunction

->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved