Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1120to1124
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Userform ohne überschrift und ohne Löschbutton

Userform ohne überschrift und ohne Löschbutton
Lutz
Hallo,
wie kann ich in einer Userform die blaue "Caption-Leiste" und den "Exit-Button" entfernen, das diese beim Aufruf nicht mit erscheinen?
M.f.G.
Lutz
AW: Userform ohne überschrift und ohne Löschbutton
28.11.2009 15:41:56
Jens
Hallo
'in das Modul der Userform
Option Explicit
Private Declare Function CreateRoundRectRgn Lib "gdi32" _
(ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long, _
ByVal X3 As Long, ByVal Y3 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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub UserForm_Initialize()
Me.Width = 350: Me.Height = 350
Commandbutton1.Left = (Me.Width - Commandbutton1.Width) / 3
Commandbutton1.Top = Me.Height * 0.6
End Sub
Private Sub UserForm_Activate()
Dim x As Long, y As Long, n As Long, mWnd As Long
x = Me.Width
y = Me.Height
n = 4
mWnd = FindWindow(vbNullString, Me.Name)
SetWindowRgn mWnd, CreateRoundRectRgn(2, 2, x, y, n, n), True
End Sub
Gruß Jens
Anzeige
AW: Userform ohne überschrift und ohne Löschbutton
28.11.2009 16:11:25
Nepumuk
Hallo Jens,
da hast du wohl die falsche Prozedur erwischt. Denn dein Code schneidet bei meinem Userform links und rechts etwas ab. Ohne Titelleiste geht so:
' **********************************************************************
' Modul: UserForm1 Typ: Userform
' **********************************************************************

Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
    ByVal hWnd As Long, _
    ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
    ByVal hWnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32.dll" ( _
    ByVal hWnd As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByRef lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long

Private Const GC_CLASSNAMEMSEXCELFORM = "ThunderDFrame"
Private Const GWL_STYLE = -16&
Private Const WS_CAPTION = &HC00000
Private Const HTCAPTION = 2&
Private Const WM_NCLBUTTONDOWN = &HA1

Private hWndForm As Long

Private Sub UserForm_Activate()
    hWndForm = FindWindow(GC_CLASSNAMEMSEXCELFORM, Me.Caption)
    If hWndForm <> 0 Then
        Call SetWindowLong(hWndForm, GWL_STYLE, GetWindowLong(hWndForm, _
            GWL_STYLE) And Not WS_CAPTION)
        Call DrawMenuBar(hWndForm)
    End If
End Sub

Private Sub UserForm_MouseDown(ByVal Button As Integer, _
        ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

    If Button = 1 Then
        Call ReleaseCapture
        Call SendMessage(hWndForm, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
End Sub

Gruß
Nepumuk
Anzeige
AW: Userform ohne überschrift und ohne Löschbutton
28.11.2009 16:19:11
Lutz
Hallo Jens,
habe den Code in eine Userform eingebunden.
Die blau hinterlegte überschrift wird dabei nicht ausgeblendet.
Habe ich da etwas übersehen?
M.f.G.
Lutz
AW: Userform ohne überschrift und ohne Löschbutton
29.11.2009 10:05:09
Lutz
Hallo Jens, Nepumuk und Hary,
vielen Dank für Eure Hilfe. (:-)
Lutz

104 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige