- Код: Выделить всё
Option Explicit
Private Type MSGBOXPARAMS
cbSize As Long
hwndOwner As Long
hInstance As Long
lpszText As Long
lpszCaption As Long
dwStyle As Long
lpszIcon As Long
dwContextHelpId As Long
lpfnMsgBoxCallback As Long
dwLanguageId As Long
End Type
Private Type MSGBOXDATA
params As MSGBOXPARAMS
pwndOwner As Long
wLanguageId As Integer
pidButton As Long ' // Array of button IDs
ppszButtonText As Long ' // Array of button text strings
cButtons As Long
DefButton As Long
CancelId As Long
Timeout As Long
End Type
Private Declare Function SoftModalMessageBox Lib "user32" (pMsgBoxParams As MSGBOXDATA) As Long
Sub Main()
Dim mbd As MSGBOXDATA, Buttons(3) As Long, Captions(3) As String
Captions(0) = "Нафиг"
Buttons(0) = vbAbort
Captions(1) = "Нефиг"
Buttons(1) = vbRetry
Captions(2) = "Пофиг"
Buttons(2) = vbIgnore
Captions(3) = "Отмена"
Buttons(3) = vbCancel
With mbd
With .params
.cbSize = LenB(mbd.params)
.lpszText = StrPtr(Replace("Чтобы сделать месседжбокс с собственными подписями\nкнопок, совсем не обязательно рисовать форму самому:\nдля этого идеально подходит малодокументированная\nфункция SoftModalMessageBox.", "\n", vbCrLf))
.lpszCaption = StrPtr("Круто, да?")
.dwStyle = vbQuestion & vbOKCancel
End With
.DefButton = 2
.CancelId = vbCancel
.cButtons = 4
.pidButton = VarPtr(Buttons(0))
.ppszButtonText = VarPtr(Captions(0))
.Timeout = -1
End With
Debug.Print SoftModalMessageBox(mbd)
End Sub