Hiding/Removing the "Triangle" from Parent MenuItem

J

javadkhan

Hi All,
I am trying to supress the small black triangle that shows up in the
menus meaning the menuitem is parent. The reason for that is I
owner-drew my own 3D looking triangle in DrawItem using GraphicPath
glyph (drew lines making triangle). What I have right now is my 3D
triangle and default windows menu triangle on it.
Please help, thanks in advance
 
E

Eric Cadwell

Are you calling base.DrawItem after your custom code? The call to base
should come first.
Maybe you could post a little code?

-Eric
 
M

Mick Doherty

You cannot stop the system from drawing the Menu arrow. You can override
everything or even create your menus via Interop and you will still get the
arrow. I couldn't even find a secret undocumented message to intercept when
I tried it. Quite why this paint is not included in the standard windows
Paint/NC_Paint/Print methods I don't know.
 
J

javadkhan

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::DrawItemEventArgs * e)
{
System::Drawing::Font *f = new System::Drawing::Font(S"Microsoft
Sans Serif", 10, System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::point, (System::Byte)0);

MenuItem *mi = __try_cast<MenuItem*>(sender);

//contextMenu1->MenuItems->Item[e->Index]->Text
e->Graphics->DrawString(mi->Text->ToString(),
f, System::Drawing::Brushes::Black,
RectangleF::blush: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::Drawing::RectangleF *triangleRect = __nogc new
System::Drawing::RectangleF(*location, *size);

// draw the white triangle:
Drawing::Drawing2D::GraphicsPath *glyph = new
Drawing::Drawing2D::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::Drawing2D::GraphicsPath *glyph2 = new
Drawing::Drawing2D::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::Drawing2D::GraphicsPath *glyph3 = new
Drawing::Drawing2D::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);

}
}
 
J

javadkhan

anybody?

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::DrawItemEventArgs * e)
{
System::Drawing::Font *f = new System::Drawing::Font(S"Microsoft
Sans Serif", 10, System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::point, (System::Byte)0);

MenuItem *mi = __try_cast<MenuItem*>(sender);

//contextMenu1->MenuItems->Item[e->Index]->Text
e->Graphics->DrawString(mi->Text->ToString(),
f, System::Drawing::Brushes::Black,
RectangleF::blush: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::Drawing::RectangleF *triangleRect = __nogc new
System::Drawing::RectangleF(*location, *size);

// draw the white triangle:
Drawing::Drawing2D::GraphicsPath *glyph = new
Drawing::Drawing2D::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::Drawing2D::GraphicsPath *glyph2 = new
Drawing::Drawing2D::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::Drawing2D::GraphicsPath *glyph3 = new
Drawing::Drawing2D::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);

}
}
 
M

Mick Doherty

I already gave you the answer!
You cannot stop the system from drawing the arrow when a menuitem has a
childmenu.
 
J

javadkhan

ok... there is no any way I can change the way the default triangle is
displayed too?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top