Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1868to1872
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

Declare Fuktion

Declare Fuktion
14.02.2022 06:59:37
Hape
Hallo ans Forum,
habe hier einen Code bei Euch gefunden. Leider funktioniert er bei Excel 64 bit nicht.
Kann mir jemand dabei helfen, dass es bei 32 und 64 Bit funktioniert. Ich bekomme es einfach nicht hin.
Grüße Hape

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Declare Fuktion
14.02.2022 07:03:34
Hape
Die Datei hochladen funktioniert irgendwie nicht!!
Daher hier der Code. Ed geht darum die Titelleiste der Userform auszublenden.
  • Option Explicit
    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong _
    Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function DrawMenuBar Lib "user32" ( _
    ByVal hwnd As Long) As Long
    
    Private Sub CommandButton1_Click()
    Call fncHasUserformCaption(True)
    End Sub
    
    
    Private Sub CommandButton2_Click()
    Call fncHasUserformCaption(False)
    End Sub
    
    
    Private Sub CommandButton3_Click()
    Unload Me
    End Sub
    
    
    Private Sub UserForm_Initialize()
    Call fncHasUserformCaption(False)
    End Sub
    
    
    Private Function fncHasUserformCaption(bState As Boolean)
    Dim Userform_hWnd As Long
    Dim Userform_Style As Long
    Dim Userform_Rect As RECT
    Const GWL_STYLE = (-16)
    Const WS_CAPTION = &HC00000
    Userform_hWnd = FindWindow( _
    lpClassName:=IIf(Val(Application.Version) > 8, _
    "ThunderDFrame", "ThunderXFrame"), _
    lpWindowName:=Me.Caption)
    Userform_Style = GetWindowLong(hwnd:=Userform_hWnd, _
    nIndex:=GWL_STYLE)
    If bState = True Then
    Userform_Style = Userform_Style Or WS_CAPTION
    Else
    Userform_Style = Userform_Style And Not WS_CAPTION
    End If
    Call SetWindowLong(hwnd:=Userform_hWnd, nIndex:=GWL_STYLE, _
    dwNewLong:=Userform_Style)
    Call DrawMenuBar(hwnd:=Userform_hWnd)
    End Function
    

  • Anzeige
    AW: Declare Fuktion
    14.02.2022 09:04:11
    Nepumuk
    Hallo Hape,
    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 DrawMenuBar Lib "user32.dll" ( _
    ByVal hwnd As LongPtr) As Long
    #If Win64 Then
    Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongPtrA" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
    Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongPtrA" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
    #Else
    Private Declare PtrSafe Function GetWindowLongPtr Lib "user32.dll" Alias "GetWindowLongA" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long) As LongPtr
    Private Declare PtrSafe Function SetWindowLongPtr Lib "user32.dll" Alias "SetWindowLongA" ( _
    ByVal hwnd As LongPtr, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As LongPtr) As LongPtr
    #End If
    Private Sub CommandButton1_Click()
    Call fncHasUserformCaption(True)
    End Sub
    Private Sub CommandButton2_Click()
    Call fncHasUserformCaption(False)
    End Sub
    Private Sub CommandButton3_Click()
    Unload Me
    End Sub
    Private Sub UserForm_Initialize()
    Call fncHasUserformCaption(False)
    End Sub
    Private Sub fncHasUserformCaption(bState As Boolean)
    Dim Userform_hWnd As LongPtr
    Dim Userform_Style As LongPtr
    Const GWL_STYLE = (-16)
    Const WS_CAPTION = &HC00000
    Userform_hWnd = FindWindowA(lpClassName:="ThunderDFrame", lpWindowName:=Caption)
    Userform_Style = GetWindowLongPtr(hwnd:=Userform_hWnd, nIndex:=GWL_STYLE)
    If bState Then
    Userform_Style = Userform_Style Or WS_CAPTION
    Else
    Userform_Style = Userform_Style And Not WS_CAPTION
    End If
    Call SetWindowLongPtr(hwnd:=Userform_hWnd, nIndex:=GWL_STYLE, dwNewLong:=Userform_Style)
    Call DrawMenuBar(hwnd:=Userform_hWnd)
    End Sub
    
    Gruß
    Nepumuk
    Anzeige
    AW: Declare Fuktion
    14.02.2022 17:13:57
    Hape
    Hallo Nepumuk,
    recht herzlichen Dank, für Deine Mühe. Funktioniert alles ohne Probleme.
    WIRKLICH SUPER
    Viele Grüße Hape
    AW: Declare Fuktion
    14.02.2022 17:17:33
    Hape
    Als solchen sehe ich Dich auch nicht!!!
    AW: Declare Fuktion
    14.02.2022 17:20:43
    SF
    Hola,
    http://www.excel-ist-sexy.de/crossposting/
    vielleicht siehst du es ja nach Studieren des Links etwas anders.
    Gruß,
    steve1da
    Anzeige

    Links zu Excel-Dialogen

    Beliebteste Forumthreads (12 Monate)

    Anzeige

    Beliebteste Forumthreads (12 Monate)

    Anzeige
    Anzeige
    Anzeige