Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1768to1772
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 Balken mit X

Userform ohne Balken mit X
16.07.2020 13:12:04
Eberhard
Hallo zusammen
Ich möchte die Userform nur einblenden als Hinweis mit einem Text. Dies funktioniert auch. Möchte aber den Balken mit dem "X" oberhalb der UserForm entfernen? Habe schon viele Möglichkeiten in den Forum & google gefunden & getestet. Doch funktionieren diese bei mir nicht! Hat da vielleicht jemand eine Lösung? Besten Dank. Gruss Daniel

19
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Userform ohne Balken mit X
16.07.2020 13:25:28
Nepumuk
Hallo Eberhard,
teste mal:
Option Explicit

Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLongA Lib "user32.dll" ( _
    ByVal hWnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongA Lib "user32.dll" ( _
    ByVal hWnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
Private Declare PtrSafe Function DrawMenuBar Lib "user32.dll" ( _
    ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function SendMessageA Lib "user32.dll" ( _
    ByVal hWnd As LongPtr, _
    ByVal wMsg As Long, _
    ByVal wParam As LongPtr, _
    ByRef lParam As Any) As LongPtr
Private Declare PtrSafe Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare PtrSafe Function IsThemeActive Lib "uxtheme.dll" () As Long

Private Const GC_CLASSNAMEMSFORM As String = "ThunderDFrame"
Private Const GWL_STYLE As Long = -16&
Private Const WS_CAPTION As LongPtr = &HC00000
Private Const HTCAPTION As LongPtr = 2&
Private Const WM_NCLBUTTONDOWN As Long = &HA1

Private mlngptrHwnd As LongPtr

Private Sub UserForm_Activate()
    Dim lngptrStyle As Long
    mlngptrHwnd = FindWindowA(GC_CLASSNAMEMSFORM, Caption)
    lngptrStyle = GetWindowLongA(mlngptrHwnd, GWL_STYLE)
    lngptrStyle = lngptrStyle And Not WS_CAPTION
    Call SetWindowLongA(mlngptrHwnd, GWL_STYLE, lngptrStyle)
    Call DrawMenuBar(mlngptrHwnd)
    If IsThemeActive = 1 Then
        Height = Height - 16
    Else
        Height = Height - 14
    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 SendMessageA(mlngptrHwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
End Sub

Private Sub CommandButton1_Click()
    Call Unload(Me)
End Sub

Gruß
Nepumuk
Anzeige
AW: Userform ohne Balken mit X
16.07.2020 14:02:37
JoWE
Hallo Nepumuk,
sorry dass ich mich hier einmische, hatte Info-Bedarf zur gleichen Frage.
Da kommt bei mir "XL2019 64Bit" bei "Userform1.show" dieser Fehler:
Objekterstellung durch ActiveX-Komponente nicht möglich
Beim Start der Userform1 in der VBA-Umgebung kommt ein Fehler "Typen unverträglich! im Modul UserForm_Activate(). Und zwar hier: lngptrStyle = GetWindowLongA(mlngptrHwnd, GWL_STYLE)
Hier die Datei: https://www.herber.de/bbs/user/139107.xlsm
Gruß
Jochen
AW: Userform ohne Balken mit X
16.07.2020 14:20:03
Nepumuk
Hallo Jochen,
für 64Bit so:
Option Explicit

Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLongPtrA Lib "user32.dll" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongPtrA Lib "user32.dll" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
Private Declare PtrSafe Function DrawMenuBar Lib "user32.dll" ( _
    ByVal hwnd As LongPtr) As Long
Private Declare PtrSafe Function SendMessageA Lib "user32.dll" ( _
    ByVal hwnd As LongPtr, _
    ByVal wMsg As Long, _
    ByVal wParam As LongPtr, _
    ByRef lParam As Any) As LongPtr
Private Declare PtrSafe Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare PtrSafe Function IsThemeActive Lib "uxtheme.dll" () As Long

Private Const GC_CLASSNAMEMSFORM As String = "ThunderDFrame"
Private Const GWL_STYLE As Long = -16&
Private Const WS_CAPTION As LongPtr = &HC00000
Private Const HTCAPTION As LongPtr = 2&
Private Const WM_NCLBUTTONDOWN As Long = &HA1

Private mlngptrHwnd As LongPtr

Private Sub UserForm_Activate()
    Dim lngptrStyle As LongPtr
    mlngptrHwnd = FindWindowA(GC_CLASSNAMEMSFORM, Caption)
    lngptrStyle = GetWindowLongPtrA(mlngptrHwnd, GWL_STYLE)
    lngptrStyle = lngptrStyle And Not WS_CAPTION
    Call SetWindowLongPtrA(mlngptrHwnd, GWL_STYLE, lngptrStyle)
    Call DrawMenuBar(mlngptrHwnd)
    If IsThemeActive = 1 Then
        Height = Height - 16
    Else
        Height = Height - 14
    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 SendMessageA(mlngptrHwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
End Sub

Private Sub CommandButton1_Click()
    Call Unload(Me)
End Sub

Gruß
Nepumuk
Anzeige
AW: Userform ohne Balken mit X
16.07.2020 14:25:06
JoWE
Super!
Vielen Dank.
Jochen
AW: Userform ohne Balken mit X
16.07.2020 14:25:32
JoWE
Super!
Vielen Dank.
Jochen
AW: Userform ohne Balken mit X
16.07.2020 18:11:11
Eberhard
Hallo zusammen!
Das sieht ja super aus! Jedoch wird beim ersten mal ausführen der Bildschirmhintergrund schwarz. Die Userform bleibt aber stehen. Beim zweiten mal starten funktioniert es wunderbar! Weiter ist mir aufgefallen, dass plötzlich nach jedem Neustart vom PC das Excel automatisch öffnet. Hat dies mit dem Makro was zu tun? Gruss Daniel
AW: Userform ohne Balken mit X
16.07.2020 18:15:21
Nepumuk
Hallo Daniel,
dass plötzlich nach jedem Neustart vom PC das Excel automatisch öffnet
mit dem Makro kann das nicht zusammenhängen.
Gruß
Nepumuk
Anzeige
AW: Userform ohne Balken mit X
16.07.2020 20:07:44
Eberhard
Hallo Nepumuk
Habe das Makro bei mir zu Hause mal getestet. Starte ich den PC neu und öffne die Datei, sieht es das erste mal aus, als würde sich die Userform hintereinander (wie 2 mal) öffnen aus. Beim zweiten, dritten mal funktioniert es wunderbar!
Da wäre mal meine Datei. Vielleicht mache ich ja was falsch?
https://www.herber.de/bbs/user/139117.xlsm
Gruss Daniel
AW: Userform ohne Balken mit X
16.07.2020 20:10:42
Eberhard
Noch vergessen!
Das Makro ist noch nicht fertig. Getestet habe ich es, indem ich die Userform2 starte und den 1. Butten anklicke! Gruss Daniel
AW: Userform ohne Balken mit X
17.07.2020 08:20:52
Eberhard
Guten Morgen zusammen
Habe das Makro nochmals neu geschrieben. Es ist tatsächlich so, wenn ich das Makro ausführe, funktioniert es super! Schließe ich Excel und fahre den PC runter, starte den PC neu, öffnet sich automatisch eine leere Excel Datei. Öffne ich das Excel ohne das Makro auszuführen, schließe es wieder, PC neu starten, öffnet sich Excel nicht! Komisch! Hat da jemand eine Idee?
Ihr noch die Datei:
https://www.herber.de/bbs/user/139121.xlsm
Gruß und einen schönen Tag. Daniel
Anzeige
AW: Userform ohne Balken mit X
17.07.2020 08:29:45
Nepumuk
Hallo Daniel,
ich kann nur die 32Bit-Version testen und da passt es, ich kann das Verhalten an deinem Rechner nicht nachvollziehen. Das muss jemand testen der ein 64Bit Office hat.
Ich lass die Frage offen.
Gruß
Nepumuk
AW: Userform ohne Balken mit X
17.07.2020 10:13:18
volti
Hallo zusammen,
die beiden Phänomene "Schwarzer Bildschirm" und "Neue Mappe" nach Neustart kann ich unter Office 365 64 Bit bestätigen.
Nach Einsetzen von Doevents (s. code) kommt der schwarze Bildschirm bei mir nicht mehr.
Leider wird nach wie vor die Neue Mappe erzeugt.
Wegen der langen Prüfzeit kann ich da jetzt keinen Tipp herausarbeiten und lass den Thread mal offen...

[+][-]
Private Sub FindFiles(ByVal strFolderPath As String) #If Win64 Then Dim lngSearch As LongPtr #Else Dim lngSearch As Long #End If Dim WFD As WIN32_FIND_DATA, strDirName As String On Error GoTo ErrorHandling If Right(strFolderPath, 1) <> "&bsol;" Then strFolderPath = strFolderPath & "&bsol;" lngSearch = FindFirstFile(strFolderPath & "*.*", WFD) If lngSearch <> INVALID_HANDLE_VALUE Then Call GetFilesInFolder(strFolderPath) If mblnSubFolders Then Do If (WFD.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) Then strDirName = Left(WFD.cFileName, InStr(WFD.cFileName, vbNullChar) - 1) If (strDirName <> ".") And (strDirName <> "..") Then _ Call FindFiles(strFolderPath & strDirName) End If DoEvents Loop While FindNextFile(lngSearch, WFD) End If Call FindClose(lngSearch) End If Exit Sub ErrorHandling: MsgBox "Fehler " & CStr(Err.Number) & vbLf & vbLf & _ Err.Description, vbCritical, "Fehler" End Sub
viele Grüße aus Freigericht
Karl-Heinz

Anzeige
AW: Userform ohne Balken mit X
17.07.2020 20:40:03
Eberhard
Hallo zusammen
Habe das Makro im Geschäft sowohl auch zu Hause getestet. Bis jetzt scheint es zu funktionieren!
Dies wegen der neuen Mappe hat sich vielleicht auch erledigt. Dies könnte ein Problem von Microsoft sein. Schliesst man Windows mit der Tastenkombination ALT+F4 & Starte den PC neu. Dann sollte sich Excel nicht mehr öffnen! Bei mir hat es jedenfalls funktioniert!
Vielen Dank. Schönes Wochenende.
Gruss Daniel
AW: Userform ohne Balken mit X
16.07.2020 14:24:37
volti
Hallo Jochen,
die beiden Funktionen brauchen unter 64Bit andere Funktionen. Wenn wir die von Nepumuk verwendeten Funktionen weiter verwenden wollen, muss der Alias angepasst werden.
Außerdem muss Dim lngptrStyle As Long => Dim lngptrStyle As LongPtr werden.
Hier Dein code:

[+][-]
Option Explicit Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As LongPtr Private Declare PtrSafe Function GetWindowLongA Lib "user32" Alias "GetWindowLongPtrA" ( _ ByVal hwnd As LongPtr, _ ByVal nIndex As Long) As LongPtr Private Declare PtrSafe Function SetWindowLongA Lib "user32" Alias "SetWindowLongPtrA" ( _ ByVal hwnd As LongPtr, _ ByVal nIndex As Long, _ ByVal dwNewLong As LongPtr) As LongPtr Private Declare PtrSafe Function DrawMenuBar Lib "user32.dll" ( _ ByVal hwnd As LongPtr) As Long Private Declare PtrSafe Function SendMessageA Lib "user32.dll" ( _ ByVal hwnd As LongPtr, _ ByVal wMsg As Long, _ ByVal wParam As LongPtr, _ ByRef lParam As Any) As LongPtr Private Declare PtrSafe Function ReleaseCapture Lib "user32.dll" () As Long Private Declare PtrSafe Function IsThemeActive Lib "uxtheme.dll" () As Long Private Const GC_CLASSNAMEMSFORM As String = "ThunderDFrame" Private Const GWL_STYLE As Long = -16& Private Const WS_CAPTION As LongPtr = &HC00000 Private Const HTCAPTION As LongPtr = 2& Private Const WM_NCLBUTTONDOWN As Long = &HA1 Private mlngptrHwnd As LongPtr Private Sub UserForm_Activate() Dim lngptrStyle As LongPtr mlngptrHwnd = FindWindowA(GC_CLASSNAMEMSFORM, Caption) lngptrStyle = GetWindowLongA(mlngptrHwnd, GWL_STYLE) lngptrStyle = lngptrStyle And Not WS_CAPTION Call SetWindowLongA(mlngptrHwnd, GWL_STYLE, lngptrStyle) Call DrawMenuBar(mlngptrHwnd) If IsThemeActive = 1 Then Height = Height - 16 Else Height = Height - 14 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 SendMessageA(mlngptrHwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&) End If End Sub Private Sub CommandButton1_Click() Call Unload(Me) End Sub
viele Grüße aus Freigericht
Karl-Heinz

Anzeige
AW: Userform ohne Balken mit X
16.07.2020 15:07:48
JoWE
Hallo Karl-Heijz,
auch Dir gilt mein Dank!
Gruß
Jochen
AW: Userform ohne Balken mit X
16.07.2020 14:25:01
Eberhard
Hallo Nepumuk
Ich habe das ganze in die UserForm geschrieben. Leider krieg ich einen Fehler! Fehler beim Kompilieren. Typen unverträglich!
Dann springt er mir auf folgende Zeile und markiert mir das Wort GetWindowLongA!
    lngptrStyle = GetWindowLongA(mlngptrHwnd, GWL_STYLE)

Gruss Daniel
Eberhard oder Daniel?!?
18.07.2020 18:34:34
Oberschlumpf
ich bin verwirrt

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige