Page 2 of 2 FirstFirst 12
Results 41 to 49 of 49

Thread: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

  1. #41
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Errors when trying to replicate using community 2015

    Quote Originally Posted by jcarpenter8504 View Post
    As stated in the Title, I am running this in Community 2015. My question is can this be done in 2015, and if it can, what did I do wrong?

    Code:
       
     ' Render container background gradient: Overload resolution failed because no accessible 'New' accepts this number of arguments.
        Protected Overrides Sub OnRenderToolStripBackground(e As ToolStripRenderEventArgs)
            MyBase.OnRenderToolStripBackground(e)
    
            Dim b As New Drawing2D.LinearGradientBrush(e.AffectedBounds, clrVerBG_White, clrVerBG_GrayBlue,
                Drawing2D.LinearGradientMode.Vertical)
            Dim shadow As New Drawing.SolidBrush(clrVerBG_Shadow)
            Dim rect As New Rectangle(0, e.ToolStrip.Height - 2, e.ToolStrip.Width - 1)         ' Error on this line
            e.Graphics.FillRectangle(b, e.AffectedBounds)
            e.Graphics.FillRectangle(shadow, rect)
        End Sub
    Code:
           
     ' OnRenderImageMargin: Error on last FillRectangle. says it failed because Value of type Pen cannot be converted to Brush
            e.Graphics.FillRectangle(SubmenuBGbrush, rect3)
            e.Graphics.FillRectangle(b, e.AffectedBounds)
            e.Graphics.FillRectangle(DarkLine, rect)
            e.Graphics.FillRectangle(WhiteLine, rect2)
            e.Graphics.FillRectangle(borderPen, rect4)  ' Error on this line
    Yes it certainly can be done in VS 2015 Community edition.

    To answer the "new" error on the rectangle, you're missing an input position parameter, you specify either the Top or the Left (with a 0 (zero)) but not the other (which would probably be a 0 again), so it should be like this: Dim rect As New Rectangle(0, 0, e.ToolStrip.Height - 2, e.ToolStrip.Width - 1)

    To answer the FillRectangle error, it says you're passing it a Pen object when it requires a Brush object, somewhere you're creating a Pen named borderPen then passing "borderPen" into the e.Graphics.FillRectangle(borderPen, rect4), what you should be doing is creating a borderBrush As New Brush().... instead and use that.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  2. #42
    New Member
    Join Date
    Apr 2017
    Posts
    6

    Re: Errors when trying to replicate using community 2015

    Quote Originally Posted by JuggaloBrotha View Post
    Yes it certainly can be done in VS 2015 Community edition.

    To answer the "new" error on the rectangle, you're missing an input position parameter, you specify either the Top or the Left (with a 0 (zero)) but not the other (which would probably be a 0 again), so it should be like this: Dim rect As New Rectangle(0, 0, e.ToolStrip.Height - 2, e.ToolStrip.Width - 1)

    To answer the FillRectangle error, it says you're passing it a Pen object when it requires a Brush object, somewhere you're creating a Pen named borderPen then passing "borderPen" into the e.Graphics.FillRectangle(borderPen, rect4), what you should be doing is creating a borderBrush As New Brush().... instead and use that.
    '// Border
    Dim borderPen As New Pen(clrMenuBorder)
    Dim rect4 As New Rectangle(0, 1, e.ToolStrip.Width - 1, e.ToolStrip.Height - 2)
    This was the section of code from the OnRenderImageMargin Sub that was on the clsMenuRenderer class. I tried switching it to Brush, but then it gave me a lot of errors upon trying to change it.

  3. #43
    New Member
    Join Date
    Apr 2017
    Posts
    6

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    I was able to get the first issue working, the second however I attempted to change it to a new instance of Brush, which it did not like at all in the slightest. Ended up making up a few new errors. Below is the code I used for the variable from the clsMenuRenderer class.

    ' Border
    Dim borderPen As New Pen(clrMenuBorder)
    Dim rect4 As New Rectangle(0, 1, e.ToolStrip.Width - 1, e.ToolStrip.Height - 2)
    What I have found so far is that it can't choose between Pen and Brush when it comes time to Override it. At least that is what I have gathered from this link.

    https://msdn.microsoft.com/en-us/library/2hx4ayzs.aspx
    Last edited by jcarpenter8504; Apr 18th, 2017 at 02:58 PM. Reason: Supplying more information about specified error and what I have found on my own research.

  4. #44
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Quote Originally Posted by jcarpenter8504 View Post
    I was able to get the first issue working, the second however I attempted to change it to a new instance of Brush, which it did not like at all in the slightest. Ended up making up a few new errors. Below is the code I used for the variable from the clsMenuRenderer class.



    What I have found so far is that it can't choose between Pen and Brush when it comes time to Override it. At least that is what I have gathered from this link.

    https://msdn.microsoft.com/en-us/library/2hx4ayzs.aspx
    What is your "clrMenuBorder" variable?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #45
    New Member
    Join Date
    Apr 2017
    Posts
    6

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Quote Originally Posted by JuggaloBrotha View Post
    What is your "clrMenuBorder" variable?
    This is the part within clsMenuRenderer where my border is handled.

    ' Border
    Dim borderPen As New Pen(clrMenuBorder)
    Dim rect4 As New Rectangle(0, 1, e.ToolStrip.Width - 1, e.ToolStrip.Height - 2)
    And my declaration of clrMenuBorder within clsColors
    Public clrMenuBorder As Color = Color.FromArgb(255, 160, 160, 160)

  6. #46
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Quote Originally Posted by jcarpenter8504 View Post
    This is the part within clsMenuRenderer where my border is handled.
    And my declaration of clrMenuBorder within clsColors
    Without seeing more of your code I'm not sure where things are going wrong, but ultimately I see you're creating a Pen from the clrMenuBorder variable (whatever that is) and you really need a Brush, which you can do by: Dim borderBrush As New SolidBrush(Colors.Black); but if clrMenuBorder is a Color Enum you could use: Dim borderBrush As New SolidBrush(clrMenuBorder)
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  7. #47
    New Member
    Join Date
    Apr 2017
    Posts
    6

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Quote Originally Posted by JuggaloBrotha View Post
    Without seeing more of your code I'm not sure where things are going wrong, but ultimately I see you're creating a Pen from the clrMenuBorder variable (whatever that is) and you really need a Brush, which you can do by: Dim borderBrush As New SolidBrush(Colors.Black); but if clrMenuBorder is a Color Enum you could use: Dim borderBrush As New SolidBrush(clrMenuBorder)
    I was able to get it to work using the variable with the last option:

    Dim borderBrush As New SolidBrush(clrMenuBorder)
    On your earlier posts where you have all the custom colors for it, is that zip file the source code?

  8. #48
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Quote Originally Posted by jcarpenter8504 View Post
    On your earlier posts where you have all the custom colors for it, is that zip file the source code?
    It should be, if so it'll be VS 2008 which should upgrade to VS2015/2017 just fine.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  9. #49
    New Member
    Join Date
    Apr 2017
    Posts
    6

    Re: Custom VisualStudio2008 style MenuStrip and ToolStrip Renderer

    Awesome, when I get a minute I will download it and mess around with it to see what the differences are between the two. Thanks for helping me with my issues I was having.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width