Ein Unmodalisches Angebot...;)
Ich denk mal, daß jeder schon eine MessageBox gesehen und benutzt hat. Und der ein oder andere hat diese bestimmt schon mit vbSystemModal System-Modal gesetzt (so zum Spaß).
Doch wie erstellt man eine MsgBox, die weder System-Modal noch Application-Modal ist (ich hab michs zumindest mal gefragt, aber meine Denkstrukturen sind manchesmal auch sehr Ausschweifend*g*)
Wieder einmal muß man da die API fragen, und (wie langweilig) diese hat auch noch eine Lösung Parat.
Deklaration:Private Type MSGBOXPARAMS
cbSize As Long
hwndOwner As Long
hInstance As Long
lpszText As String
lpszCaption As String
dwStyle As Long
lpszIcon As String
dwContextHelpId As Long
lpfnMsgBoxCallback As Long
dwLanguageId As Long
End Type
Private Declare Function MessageBoxIndirect Lib "user32" Alias "MessageBoxIndirectA" (lpMsgBoxParams As MSGBOXPARAMS) As Long
Naja, nichtmodal ist die erzeugte MsgBox ja eigentlich nicht ganz. Es wird nur die hwndOwner-Eigenschaft auf 0 gesetzt(der Dektop), und dann verhällt sich die MsgBox wie gewünscht.
Private Function UMsgBox(Prompt, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title) As VbMsgBoxResult
If IsMissing(Title) = True Then Title = App.Title
Dim MSP As MSGBOXPARAMS
With MSP
.hwndOwner = 0
.lpszCaption = Title
.lpszText = Prompt
.dwStyle = Buttons
End With
UMsgBox = MessageBoxIndirect(MSP)
End Function
Nachdem man die Funktion in sein Projekt eingefügt hat, hat man eine zweite MsgBox-Funktion...UMsgBox
Diese wird genauso aufgerufen wie die normale MsgBox, mit dem einzigen Unterschied, daß es keine Hilfedatei und dementsprechend auch keinen Context für eine solche gibt.
Auch die Rückgabewerte sind gleich geblieben, so daß der Arbeit damit nichts im Wege steht...