AW: Die Länge noch!
31.01.2009 20:06:00
Tino
Hallo,
in erster Linie über Google, da gibt es schlauerer Leute wie mich. ;-)
Mit etwas Geduld und einer gewissen Hartnäckigkeit, findet man fasst alles.
Naja mansche Sachen nur für VB5 oder 6, aber dies kann man recht leicht auf Excel umstricken.
Hier noch ein Beispiel für die Höhe, es wird die Größe der Task bar berücksichtigt.
Bei mir hat es funktioniert, kannst ja mal testen.
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal _
hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal _
hMenu As Long, ByVal nPosition As Long, ByVal wFlags _
As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32.dll" ( _
ByVal nIndex As Long) As Long
Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, _
lpRect As xRECT) As Long
Private Type xRECT ' Datentyp Rechteck (Koordinaten)
rX1 As Long ' links
rY1 As Long ' oben
rX2 As Long ' rechts
rY2 As Long ' unten
End Type
Private Const SM_CXSCREEN = 0&
Private Const MF_BYCOMMAND = &H0
Private Const SC_MOVE = &HF010
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim hRect As xRECT
Dim hwnd As Long, hRes As Long, hwndForm As Long, hwndMenu As Long
hwnd = FindWindow("Shell_traywnd", "") ' Handle TBarWindow ermitteln
hRes = GetWindowRect(hwnd, hRect)
hwndForm = FindWindow(vbNullString, Me.Caption)
hwndMenu = GetSystemMenu(hwndForm, 0)
DeleteMenu hwndMenu, SC_MOVE, MF_BYCOMMAND
With Me
.StartUpPosition = 0
.Top = 0
.Left = GetSystemMetrics(SM_CXSCREEN) * 0.75 - .Width
.Height = hRect.rY1 * 0.75
End With
End Sub
Gruß Tino