home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD138551172001.psc / MessgBoxMod.bas < prev    next >
Encoding:
BASIC Source File  |  2001-01-17  |  3.0 KB  |  116 lines

  1. Attribute VB_Name = "modMessgBox"
  2. Option Explicit
  3.  
  4. '******************************************************
  5. '
  6. ' MessgBox module
  7. ' Author: Raul Lopez  raulopez@hotmail.com
  8. ' Use this code as you like. It isn't necessary
  9. ' to mention me nor give me any credit. Enjoy it!
  10. '
  11. '******************************************************
  12. '
  13. 'You can use any button, included standard VB CommdButt
  14. 'You can use any caption for your buttons
  15. 'You can use standard or custom icons
  16. 'You can use system or custom sounds
  17. '
  18. '******************************************************
  19. '
  20. 'To call the function:
  21. '
  22. 'MesgBox "Text", n, "Title", "Capt1", "Capt2", "Capt3"
  23. '
  24. 'Where
  25. '   Text = Message
  26. '      n = Icon and sound value
  27. '  Title = Message box title
  28. '  Capt1 = First button caption
  29. '  Capt2 = Second button caption (optional)
  30. '  Capt3 = Third button caption (optional)
  31. '
  32. '******************************************************
  33. '
  34. 'The value for the icons and sounds are:
  35. '  0 = None
  36. '  1 = Critical
  37. '  2 = Question
  38. '  3 = Exlamation
  39. '  4 = Information
  40. '  5 = Custom
  41. 'and next
  42. '
  43. 'The button's value are:
  44. '  0 = First button
  45. '  1 = Second button
  46. '  2 = Third button
  47. '
  48. '******************************************************
  49.  
  50. Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
  51.        (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  52.  
  53. Public Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long
  54.  
  55. Public Const MB_ICONASTERISK = &H10&
  56. Public Const MB_ICONQUESTION = &H20&
  57. Public Const MB_ICONEXCLAMATION = &H30&
  58. Public Const MB_ICONINFORMATION = &H40&
  59.  
  60. Public IcoVal As Integer
  61. Public Message As Integer
  62.  
  63. Public Function MesgBox(mbText As String, mbIcon As Integer, _
  64.                         mbTitle As String, mbCBut0 As String, _
  65.                         Optional mbCBut1 As String, _
  66.                         Optional mbCBut2 As String) _
  67.                         As Long
  68.  
  69.    IcoVal = mbIcon  'Stores icon value to play sound
  70.    
  71.    With frmMessgBox
  72.       'Message
  73.       .Label1.Caption = mbText
  74.       
  75.       'Message box title
  76.       If mbTitle <> "" Then
  77.          .Caption = mbTitle
  78.       Else
  79.          .Caption = App.Title
  80.       End If
  81.       
  82.       'Buttons caption
  83.       .Button(0).Caption = mbCBut0
  84.       .Button(1).Caption = mbCBut1
  85.       .Button(2).Caption = mbCBut2
  86.       
  87.       'Icon
  88.       If mbIcon <> 0 Then
  89.          .Image1.Picture = .ImageList1.ListImages(mbIcon).Picture
  90.       End If
  91.       
  92.       If mbCBut1 <> "" Then .Button(1).Visible = True
  93.       If mbCBut2 <> "" Then .Button(2).Visible = True
  94.       
  95.       'One button
  96.       .Button(0).Left = 2130
  97.       
  98.       'Two buttons
  99.       If mbCBut1 <> "" And mbCBut2 = "" Then
  100.          .Button(0).Left = 1320
  101.          .Button(1).Left = 2940
  102.       End If
  103.     
  104.       'Three buttons
  105.       If mbCBut1 <> "" And mbCBut2 <> "" Then
  106.          .Button(0).Left = 840
  107.          .Button(1).Left = 2130
  108.          .Button(2).Left = 3420
  109.       End If
  110.  
  111.    End With
  112.    
  113.    frmMessgBox.Show 1
  114.  
  115. End Function
  116.