Results 1 to 3 of 3

Thread: SysTrayIcon and Background Color

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    28

    SysTrayIcon and Background Color

    How would I place code to get the background a different color, instead of transparent to the systray?


    Code:
            private void CreateIcon(int temperature)
            {
                // Create a graphics instance that draws to a bitmap
                Bitmap bitmap = new Bitmap(16, 16,
                             System.Drawing.Imaging.PixelFormat.Format32bppArgb);
    
                Graphics graphics = Graphics.FromImage(bitmap);
    
                // FONT
                System.Drawing.Font drawFont
                           = new System.Drawing.Font("Segoe UI", 8,
                                                System.Drawing.FontStyle.Bold);
    
                // TEXT
                string drawString = temperature.ToString();
    
                SizeF drawStringSize = new SizeF();
                //Measure the Copyright string in this Font
                drawStringSize = graphics.MeasureString(drawString, drawFont);
    
                // BRUSH
                System.Drawing.SolidBrush drawBrush
                                        = new System.Drawing.SolidBrush(
                                             Color.FromArgb(255, 255, 255, 255));
                // center text in icon image
                graphics.DrawString(drawString, drawFont, drawBrush,
                       16 / 2 - drawStringSize.Width / 2, 16 / 2 - drawStringSize.Height / 2);
    
                notifyWeather.Icon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());
    
                drawFont.Dispose();
                drawBrush.Dispose();
                graphics.Dispose();
    
            }

  2. #2
    Hyperactive Member Arrow_Raider's Avatar
    Join Date
    Dec 2001
    Location
    AVR Lovers Club
    Posts
    423

    Re: SysTrayIcon and Background Color

    Before drawing the text, do this:
    Code:
    graphics.Clear(Color.Black);
    Replace Black with the color you want.
    My monkey wearing the fedora points and laughs at you.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    28

    Re: SysTrayIcon and Background Color

    Thanks...

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