Announcement

Collapse
No announcement yet.

ProgressBar Farbe

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ProgressBar Farbe

    Hallo zusammen!

    Ich würde gerne bei einer ProgressBar die Farbe des Fortschrittbalkens ändern. Geht das mit "ProgressBar.Fore/BackColor" bzw geht es überhaupt? Und wenn wie muss ich die Farbe angeben, mit den 3 RGB Werten?
    Danke für die Hilfe!

    Also ich hab jetzt rausgefunden, dass ich mit Color.ArqticBlue die Farbe festlegen kann, es funktioniert aber weder mit BackColor noch ForeColor von ProgressBar...
    Zuletzt editiert von brown78; 09.10.2008, 00:49.

  • #2
    Hast Du (XP-)Theming aktiviert? Falls ja wird die Farbe durch das Theming vor gegeben!

    Comment


    • #3
      Hallo,

      2 Möglichkeiten
      1. EnableVisualStyles deaktivieren und mit API-SendMessage die Farben setzen
      2. dir selbst eine ProgressBar zu programmieren


      ad 2) zB http://www.codeproject.com/KB/cpp/VistaProgressBar.aspx

      ad 1)
      [highlight=c#]
      using System.Drawing;
      using System.Runtime.InteropServices;
      using System.Windows.Forms;

      namespace ProgressBarFarbe
      {
      public class gfPropressBar : ProgressBar
      {
      #region API
      [DllImport("user32.dll")]
      private static extern int SendMessage(int hWnd, int wMsg, int wParam, int lParam);

      private const int PBM_SETBKCOLOR = 0x2001;
      private const int PBM_SETBARCOLOR = 0x409;
      #endregion
      //---------------------------------------------------------------------
      #region Methoden
      public void SetBackColor(Color color)
      {
      int winColor = ColorTranslator.ToWin32(color);
      int handle = this.Handle.ToInt32();
      SendMessage(handle, PBM_SETBKCOLOR, 0, winColor);
      }
      //---------------------------------------------------------------------
      public void SetBarColor(Color color)
      {
      int winColor = ColorTranslator.ToWin32(color);
      int handle = this.Handle.ToInt32();
      SendMessage(handle, PBM_SETBARCOLOR, 0, winColor);
      }
      #endregion
      }
      }
      [/highlight]

      mfG Gü
      "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

      Comment


      • #4
        Ok, danke dafür. Ich hab mich für die Vorlage von Codeproject entschieden... Werd mich mal in den Code vertiefen und für mich anpassen....

        Comment

        Working...
        X