Hello all. I'm starting to learn .net and I'm using c#. I'm trying to build an owner draw menu, which should look like VS.net. So I've looked for examples and I've found some. The problem I'm getting is that when the mouse is over one of the items in the menu I'm getting a broke line in the place where the mouse is standing (I'm using drawrectangle to draw a blue rect around the selected item). I think that there's something wrong with this line of code:
gr.DrawRectangle( new Pen( Color.DarkBlue ), rect.X, rect.Y, rect.Width - 1 , rect.Height - 1 ); I'm saying this because if I replace it with this one: ControlPaint.DrawBorder3D( gr, rect.Left, rect.Top, rect.Width,rect.Height, Border3DStyle.Flat, Border3DSide.Top | Border3DSide.Left | Border3DSide.Right | Border3DSide.Bottom ); it works ok (no lines get broken when the mouse is over the items). What I don't understand is why this doesn't happen top the top menu item (only happens to the children of the main menu item). Has anyone found anything like this? This link has 2 images showing the results of what happens when I use each of the functions: http://members.netmadeira.com/luisabreu/error/errorc.htm Here is the code responsible for drawing the background of the menu items: protected void DrawBackground( Graphics gr, Rectangle rect, DrawItemState state, bool isTopLevel, bool hasIcon ) { bool selected = ( state & DrawItemState.Selected ) > 0; bool over = ( state & DrawItemState.HotLight ) > 0; if( selected || over ) { //check if top level if( isTopLevel && selected) { gr.FillRectangle( new SolidBrush( SystemColors.ControlLight ), rect ); ControlPaint.DrawBorder3D( gr, rect.Left, rect.Top, rect.Width, rect.Height, Border3DStyle.Flat, Border3DSide.Top | Border3DSide.Left | Border3DSide.Right ); } else { Trace.Write ("top1"); gr.FillRectangle( new SolidBrush( Color.FromArgb(173, 173, 209) ), rect ); /* HERE IS WHERE I'M GETTING THAT NASTY ERROR */ gr.DrawRectangle( new Pen( Color.DarkBlue ), rect.X, rect.Y, rect.Width - 1 , rect.Height - 1 ); /*ControlPaint.DrawBorder3D( gr, rect.Left, rect.Top, rect.Width, rect.Height, Border3DStyle.Flat, Border3DSide.Top | Border3DSide.Left | Border3DSide.Right | Border3DSide.Bottom );*/ } else { if( !isTopLevel ) { Trace.Write ("top2"); gr.FillRectangle( new SolidBrush( SystemColors.ControlLight ), rect ); rect.X += bitmap_size + 5; rect.Width -= bitmap_size + 5; gr.FillRectangle( new SolidBrush( SystemColors.ControlLightLight ), rect ); } else { gr.FillRectangle( SystemBrushes.Control, rect ); } } } Regards, Luis Abreu http://www.luisabreu.go.cc/ mailto:[EMAIL PROTECTED] --------------------------------------------- "Those who give up never win, and those who win never give up!", Luis Abreu --------------------------------------------- You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.