netrosly

TaskDialog

Mar 27th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.11 KB | None | 0 0
  1. Module TaskDialog
  2.  
  3.     'This code was made by DeStilleGast
  4.     'If you wish to use this code leave those line in it
  5.  
  6.     'How to use it:
  7.     'TaskDialog.show(Mainform <like the owner from the dialog>
  8.     'Title <the title from the messagebox>
  9.     'Headtext <the blue text>
  10.     'Context <the black text>
  11.     'buttons <wana use more buttons use Or and not And>
  12.     'Icon <messagebox style>)
  13.  
  14.     'To get a result back use this:
  15.     'Dim result as TaskDialog.TaskDialogResult
  16.     'result = TaskDialog.show(me, "Title", "Headtext", "Context", TaskDialogButtons.OK Or TaskDialogButtons.Close, TaskDialogIcon.Stop)
  17.     '
  18.  
  19.     Public Declare Auto Function TaskDialog Lib "comctl32.dll" (ByVal hWnd As IntPtr, ByVal hInstance As IntPtr, ByVal WindowTitle As String, ByVal MainInstruction As String, ByVal Content As String, ByVal CommonButton As Integer, ByVal DialogIcon As Integer, ByRef PushedButton As Integer) As Integer
  20.  
  21.     Public Enum TaskDialogButtons
  22.         OK = &H1
  23.         Cancel = &H8
  24.         Yes = &H2
  25.         No = &H4
  26.         Retry = &H10
  27.         Close = &H20
  28.     End Enum
  29.  
  30.     Public Enum TaskDialogIcon
  31.         Information = UInt16.MaxValue - 2
  32.         Warning = UInt16.MaxValue
  33.         [Stop] = UInt16.MaxValue - 1
  34.         Question = 0
  35.         SecurityWarning = UInt16.MaxValue - 5
  36.         SecurityError = UInt16.MaxValue - 6
  37.         SecuritySuccess = UInt16.MaxValue - 7
  38.         SecurityShield = UInt16.MaxValue - 3
  39.         SecurityShieldBlue = UInt16.MaxValue - 4
  40.         SecurityShieldGray = UInt16.MaxValue - 8
  41.     End Enum
  42.  
  43.     Public Enum TaskDialogResult
  44.         None = 0
  45.         OK = 1
  46.         Cancel = 2
  47.         Yes = 6
  48.         No = 7
  49.         Retry = 4
  50.         Close = 8
  51.     End Enum
  52.  
  53.     Public Function show(ByVal _Frm As Form, ByVal _Title As String, ByVal _HeadText As String, ByVal _contents As String, _buttons As TaskDialogButtons, _icon As TaskDialogIcon) As TaskDialogResult
  54.         Dim result As TaskDialogResult
  55.         TaskDialog(_Frm.Handle, IntPtr.Zero, _Title, _HeadText, _contents, _buttons, _icon, result)
  56.         Return result
  57.     End Function
  58.  
  59. End Module
Add Comment
Please, Sign In to add comment