Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
860to864
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
860to864
860to864
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Schließen Kreuz

Schließen Kreuz
20.04.2007 13:59:00
Heiko
Hi Leute
gibt es eine möglichkeit in einer MsgBox das Rote Schließen Kreuz rechts in der Ecke zu entfernen. Das heißt das ich nur über den Ok oder den Abbrechen Button die MsgBox Schließen kann?
Gruß Heiko

10
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Schließen Kreuz
20.04.2007 14:07:00
Born
Hallo Heiko,
in Excel selbst ist das nicht machbar. Das ganze geht nur, wenn Du die komplette Titelleiste mit Hilfe von API-Funktionen ausblendest. Ich habe das mal vor Jahren im Web gefunden, spaßeshalber getestet und es hat auch funktioniert, aber den Code habe ich nicht mehr.
Viele Grüße,
M. Born

AW: Schließen Kreuz
20.04.2007 14:36:03
Heiko
Hi M.Born
danke für deine Antwort ich werd es mal im Netz versuchen aber sollte einer einen Code für das Schließen Kreuz ausblenden haben dann könnte er mir ihn schicken. Danke im vorraus.
Gruß Heiko

AW: Schließen Kreuz
20.04.2007 14:52:00
Heinz
Hi,
welchen soll das Ganze haben?
mfg Heinz

Anzeige
AW: Schließen Kreuz
21.04.2007 09:21:28
Nepumuk
Hallo Heiko,
eine Möglichkeit (es gibt wie immer verschiedene :-) )
' **********************************************************************
' Modul: Modul4 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Function GetVbaProjekt Lib "vba332.dll" Alias "EbGetExecutingProj" ( _
    ByRef hVBA As Long) As Long
Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" ( _
    ByVal idHook As Long, _
    ByVal lpfn As Long, _
    ByVal hmod As Long, _
    ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32.dll" ( _
    ByVal hHook As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32.dll" () 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 Const HCBT_ACTIVATE = 5&
Private Const WH_CBT = 5&
Private Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000

Private hHook As Long

Private Function WinProc(ByVal lMsg As Long, ByVal wParam _
        As Long, ByVal lParam As Long) As Long

    If lMsg = HCBT_ACTIVATE Then
        SetWindowLong wParam, GWL_STYLE, _
            GetWindowLong(wParam, GWL_STYLE) And Not WS_SYSMENU
        DrawMenuBar wParam
        UnhookWindowsHookEx hHook
    End If
    WinProc = False
End Function

Public Sub prcShowBox4() 'Schließenkreuz weg
    Dim hInst As Long, Thread As Long
    GetVbaProjekt hInst
    Thread = GetCurrentThreadId()
    hHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc, _
        hInst, Thread)
    MsgBox "Hallo, da bin ich", 64, "Information"
End Sub

Gruß
Nepumuk

Anzeige
AW: Schließen Kreuz
21.04.2007 12:26:58
Nico
Hi,
"...eine Möglichkeit (es gibt wie immer verschiedene :-) )..."
Kannst du noch eine Lösung ohne die vba332.dll einstellen, diese ist unter Win XP nicht
vorhanden, weder XP Home noch XP Pro.
mfg Nico

AW: Schließen Kreuz
21.04.2007 12:41:14
Nepumuk
Hallo Nico,
die könntest du dir hier auch runterladen: http://www.dll-files.com/dllindex/dll-files.shtml?vba332
Einfach in das Systemverzeichnis (C:\WINDOWS\system32) kopieren.
Aber es geht natürlich auch ohne:
' **********************************************************************
' Modul: Modul5 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
Private Declare Function SetTimer Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal nIDEvent As Long, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal nIDEvent As Long) 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 Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private Const GC_CLASSNAMEMSDIALOG = "#32770"

Private Const BOX_TITLE = "Information"

Private XL_hWnd As Long, BOX_hWnd As Long

Public Sub prcShowBox5() 'Schließenkreuz weg
    XL_hWnd = FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
    SetTimer XL_hWnd, 0, 10, AddressOf prcTimer
    MsgBox "Hallo, da bin ich", 64, BOX_TITLE
End Sub

