
IRainButtonDraw Interface
This interface allows you, the developer, to
customize some or all of RainbowButton's visual appearance.
This works in a manner similar to the CustomDraw
features of the Windows Common Controls API.
To implement the IRainButtonDraw interface, you
type the following code into the top of your form or
class module:
Implements IRainButtonDraw
To start receiving notifications through the interface,
use the SetCallbackSink method of the RainbowButton control
(the following code assumes that you will type this code
into the object module that implements the interface):
RainButton1.SetCallbackSink Me
From that point on, all of the events that are listed as
methods of IRainButtonDraw will be called on your object.
Note: There is a "custom draw" sample project included
with the RainbowButton control.
DrawItem
This interface contains only a single method - DrawItem. Its
definition is as follows:
DrawItem(RainCtrl As RainButton, ByVal hDC As Long, _
ByVal nDrawStep As ButtonPreDrawSteps, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal bMouseDown As Boolean, ByVal bHasFocus As Boolean, _
bDoDefaultDrawing As Boolean
Parameters
- RainCtrl - The object reference to the button that
is calling the method. This is useful if you are
custom-drawing multiple buttons.
- hDC - The device context handle on which you should
draw using the Windows GDI API.
- nDrawStep - DrawItem is called four times during
the rendering of a button. This parameter indicates
which stage the rendering is in:
- btnBackground - You should render the button's
background, or allow RainbowButton to draw
it automatically.
- btnBorder - It is time to draw the button's
border.
- btnPicture - Render the button's picture at
any location you wish.
- btnCaption - Finally, draw the caption of
the button. Note that if you choose to draw
the picture yourself in the previous step,
and then allow RainbowButton to draw its own
caption, the caption text will be drawn
horizontally and vertically centered regardless
of the PicturePlacement property.
- nWidth - The width of the button, in pixels.
- nHeight - The height of the button, in pixels.
- bMouseDown - If True, the button should be
drawn in the "down" state.
- bHasFocus - If True, the button should be drawn as
if it has the focus and is the default button.
- bDoDefaultDrawing - This parameter is True by default.
If it remains True when the method's execution is over,
RainbowButton will draw this step itself. You should set
this parameter to False if you plan to render this
step yourself.