|
|
Balloon Dialog
I know that a neat WTL balloon tip class already exists on CodeProject.com, but this control was actually inspired from my old CountDown sample and a Delphi component by Jonathan Hosking (I'm a former Pascal programmer, so it was fun to look at some Delphi code). The control was created because I required something more of my balloons. This control uses a dialog template to render the balloon, allowing you to put a multitude of texts and shiny buttons inside it. Being a dialog means that it works best in a modal state. But you can have modeless balloons floating around too. The dialog needs a buddy. That's a window it can position itself relative to. You can choose on which side it should prefer to attach itself, but if there is not enough real estate, the dialog will move to another side of the buddy window. The sample contains some Office 97 buttons as well. They are not perfect, but I included them anyway so you could perhaps build your own pesky Office Assistant look-alike into your WTL app. A few quirksImplementing this was not without a few quirks.The little arrow-head turned out to be most troublesome. Normally you would paint the entire balloon frame in one go, however if i.e. the arrow-head should be painted to the left, then the entire dialog content had to be shifted to the right. To avoid this maneuver, I applied the arrow-head as a separate window, which is attached on-top of the dialog at runtime.
Another problem is of course that you might want to resize your dialog
depending on the size of text and other controls. You can still resize
the dialog in a How to use itSimply create a dialog class as usual.The dialog should be a popup dialog, with all borders and captions removed.
Then derive from CBalloonDialog...
In your dialog message map, add a few chains...
Finally, to show the dialog, simply use the DoModal() method.
But first you must attach your buddy window...
If you do not assign the buddy window, the balloon dialog
will appear as a MessageBox-like dialog - without the arrow
and centered on the owner window.
The CBalloonDialog class needs to handle a few important
messages, such as the Source Code DependenciesMicrosoft Visual C++ 6.0Microsoft WTL 3.1 Library Download Files
Written by Bjarke Viksoe. Article submitted 3/2/2002. To the top
|
|||