
TGadget provides a number of protected access functions that you can use
Deriving from
when deriving a gadget class from TGadget.
TGadget
TGadget provides a couple virtual functions that give a gadget a chance to
Initializing and
initialize or clean up:
cleaning up
virtual void Inserted();
virtual void Removed();
Inserted is called after inserting a gadget into a gadget window. Removed is
called before removing the gadget from its gadget window. The default
versions of these function do nothing.
The TGadget class provides two different paint functions: PaintBorder and
Painting the gadget
Paint.
The PaintBorder function paints the border of the gadget. This virtual
function takes a single parameter a TDC &, and returns void. PaintBorder,
implements the standard border styles. If you want to create a new border
style, you need to override this function and provide the functionality for
the new style. If you want to continue to provide the standard border
styles, you should also call the TGadget version of this function. PaintBorder
is called by the Paint function.
The Paint function is similar to the TWindow function Paint. This function
takes a single parameter a TDC &, and returns void. Paint is declared,
virtual. TGadget’ PaintGadgets function calls each gadget’ Paint functions s
when painting the gadget window. The default Paint function only calls the
PaintBorder function. T paint the inner rectangle of the gadget’ boundingo s
rectangle, you should override this function to provide the necessary
functionality.
If you’re painting the gadget yourself in the Paint function, you often need
to find the area inside the borders and margins of the gadget. This area is
called the inner rectangle. Y u can find the inner rectangle using theo
GetInnerRect function:
void GetInnerRect(TRect& rect);
GetInnerRect places the coordinates of the inner rectangle into the TRect
reference passed into it.
258
OWL P ogrammer’ Guider s