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

  1. 1、本文档共11页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
VB代码获得当前计算机屏幕的分辨率

首先:如何获得当前计算机屏幕的分辨率? 方法一: Private Const SPI_GETWORKAREA = 48 Private Declare Function SystemParametersInfo Lib user32 Alias _ ???? SystemParametersInfoA (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long Public 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.Bottom End Sub 注意,上述得到的是可视屏幕的分辨率,如果任务栏可见,则任务栏的高度排除在外。 2.根据取得的分辨率再循环所有的控件依次改变控件属性。 方法二: ***************************************************************** DECLARATIONS SECTION ***************************************************************** Option Explicit Type RECT ??? x1 As Long ??? y1 As Long ??? x2 As Long ??? y2 As Long End Type NOTE: The following declare statements are case sensitive. Declare Function GetDesktopWindow Lib User32 () As Long Declare 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例 例一、 Declare Function GetDesktopWindow Lib USER32 () As Long Declare Function GetWindowRect Lib USER32 (ByVal hWnd As Long, rectangle As RECT) As Long 这个函数可以使你开发的程序适应各种分辨率,这是我见过的最完美的解决方案!强列推荐 如果你是在1024*768的分辨率下写的程序,就把下面那句改为 Const DesignSize = 102

您可能关注的文档

文档评论(0)

xjj2017 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档