OK, I'm developing a component in VB.NET to simplify menus with
bitmaps. It implements the IExtenderProvider interface and adds
an 'ImageIndex' property to every MenuItem on the form. The goal
is to ownerdraw every menuitem on the form with just dropping this
component on the form.
However, I've hit a snag. I don't know where to do the OwnerDrawing.
If I put it in the CanExtend function (Implemented from IExtenderProvider;
the function checks to see if a specific control should be extended
with a new property), it actually changes the OwnerDraw property
at design time (i.e. actually, sets OwnerDraw = True in the property
window and underlying form code). If I set it in the SetImageIndex
method (it is called every time the ImageIndex extended property
is changed to set up the appropriate values), it also changes it
at design time.
My question is this: where should I put the appropriate OwnerDraw = True
and AddHandlers in the component so that it OwnerDraws every
MenuItem on the form that it's contained on, but at run time only.
If possible, I'd like to do it with as little code on the form as possible
(I'm trying to concentrate all the the code in this component).
bitmaps. It implements the IExtenderProvider interface and adds
an 'ImageIndex' property to every MenuItem on the form. The goal
is to ownerdraw every menuitem on the form with just dropping this
component on the form.
However, I've hit a snag. I don't know where to do the OwnerDrawing.
If I put it in the CanExtend function (Implemented from IExtenderProvider;
the function checks to see if a specific control should be extended
with a new property), it actually changes the OwnerDraw property
at design time (i.e. actually, sets OwnerDraw = True in the property
window and underlying form code). If I set it in the SetImageIndex
method (it is called every time the ImageIndex extended property
is changed to set up the appropriate values), it also changes it
at design time.
My question is this: where should I put the appropriate OwnerDraw = True
and AddHandlers in the component so that it OwnerDraws every
MenuItem on the form that it's contained on, but at run time only.
If possible, I'd like to do it with as little code on the form as possible
(I'm trying to concentrate all the the code in this component).