Private Sub prcTimer(ByVal hWnd As Long, ByVal nIDEvent As Long, _
        ByVal uElapse As Long, ByVal lpTimerFunc As Long)

    Call prcKillTimer
    Call prcSetWindow
End Sub

Private Sub prcKillTimer()
    KillTimer XL_hWnd, 0
End Sub

Private Sub prcSetWindow()
    BOX_hWnd = FindWindow(GC_CLASSNAMEMSDIALOG, BOX_TITLE)
    If BOX_hWnd <> 0 Then
        SetWindowLong BOX_hWnd, GWL_STYLE, _
            GetWindowLong(BOX_hWnd, GWL_STYLE) And Not WS_SYSMENU
        DrawMenuBar BOX_hWnd
    End If
End Sub

Gruß
Nepumuk

Anzeige
Super, danke! oT
21.04.2007 13:02:00
Nico
oT

AW: Schließen Kreuz
22.04.2007 13:43:35
Heiko
Hi Leute
danke für eure hilfe klappt super. Ich hätte da aber noch 2 Fragen.
1. Was hat das mit der dll vba332 auf sich?
2. Wie kann ich den Button von der MsgBox bestimmen. Das heißt wenn ich zb. auf Ja klicke das dann eine MsgBox aufgeht und wenn ich auf Nein klicke das dann eine 2 MsgBox auf geht mit einem Text. Mit dem Code den ich hier habe klappt das zwar mit den MsgBoxen aber das Schleißen Kreuz ist da. Wie kann man das mit eurem Code bestimmen.
gruß Heiko

Sub Schaltfläche8_BeiKlick()
Frage = MsgBox("Text Nummer eins !!!", vbExclamation + vbYesNo)
If Frage = 6 Then MsgBox ("Text Nummer zwei")
If Frage = 7 Then Frage = MsgBox("Text Nummer drei !!!")
End Sub


Anzeige
AW: Schließen Kreuz
22.04.2007 14:07:00
Nepumuk
Hallo Heiko,
1. Die Funktion aus der vba332.dll benötige ich um das Handle (ein Pointer im Stackframe) der aufrufenden Prozedur zu bekommen. Damit kann ich dann den Hook auf die Msgbox setzen.
2. Versuch es mal einfach so:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
Private Declare Function SetTimer Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal nIDEvent As Long, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal nIDEvent As Long) 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 Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private Const GC_CLASSNAMEMSDIALOG = "#32770"

Private Const BOX_TITLE = "Microsoft Excel"

Private XL_hWnd As Long, BOX_hWnd As Long

Public Sub Schaltfläche8_BeiKlick()
    XL_hWnd = FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
    SetTimer XL_hWnd, 0, 10, AddressOf prcTimer
    If MsgBox("Text Nummer eins !!!", vbExclamation + vbYesNo, BOX_TITLE) = vbYes Then
        SetTimer XL_hWnd, 0, 10, AddressOf prcTimer
        MsgBox "Text Nummer zwei", vbOKOnly, BOX_TITLE
    Else
        SetTimer XL_hWnd, 0, 10, AddressOf prcTimer
        MsgBox "Text Nummer drei !!!", vbOKOnly, BOX_TITLE
    End If
End Sub

Private Sub prcTimer(ByVal hWnd As Long, ByVal nIDEvent As Long, _
        ByVal uElapse As Long, ByVal lpTimerFunc As Long)

    Call prcKillTimer
    Call prcSetWindow
End Sub

Private Sub prcKillTimer()
    KillTimer XL_hWnd, 0
End Sub

Private Sub prcSetWindow()
    BOX_hWnd = FindWindow(GC_CLASSNAMEMSDIALOG, BOX_TITLE)
    If BOX_hWnd <> 0 Then
        SetWindowLong BOX_hWnd, GWL_STYLE, _
            GetWindowLong(BOX_hWnd, GWL_STYLE) And Not WS_SYSMENU
        DrawMenuBar BOX_hWnd
    End If
End Sub

Gruß
Nepumuk

Anzeige
AW: Schließen Kreuz
23.04.2007 06:13:43
Heiko
Hi Nepumuk
danke für deine hilfe klappt super. Genau so hab ich mir das vorgestellt. Danke
Gruß Heiko

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige