Visual Basic Tips


デスクトップ領域のサイズ取得(API)


デスクトップ領域(タスクバーやOfficeショートカットバーを除いた領域)のサイズ取得するにはGetSystemMetricsを使用します。

'--------------------------------------------------------
' Form
'--------------------------------------------------------
Private Sub Form_Load()
  Dim intScreenWidth As Integer
  Dim intScreenHeight As Integer

  intScreenWidth = GetSystemMetrics(SM_CXFULLSCREEN)
  intScreenHeight = GetSystemMetrics(SM_CYFULLSCREEN)

  MsgBox "デスクトップの領域は" & intScreenWidth & "×" & intScreenHeight
End Sub

'--------------------------------------------------------
' Module
'--------------------------------------------------------
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Public Const SM_CXFULLSCREEN = 16
Public Const SM_CYFULLSCREEN = 17


DownLoad vbtips111.lzh 2KB (VB6.0)