电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

VB代码获得当前计算机屏幕的分辨率

VB代码获得当前计算机屏幕的分辨率_第1页
1/11
VB代码获得当前计算机屏幕的分辨率_第2页
2/11
VB代码获得当前计算机屏幕的分辨率_第3页
3/11
首先:如何获得当前计算机屏幕的分辨率?方法一:Private Const SPI_GETWORKAREA = 48Private Declare Function SystemParametersInfo Lib "user32" Alias _ "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As LongPublic Type RECT Left As Long '矩形左上角的 X 坐标 Top As Long '矩形左上角的 Y 坐标 Right As Long '矩形右下角的 X 坐标 Bottom As Long '矩形右下角的 Y 坐标End Type Private Sub Command0_Click() Dim lRet As Long Dim apiRECT As RECT lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0) MsgBox apiRECT.Right & "X" & apiRECT.BottomEnd Sub注意,上述得到的是可视屏幕的分辨率,假如任务栏可见,那么任务栏的高度排除在外。 2.根据取得的分辨率再循环所有的控件依次改变控件属性。方法二:'*****************************************************************' DECLARATIONS SECTION'*****************************************************************Option ExplicitType RECT x1 As Long y1 As Long x2 As Long y2 As LongEnd Type' NOTE: The following declare statements are case sensitive.Declare Function GetDesktopWindow Lib "User32" () As LongDeclare Function GetWindowRect Lib "User32" _ (ByVal hWnd As Long, rectangle As RECT) As Long'*****************************************************************' FUNCTION: GetScreenResolution()'' PURPOSE:' To determine the current screen size or resolution.'' RETURN:' The current screen resolution. Typically one of the following:' 640 x 480' 800 x 600' 1024 x 768''*****************************************************************Function GetScreenResolution () as String Dim R As RECT Dim hWnd As Long Dim RetVal As Long hWnd = GetDesktopWindow() RetVal = GetWindowRect(hWnd, R) GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)End Function然后:自动适应电脑显示器各种分辨率 2 例例一、1. Declare ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

VB代码获得当前计算机屏幕的分辨率

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部