Hi,
geht doch:
' **********************************************************************
' Modul: Modul2 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 lpTimer As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function MessageBox Lib "user32.dll" _
Alias "MessageBoxA" ( _
ByVal hWnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As Long) As Long
Private Declare Function SendDlgItemMessage Lib "user32.dll" _
Alias "SendDlgItemMessageA" ( _
ByVal hDlg As Long, _
ByVal nIDDlgItem As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Private Const WM_SETTEXT = &HC
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private Const GC_CLASSNAMEMSDIALOG = "#32770"
Private Enum MsgBoxPlusIcon
Critical = 16
Question = 32
Exclamation = 48
Information = 64
End Enum
Private strCaption1 As String
Private strCaption2 As String
Private strCaption3 As String
Private strCaption As String
Private hWnd As Long
Private Function MsgBoxPlus(ByVal hWnd As Long, _
ByVal strText As String, _
ByVal strTitle As String, _
ByVal strButton1 As String, _
Optional ByVal strButton2 As String, _
Optional ByVal strButton3 As String, _
Optional ByVal enmSymbol As MsgBoxPlusIcon) As Long
Dim nResult As Long
strCaption1 = strButton1
strCaption2 = strButton2
strCaption3 = strButton3
strCaption = strTitle
nResult = SetTimer(hWnd, 0, 25, AddressOf MsgBoxPlus_TimerEvent)
If strButton2 = "" And strButton3 = "" Then
nResult = MessageBox(hWnd, strText, strCaption, enmSymbol Or vbOKOnly)
ElseIf strButton2 <> "" And strButton3 = "" Then
nResult = MessageBox(hWnd, strText, strCaption, enmSymbol Or vbYesNo)
Else
nResult = MessageBox(hWnd, strText, strCaption, enmSymbol Or vbAbortRetryIgnore)
End If
Select Case nResult
Case 1, 3, 6
MsgBoxPlus = 1
Case 4, 7
MsgBoxPlus = 2
Case Else
MsgBoxPlus = 3
End Select
End Function
Private Sub MsgBoxPlus_TimerEvent()
Dim lngBoxHandle As Long
KillTimer hWnd, 0
lngBoxHandle = FindWindow(GC_CLASSNAMEMSDIALOG, strCaption)
If strCaption2 = "" And strCaption3 = "" Then
SendDlgItemMessage lngBoxHandle, vbCancel, WM_SETTEXT, 0, strCaption1
ElseIf strCaption2 <> "" And strCaption3 = "" Then
SendDlgItemMessage lngBoxHandle, vbYes, WM_SETTEXT, 0, strCaption1
SendDlgItemMessage lngBoxHandle, vbNo, WM_SETTEXT, 0, strCaption2
Else
SendDlgItemMessage lngBoxHandle, vbAbort, WM_SETTEXT, 0, strCaption1
SendDlgItemMessage lngBoxHandle, vbRetry, WM_SETTEXT, 0, strCaption2
SendDlgItemMessage lngBoxHandle, vbIgnore, WM_SETTEXT, 0, strCaption3
End If
End Sub
Public Sub Test()
Dim lngButton As Long
hWnd = FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
lngButton = MsgBoxPlus(hWnd, "MsgBox mit oam Gnopf", _
"Des schded om drin", "Druck mi", , , MsgBoxPlusIcon.Exclamation)
MsgBox lngButton
lngButton = MsgBoxPlus(hWnd, "MsgBox mit zwoa Gnepf", _
"Des schded om drin", "so ned", "doch a so", , _
MsgBoxPlusIcon.Question)
MsgBox lngButton
lngButton = MsgBoxPlus(hWnd, "MsgBox mit drei Gnepf", _
"Des schded om drin", "Ko sei", "Mir wuschd", "Leck mi", _
MsgBoxPlusIcon.Information)
MsgBox lngButton
End Sub
Gruß
Nepumuk