[DllImport("user32.dll", SetLastError=true)]
static extern int MessageBoxTimeout(IntPtr hwnd, String text, String title, uint type, Int16 wLanguageId, Int32 milliseconds);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.U4)]
private static extern uint MessageBoxTimeout(IntPtr hwnd,
[MarshalAs(UnmanagedType.LPTStr)] String text,
[MarshalAs(UnmanagedType.LPTStr)] String title,
[MarshalAs(UnmanagedType.U4)] uint type,
Int16 wLanguageId,
Int32 milliseconds);
<DllImport("user32.dll", EntryPoint:="MessageBoxTimeoutA", setLastError:=True, CharSet:= CharSet.Unicode)> _
Private Shared Function MessageBoxTimeOut( _
Byval hWnd as IntPtr, _
<MarshalAs(UnmanagedType.LPStr)> ByVal lpText as StringBuilder, _
<MarshalAs(UnmanagedType.LPStr)> ByVal lpCaption as StringBuilder, _
<MarshalAs(UnmanagedType.U4)> ByVal uType as UInteger, _
<MarshalAs(UnmanagedType.U2)> ByVal wLanguage as Int16, _
<MarshalAs(UnmanagedType.U4)> ByVal dwMilliseconds as Int32, _
) as <MarshalAs(UnmanagedType.U4)> UInteger
End Function
Private Declare Function MessageBoxTimeOut _
Lib "user32.dll" Alias "MessageBoxTimeoutA" _
( _
Byval prmlngWindowHandle as Long, _
Byval prmstrMessage as String, _
Byval prmstrCaption as string, _
Byval prmlngType as long, _
Byval prmwLanguage as Integer, _
Byval prmdwMiliseconds as Long _
) as Integer
use MessageBoxButtons.* enumeration for type argument, cast as integer.
Use enumeration for type aruments, cast as uint with Flags
Do you know one? Please contribute it!
Returns 32000 if the messagebox timed out.
wLanguageID
The language for the text displayed in the message box button(s). Specifying a value of zero (0) indicates to display the button text in the default system language. If this parameter is MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), the current language associated with the calling thread is used.
To specify a language other than the current language, use the MAKELANGID macro to create this parameter. For more information,see http://msdn.microsoft.com/en-gb/library/windows/desktop/dd373908(v=vs.85).aspx
dwMilliseconds
Parameter is in milliseconds so 1000 will be 1 second etc
Messagebox wont time out if dwMilliseconds is 0
Please add some!
private static uint SetupnCallMessageBoxTimeOut(IntPtr hWnd, string itsMessage, string itsCaption, uint itsMessageBoxOptions,Int32 itsTimeOutMilliSeconds)
{
return MessageBoxTimeout(hWnd , itsMessage, itsCaption,itsMessageBoxOptions,0,itsTimeOutMilliSeconds);
}
private Shared Function DisplayMessageBox( _
ByVal hWnd as IntPtr, _
ByVal Message as string, _
ByVal Caption as string, _
ByVal MessageOptions as UInteger, _
Byval TimeOutMilliSeconds as Int32 _
) as Uinteger
return MessageBoxTimeOut(hWnd, New StringBuilder(Message), New StringBuilder(Caption), MessageBoxOptions,0, TimeOutMilliSeconds)
End Function
Public Function DisplayMessageBox( _
ByVal hWnd As Long, _
ByVal Message As String, _
ByVal Caption As String, _
ByVal MessageBoxOptions As Long, _
ByVal TimeOutMilliseconds As Long _
) As Integer
DisplayMessageBox = MessageBoxTimeOut(hWnd, Message, Caption, MessageBoxOptions, 0, TimeOutMilliseconds)
End Function
Please add some!