ich habe eine Datei gefunden (ausForum), da wird die UF ohne
Rahmen dargestellt.
Nun weiß ich nicht, was ich ändern muss um die UF in die Richtige
Position zu bringen.
Ich möchte gern das die UF genau passend in meine Zeile1 eingepaßt
wird und sich dann nicht verschiebt.
Anbei das Makro, welches dazu gehört.
mfg
philipp
Option Explicit
' Userform mit einem CommandButton (CoEnde), um die Userform
' zu schließen. Mit rechtsklick auf die Maus in der Userform
' wird diese ebenfalls geschlossen. Abschnitt:
' UserForm_MouseDown zum Schließen, dieser Teil ist auskommentiert
' von GraFri
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As _
Long, lpRect As RECT) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, _
ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, _
ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private FensterRegion&, Region&
Private Hauptfensternummer&, Clientfensternummer&
Private dummy As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const GW_CHILD = 5
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub UserForm_Initialize()
Call FensterOhneKopf
End Sub
Sub FensterOhneKopf()Dim Abmessung As RECT
Dim Abmessung1 As RECT
Dim Pos1x&, Pos1y&, Pos2x&, Pos2y&
If FensterRegion 0 Then Exit Sub
UserForm1.BorderStyle = fmBorderStyleSingle
Call Fensternummer(UserForm1, Abmessung, Abmessung1)
Pos1x = 0
Pos1y = (Abmessung1.Top - Abmessung.Top)
Pos2x = Abmessung.Right - Abmessung.Left
Pos2y = Abmessung.Bottom - Abmessung.Top
Region = CreateRectRgn(Pos1x, Pos1y, Pos2x, Pos2y)
FensterRegion = SetWindowRgn(Hauptfensternummer, Region, True)
End Sub 'Fensterhandles und Infos über Fenster holen
Private Sub Fensternummer(Form As Object, Abmessung As RECT, Abmessung1 As RECT)
Dim Fenstername$, Suchstring$
Suchstring = "UserForm ohne Titelzeile"
Fenstername = Form.Caption
Form.Caption = Suchstring
Hauptfensternummer = FindWindow(vbNullString, Suchstring)
Form.Caption = Fenstername
Clientfensternummer = GetWindow(Hauptfensternummer, GW_CHILD)
dummy = GetWindowRect(Hauptfensternummer, Abmessung)
dummy = GetWindowRect(Clientfensternummer, Abmessung1)
End Sub
'Folgendes ist notwendig, um die Form ohne Titelleiste zu verschieben'
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, _
'ByVal X As Single, ByVal Y As Single)
' If Button = 1 Then
' If Hauptfensternummer 0 Then
' dummy = ReleaseCapture()
' dummy = SendMessage(Hauptfensternummer, WM_NCLBUTTONDOWN, HTCAPTION, 0)
' End If
' Else
' Unload UserForm1 ' zum Schließen, beim Ausprobieren.
' End If
'End Sub
Private Sub CoEnde_Click()
Unload Me
End Sub