Tips
1. Update a project that use MsgBox for a project with
BalloonDialog.
1. Update a project that use MsgBox for a project with BalloonDialog.
This example use a public function that get all the MsgBox arguments and add
some extra data to call the MsgBalloon method.
VB5,
VB6
-
Insert in the main form (Form1) the Microsoft Agent Control 2.0 and the
BalloonDialog control.
-
Add this code in a Module.
Option Explicit
' Global variables declaration.
Global Genie As IAgentCtlCharacterEx
Global Balloon As BalloonDialog.Balloon
' This function get all the MsgBox arguments and add some
data
' to call the MsgBalloon method.
' Return the MsgBalloonResult (or vbMsgBoxResult).
Public Function Message(Prompt As
String, _
Optional Buttons As VbMsgBoxStyle
= vbOKOnly, _
Optional Title As
String, _
Optional HelpFile As
String, _
Optional Context As
Integer) As MsgBalloonResult
' Show the character if it is not visible.
If Genie.Visible
= False Then Genie.Show
' This use Map to speak without the common
balloon.
' Chr(34) = ". ("\Map=""Hello world!""=""\").
Genie.Speak "\Map=" & Chr(34) & Chr(34) & Prompt & _
Chr(34) & Chr(34) & _
"=" & Chr(34) & Chr(34) & "\"
' Add the object character and call the
MsgBalloon method.
Message = Balloon.MsgBalloon(Prompt,
Buttons, Title, Genie)
End Function
-
Add this code in the Form1.
Private Sub Form_Load()
' Load and show the character.
Agent1.Characters.Load "Genie", "genie.acs"
Set Genie =
Agent1.Characters("Genie")
Genie.Show
Set Balloon = Balloon1
End Sub
-
Now, you can use Ctrl+H to replace all the MsgBox function for
the new Message function.
Download the complete code.
|