Microsoft Office 2000/Visual Basic Programmer's Guide   

Modeless Balloons and the Callback Property

When you display a modeless balloon, the user is able to use your application while the balloon is displayed. You specify that a balloon is modeless by setting the Mode property to the built-in constant msoModeModeless.

When you create a modeless balloon you must also set its Button property to something other than msoButtonSetNone and its Callback property to the name of a procedure to call when the user clicks a button in the modeless balloon. The procedure named in the Callback property must accept three arguments: a Balloon object, a long integer representing the button selected (msoBalloonButtonType values or a number representing the button clicked when the BalloonType property is set to msoBalloonTypeButtons), and a long integer representing the Balloon object's Private property.

You use the Private property to assign a value to a Balloon object that uniquely identifies it to the procedure named in the Callback property. You could use this property in a single generic callback procedure that is called from multiple modeless balloons. For example, the BalloonSamples.xls sample file in the ODETools\V9\Samples\OPG\Samples\CH06 subfolder on the Office 2000 Developer CD-ROM contains a five-step tour of a Northwind Company spreadsheet that uses a collection of modeless balloons representing each step in the tour. All five Balloon objects name the BalloonCallBackProc procedure in their Callback property setting. Each Balloon object uses a unique value in its Private property setting, and the BalloonCallBackProc procedure uses this value and the value of the button clicked by the user (lngBtnRetVal) to identify which balloon has called the procedure and which button was clicked. The Balloon objects that call this procedure all specify a Private property by using a module-level constant (BALLOON_ONE, BALLOON_TWO, and so on) that indicates in which step of the tour they are called. Each balloon has a Close button and either a Next button, a Back button, or both, depending on the balloon's location in the tour. This single procedure is designed to handle all selections made in all balloons:

Function BalloonCallBackProc(balBalloon As Balloon, _
                             lngBtnRetVal As Long, _
                             lngPrivateBalloonID As Long)
               
   ' This procedure is specified in the Callback property
   ' setting for all five balloons used in the Modeless
   ' Balloon Demo. These balloons are created in the AddBalloon
   ' procedure and stored in the mcolModelessBalloons collection.
   
   Const BUTTON_BACK As Long = -5
   Const BUTTON_NEXT As Long = -6
   
   ' Close current balloon.
   balBalloon.Close
   
   Select Case lngPrivateBalloonID + lngBtnRetVal
      Case BALLOON_ONE + BUTTON_NEXT
         ' User clicked first balloon, Next button.
         Call ShowModelessBalloon(CStr(BALLOON_TWO))
      Case BALLOON_TWO + BUTTON_NEXT
         Call ShowModelessBalloon(CStr(BALLOON_THREE))
      Case BALLOON_TWO + BUTTON_BACK
         Call ShowModelessBalloon(CStr(BALLOON_ONE))
      Case BALLOON_THREE + BUTTON_NEXT
         Call ShowModelessBalloon(CStr(BALLOON_FOUR))
      Case BALLOON_THREE + BUTTON_BACK
         Call ShowModelessBalloon(CStr(BALLOON_TWO))
      Case BALLOON_FOUR + BUTTON_NEXT
         Call ShowModelessBalloon(CStr(BALLOON_FIVE))
      Case BALLOON_FOUR + BUTTON_BACK
         Call ShowModelessBalloon(CStr(BALLOON_THREE))
      Case BALLOON_FIVE + BUTTON_BACK
         Call ShowModelessBalloon(CStr(BALLOON_FOUR))
      Case Else
         ' User clicked Close button.
         Set mcolModelessBalloons = Nothing
   End Select
End Function

The BalloonCallBackProc procedure is available in the modTutorial module in BalloonSamples.xls in the ODETools\V9\Samples\OPG\Samples\CH06 subfolder on the Office 2000 Developer CD-ROM.

This is just one example of the kinds of things you can do with modeless Balloon objects. You have a great deal of flexibility over what you can do with a balloon and a great deal of programmatic control over how your users interact with the balloons you create. You can use the Object Browser to get a complete listing of all the Balloon object's properties and methods. You can use the Microsoft Office Visual Basic Reference Help index to get more information about these properties and methods.