vb中修改屏幕分辨率

前端之家收集整理的这篇文章主要介绍了vb中修改屏幕分辨率前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在窗体上画一个按钮和四个文本框,运行如下代码:启动时,显示相应数据。修改后,单击按钮改变设置。

 
 
  1. OptionExplicit
  2. PrivateDeclareFunctionGetDeviceCapsLib@H_301_30@"gdi32"(ByValhdcAsLong,ByValnIndexAsLong)AsLong
  3. PrivateDeclareFunctionChangeDisplaySettingsLib@H_301_30@"user32"Alias@H_301_30@"ChangeDisplaySettingsA"(lpDevModeAsAny,ByValdwflagsAsLong)AsLong
  4. PrivateConstCCDEVICENAMEAsLong=32
  5. PrivateConstCCFORMNAMEAsLong=32
  6. PrivateConstDM_BITSPERPELAsLong=&H40000
  7. PrivateConstDM_PELSWIDTHAsLong=&H80000
  8. PrivateConstDM_PELSHEIGHTAsLong=&H100000
  9. PrivateConstDM_DISPLAYFLAGSAsLong=&H200000
  10. PrivateConstDM_DISPLAYFREQUENCY=&H400000
  11. PrivateConstCDS_FORCEAsLong=&H80000000
  12. PrivateConstBITSPIXELAsLong=12
  13. PrivateConstHORZRESAsLong=8
  14. PrivateConstVERTRESAsLong=10
  15. PrivateConstVREFRESH=116
  16. PrivateTypeDEVMODE
  17. dmDeviceNameAsString*CCDEVICENAME
  18. dmSpecVersionAsInteger
  19. dmDriverVersionAsInteger
  20. dmSizeAsInteger
  21. dmDriverExtraAsInteger
  22. dmFieldsAsLong
  23. dmOrientationAsInteger
  24. dmPaperSizeAsInteger
  25. dmPaperLengthAsInteger
  26. dmPaperWidthAsInteger
  27. dmScaleAsInteger
  28. dmCopiesAsInteger
  29. dmDefaultSourceAsInteger
  30. dmPrintQualityAsInteger
  31. dmColorAsInteger
  32. dmDuplexAsInteger
  33. dmYResolutionAsInteger
  34. dmTTOptionAsInteger
  35. dmCollateAsInteger
  36. dmFormNameAsString*CCFORMNAME
  37. dmUnusedPaddingAsInteger
  38. dmBitsPerPelAsInteger
  39. dmPelsWidthAsLong
  40. dmPelsHeightAsLong
  41. dmDisplayFlagsAsLong
  42. dmDisplayFrequencyAsLong
  43. EndType
  44. PrivateSubcommand1_Click()
  45. DimDMAsDEVMODE
  46. WithDM
  47. .dmPelsWidth=CInt(Text1.Text)
  48. .dmPelsHeight=CInt(Text2.Text)
  49. .dmBitsPerPel=CInt(Text3.Text)
  50. .dmDisplayFrequency=CInt(Text4.Text)
  51. .dmFields=DM_PELSWIDTHOrDM_PELSHEIGHTOrDM_BITSPERPELOrDM_DISPLAYFREQUENCY
  52. .dmSize=LenB(DM)
  53. EndWith
  54. IfChangeDisplaySettings(DM,CDS_FORCE)<>0Then
  55. MsgBox@H_301_30@"错误!不支持此模式!"
  56. EndIf
  57. EndSub
  58. PrivateSubForm_Load()
  59. Text1.Text=GetDeviceCaps(Me.hdc,HORZRES)
  60. Text2.Text=GetDeviceCaps(Me.hdc,VERTRES)
  61. Text3.Text=GetDeviceCaps(Me.hdc,BITSPIXEL)
  62. Text4.Text=GetDeviceCaps(Me.hdc,VREFRESH)
  63. EndSub

猜你在找的VB相关文章