Screen.Height - Me.Height - 300
Số 300 này chỉ là đoán mò về chiều cao của Taskbar. Lỡ người ta kéo taskbar lên thành 2 tầng thì sao
Hơn nữa, trong Windows Vista. Nếu ứng dụng của bạn khởi động cùng Windows (tức kích hoạt trước khi
Windows Desktop Manager active) thì
Screen.Width = Screen.Height -> SAI. gianghoplus cũng hok hiểu vì sao nữa
Muốn chính xác hơn ta xác định lun kích thước taskbar
Code: Select all
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd Type Private Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As LongEnd Type Private Type TBSIZE Width As Long Height As LongEnd Type Private Function Taskbar() As TBSIZE Dim tBar As APPBARDATA SHAppBarMessage &H5, tBar Taskbar.Height = (tBar.rc.Bottom - tBar.rc.Top) * 15 Taskbar.Width = (tBar.rc.Right - tBar.rc.Left) * 15End Function
Lúc này ta lấy chiều rộng của màn hình bằng với
Taskbar.Width thì ok
àh còn nữa. Trong Vista nếu chạy hiệu ứng trong suốt Aero thì lại phải tính thêm đường viền nữa
Code: Select all
Public Function VistaX() As ByteIf (GetOS = "Vista" Or GetOS = "Seven") And _GetDword(HKEY_CURRENT_USER, "Software\Microsoft\Windows\DWM", "Composition") = 1 Then _ VistaX = 100 Else VistaX = 0End Function
lúc đó sửa dòng Me.Left thành như thế này là ổn
Code: Select all
Me.Left = Taskbar.Width - Me.Width - VistaX