Here's the code where I am trying to do this.
I am not using base.DrawItem... Do I need to?
private: System::Void menuItem1_DrawItem(System::Object * sender,
System::Windows::Forms:
rawItemEventArgs * e)
{
System:
rawing::Font *f = new System:
rawing::Font(S"Microsoft
Sans Serif", 10, System:
rawing::FontStyle::Bold,
System:
rawing::GraphicsUnit:
oint, (System::Byte)0);
MenuItem *mi = __try_cast<MenuItem*>(sender);
//contextMenu1->MenuItems->Item[e->Index]->Text
e->Graphics->DrawString(mi->Text->ToString(),
f, System:
rawing::Brushes::Black,
RectangleF:
p_Implicit(e->Bounds),
StringFormat::GenericDefault);
if (mi->IsParent) {
Rectangle rect = e->Bounds;
// where to put a 9 x 5 triangle in rect:
//PointF *location = __nogc new PointF((rect.Width - 2.0 - 9.0)/2.0
+ rect.Left + 1.0,(rect.Height - 2.0 - 5.0)/2.0 + rect.Top + 1.0);
PointF *location = __nogc new PointF(rect.Left + rect.Width -
14,(rect.Height - 2.0 - 5.0)/2.0 + rect.Top + 1.0);
//location->X += 45;
//location->X += 0;
location->X += 0;
location->Y -= 3;
SizeF *size = __nogc new SizeF(10.0, 6.0);
System:
rawing::RectangleF *triangleRect = __nogc new
System:
rawing::RectangleF(*location, *size);
// draw the white triangle:
Drawing:
rawing2D::GraphicsPath *glyph = new
Drawing:
rawing2D::GraphicsPath();
//glyph->AddLine(triangleRect->Left, triangleRect->Top,
triangleRect->Right - 1 , triangleRect->Top);
//glyph->AddLine(triangleRect->Right - 1, triangleRect->Top,
triangleRect->Left + 4, triangleRect->Bottom -1 );
//glyph->AddLine(triangleRect->Left+2, triangleRect->Bottom,
triangleRect->Left+2, triangleRect->Top-3);
//glyph->AddLine(triangleRect->Left+2, triangleRect->Top-3,
triangleRect->Right-1, triangleRect->Top-2+(triangleRect->Bottom -
triangleRect->Top)/2.0);
glyph->AddLine(triangleRect->Left-1, triangleRect->Bottom+3,
triangleRect->Left-1, triangleRect->Top-2);
glyph->AddLine(triangleRect->Left-1, triangleRect->Top-2,
triangleRect->Right, triangleRect->Top + 4);
glyph->CloseFigure();
e->Graphics->FillPath(SystemBrushes::ActiveCaptionText, glyph);
// draw the dark triangle:
Drawing:
rawing2D::GraphicsPath *glyph2 = new
Drawing:
rawing2D::GraphicsPath();
glyph2->AddLine(triangleRect->Left-1, triangleRect->Bottom+1,
triangleRect->Left-1, triangleRect->Top-2);
glyph2->AddLine(triangleRect->Left-1, triangleRect->Top-2,
triangleRect->Right-1, triangleRect->Top-2+4);
glyph2->CloseFigure();
e->Graphics->FillPath(SystemBrushes::ControlDarkDark, glyph2);
// draw the same color triangle:
Drawing:
rawing2D::GraphicsPath *glyph3 = new
Drawing:
rawing2D::GraphicsPath();
glyph3->AddLine(triangleRect->Left+1, triangleRect->Bottom+1,
triangleRect->Left+1, triangleRect->Top+1);
glyph3->AddLine(triangleRect->Left+1, triangleRect->Top,
triangleRect->Right-4, triangleRect->Top+3);
glyph3->CloseFigure();
e->Graphics->FillPath(SystemBrushes::ControlLight, glyph3);
}
}