' ウィンドウの移動、サイズ指定 Declare Function MoveWindow Lib "user32" _ (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, _ ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long ' ウィンドウサイズの取得 Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long ' タスクバー情報の取得 Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As Long End Type Declare Function SHAppBarMessage Lib "shell32.dll" _ (ByVal dwMessage As Long, pData As APPBARDATA) As Long Const ABM_GETSTATE = &H4 Const ABM_GETTASKBARPOS = &H5 Const ABS_AUTOHIDE = &H1 Const ABS_ALWAYSONTOP = &H2 Const ABE_LEFT = 0 Const ABE_TOP = 1 Const ABE_RIGHT = 2 Const ABE_BOTTOM = 3 Public Sub Sample1() Dim wRECT As RECT Dim lngRet As Long ' Access のウィンドウサイズの取得 lngRet = GetWindowRect(Application.hWndAccessApp, wRECT) lngRet = MoveWindow(Application.hWndAccessApp, wRECT.Left, wRECT.Top, 800, 600, True) End Sub Public Sub Sample2() Dim Bardata As APPBARDATA Dim lngState As Long Dim lngRet As Long Dim lngTop As Integer Dim lngLeft As Integer ' タスクバーが『自動的に隠す』となっていた場合、タスクバーの表示位置は無視 lngState = SHAppBarMessage(ABM_GETSTATE, Bardata) If (lngState And ABS_AUTOHIDE) = ABS_AUTOHIDE Then lngTop = 0 lngLeft = 0 Else lngState = SHAppBarMessage(ABM_GETTASKBARPOS, Bardata) ' タスクバーが上部に配置されている場合 If Bardata.uEdge = ABE_TOP Then lngTop = Bardata.rc.Bottom lngLeft = 0 ' タスクバーが左側に配置されている場合 ElseIf Bardata.uEdge = ABE_LEFT Then lngTop = 0 lngLeft = Bardata.rc.Right Else lngTop = 0 lngLeft = 0 End If End If lngRet = MoveWindow(Application.hWndAccessApp, lngLeft, lngTop, 800, 600, True) End Sub