Results 1 to 5 of 5

Thread: How to give Windows Vista buttons effects?

  1. #1
    Join Date
    Dec 2009
    Posts
    21

    How to give Windows Vista buttons effects?

    Hi,
    I am a IT student and I develop a software in C# in that I want to give glowing effects to all the buttons, it look something like windows vista’s button, I know for giving this effect use mouse hover event but I don’t how I implement the code please help me, and I sure here I get the solution for How to give Windows Vista buttons effects?

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to give Windows Vista buttons effects?

    Hey I also face this same problem in my project I write code for that but the problem you able to see in following code in that I give Strdate the value on Load event, but the button redraws immediately after drawing the text and the text disappears.

    private void onlod(object sender, EventArgs e)
    {_brush = Brushes.Navy;
    Strdate = "Sample Drawing";
    }
    #endregion

    #region properties
    private string Strdate
    {
    get { return _strdate; }
    set
    {
    if (value.Equals(_strdate)) return;

    Drwdate(value);
    _strdate = value;
    }
    }
    #endregion

    #region text painting and stuff
    private void Drwdate(string strdate)
    {
    Graphics g = back.CreateGraphics();
    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    g.DrawString(strdate, Font, Brush, new PointF(0, 0));
    //TextRenderer.DrawText(g, "Sample Drawing...", Font, new Point(0, 0), Color.Navy);
    g.Dispose();
    }
    #endregion

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to give Windows Vista buttons effects?

    I hopefully this following code will help you I properly edited this code here you have to just override the paint method which on a button to do what you want. And I think after that you able to get whatever you want from this code.

    class Lbtn : Button
    {
    [Category("Apranc")]
    public string Lbltxt { get; set; }

    [Category("Apranc")]
    public Point Lbllocton { get; set; }

    protected override void OnPaint(PaintEventArgs pevent)
    {
    base.OnPaint(pevent);

    if (pevent != null)
    {
    pevent.Graphics.DrawString(Lbltxt, this.Font, Brushes.Black, Lbllocton);
    }
    }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to give Windows Vista buttons effects?

    Hey I give you better solution for that because I also want to implement this same glowing effect to buttons in my project I also try many of things but after lots of try I get this code for solving same problem which you correctly face, and for solving your problem you have to use following code.

    protected override void Mouseover(MouseEventArgs mevn)
    {
    base.Mouseover(mevn);
    Graphics g = this.CreateGraphics();
    SizeF strSize = g.MeasureString(m_labelText, this.Font);
    RectangleF labelRect = new RectangleF(m_labelLocation, strSize);
    if (labelRect.Contains(new Point(mevn.X, mevn.Y)))
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: How to give Windows Vista buttons effects?

    Here i give you other option to you use if you want to ceate vista type buttonr in your project then use this code.

    private void Drwglow(Graphics g)
    {
    if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None){return;}
    int butn = (mButtonState == State.Pressed) ? 60 : 150;
    Rectangle rect = new Rectangle(0, 0, this.Width, this.Height / 2);
    using (GraphicsPath r = RoundRect(rect, CornerRadius, CornerRadius, 0, 0))
    {
    using (LinearGradientBrush lg = new LinearGradientBrush(r.GetBounds(),
    Color.FromArgb(butn, this.HighlightColor),
    Color.FromArgb(butn / 3, this.HighlightColor),
    LinearGradientMode.Vertical))
    {
    g.FillPath(lg, r);
    }
    }
    }

Similar Threads

  1. Replies: 5
    Last Post: 12-08-2011, 10:48 PM
  2. I need clarification on system restore's effects in Vista
    By manwithoutanswers in forum Operating Systems
    Replies: 1
    Last Post: 11-03-2011, 02:16 PM
  3. Replies: 5
    Last Post: 06-07-2010, 12:51 PM
  4. How to give the classic look of XP to Vista
    By Billie in forum Customize Desktop
    Replies: 3
    Last Post: 14-02-2009, 06:11 PM
  5. Cursed Windows Vista, which does not give more errors
    By Arlo in forum Operating Systems
    Replies: 5
    Last Post: 29-08-2008, 05:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,926,120.92259 seconds with 17 queries