Re: Applying color to Toolbars

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tonny (anonymous_at_discussions.microsoft.com)
Date: 05/02/04

  • Next message: Yizhaq Shmaayahoo: "Pen bug? Line disappears with high scale transformations"
    Date: Sat, 1 May 2004 23:26:04 -0700
    
    

    Hi,

    Thank you very much. Your suggestion worked fine. Now I'm able to draw a gradient "backcolor".

    I have one problem though. It seems that the gradient "backcolor" is drawn on top of the buttons, because I'm not able to see any of the buttons after i have drawn the "backcolor". I guess I have to redraw the buttons in order to be able to view them.

    My original idea was to use a foreach an run through all the ToolbarButton's and redraw them. However, there is no refresh()-method or invalidate()-method.

    Any suggestions on how to solve this problem?

    Kind regards,
    Tonny
         
         ----- Ken Tucker [MVP] wrote: -----
         
         Hi,
         
             Try this.
         
            //
            // TODO: Add constructor logic here
            //
            this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);
         
         Ken
         --------------------
         "Tonny" <anonymous@discussions.microsoft.com> wrote in message
         news:305748E6-DB6A-4C9A-8B18-A6C3ECFFD94B@microsoft.com...
    > Hi
    >> I'm trying to draw an gradient on a Toolbar. I have created my own
    > GradientToolbar, which inherrits from Toolbar. In this I try to override
    > OnPaint in order to draw something:
    >> protected override void OnPaint(PaintEventArgs e)
    > {
    > Rectangle rectangle = new Rectangle(0, 0, this.Width, this.Height);
    > Color gradientColorA = Color.Blue;
    > Color gradientColorB = Color.White;
    > Brush brush = new LinearGradientBrush(rectangle, gradientColorA,
    > gradientColorB, 0.0F);
    > e.Graphics.FillRectangle(brush, rectangle);
    > }
    >> However, nothing happens. The toolbar is not drawn with the desired
    > colors.
    >> Is there anyone who knows how to draw the background of an toolbar. I
    > obviously don't. I have also tried to override the BackColor - also
    > without an positive result.
    >> If anyone have an answer to how to solve this problem I would be
    > gratefull, if you respond to this message.
    >> Kind regards,
    > Tonny
         
         
         


  • Next message: Yizhaq Shmaayahoo: "Pen bug? Line disappears with high scale transformations"

    Relevant Pages

    • Applying color to Toolbars
      ... I'm trying to draw an gradient on a Toolbar. ... I have created my own GradientToolbar, ... In this I try to override OnPaint in order to draw something: ...
      (microsoft.public.dotnet.framework.drawing)
    • Neon Lines
      ... things with the .net drawing functions, but this one has me stumped. ... I want to draw neon lines. ... Now I can draw a straight line with a gradient ... To achieve a basic neon effect a gradient of dark-light-dark is used, ...
      (microsoft.public.dotnet.framework.drawing)
    • Re: Problem with Themes -- drawing a rebar
      ... Passing this solution along after dialoging with Mr. Wheatley offline. ... Rebar, they'll paint mostly ... So, to get the actual Rebars background gradient to draw, you'd do ... Now just be careful because the gradient you draw in themes like Luna ...
      (microsoft.public.win32.programmer.ui)
    • Re: How to draw a rectangle with gradient?
      ... I am using PIL to draw a rectangle filled with color blue. ... Is there anyway I could set the fill pattern so that the drawn ... I don't think there is a built-in gradient function, ...
      (comp.lang.python)
    • Re: Drawing a circular gradient
      ... linear gradient, changing the start and end color a bit each time. ... Animated vector graphics system ... > I want to draw a gradient, much like the gradient drawn by a linear ... > to be able to specify 2 colors and have the gradient drawn like in the ...
      (microsoft.public.dotnet.framework.drawing)