Results 1 to 5 of 5

Thread: Change the background color of a StatusBar [RESOLVED]

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    London
    Posts
    63

    Change the background color of a StatusBar [RESOLVED]

    The C# status bar does not have a BackgroundColor property or anything similar.

    How can I go about changing it's colour?

    My forms are all light blue but the dastardly status bar is still grey!

    Maybe an API call?
    Last edited by Genie; Oct 14th, 2003 at 06:26 AM.

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    Use the SendMessage API

    Code:
    [DllImport("user32.dll")]
    public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); 
    
    SendMessage sBar.hwnd, SB_SETBKCOLOR, 0, NewBgColor
    I'm not sure the value of SB_SETBKCOLOR you will have to look it up

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    London
    Posts
    63

    Talking

    Thanks you very much Tewl.

    For others who also need to know how to change the colour of the status bar:

    Add reference:
    using System.Runtime.InteropServices;

    the value for SB_SETBKCOLOR:

    int CCM_FIRST = 0x2000;
    SB_SETBKCOLOR = (CCM_FIRST + 1);

  4. #4
    New Member
    Join Date
    Sep 2006
    Posts
    4

    Question Re: Change the background color of a StatusBar [RESOLVED]

    hi,
    thanks for the code. But I have a problem. In design view it works correct. but when I am running the application, its not working.

    my status bar is inside a user control. Can anybody help me ??

    Regards,
    Reshmi

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Change the background color of a StatusBar [RESOLVED]

    Quote Originally Posted by Reshmi
    hi,
    thanks for the code. But I have a problem. In design view it works correct. but when I am running the application, its not working.

    my status bar is inside a user control. Can anybody help me ??

    Regards,
    Reshmi
    Within the Usercontrol, make the access specifier of Statusbar Public, then use the SendMessage API like
    Code:
    SendMessage UserControlName.ProgressBarName.Handle, SB_SETBKCOLOR, 0, NewBgColor
    [Handle] is in C# as [Hwnd] is in VB.

    EDIT: Oh, I forgot to add, this is an old thread, so if you have similar question/s, make a seperate/your own thread because it's unlikely that people will open a *RESOLVED* thread.
    Last edited by Harsh Gupta; Oct 10th, 2006 at 03:09 PM.
    Show Appreciation. Rate Posts.

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