From: Martin on 30 Dec 2009 14:59 I've googled around a bit but couldn't find anything. Is there a way to set the BackColor of a panel in a StatusBar?
From: mscir on 30 Dec 2009 15:39 Martin wrote: > I've googled around a bit but couldn't find anything. > Is there a way to set the BackColor of a panel in a StatusBar? If you're willing to use a picturebox... I don't remember where I downloaded this so unfortunately I can't give credit to the author. Option Explicit Private Declare Function SetParent Lib "user32" (ByVal hWndChild As _ Long, ByVal hWndNewParent As Long) As Long Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, lParam _ As Any) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const WM_USER As Long = &H400 Private Const SB_GETRECT As Long = (WM_USER + 10) Private Sub Form_Load() With StatusBar1 .Panels.Clear .Panels.Add .Panels.Add End With With Picture1(0) .BorderStyle = 1 .AutoRedraw = True .BackColor = vbRed .ForeColor = vbWhite End With Picture1(0).Print "Testing.." 'Do another Load Picture1(1) With Picture1(1) .BorderStyle = 1 .AutoRedraw = True .BackColor = vbBlue .ForeColor = vbWhite End With Picture1(1).Print "123..." End Sub Private Sub Form_Resize() Dim PB As PictureBox For Each PB In Picture1 Call ShowInStatusBar(PB, PB.Index) Next End Sub Private Sub ShowInStatusBar(ByRef PB As PictureBox, ByVal PanelIndex As Integer) Dim tRC As RECT ' Get the size of the Panel Rectangle from the status bar SendMessageAny StatusBar1.hwnd, SB_GETRECT, PanelIndex, tRC ' and convert it to twips.... With tRC .Top = (.Top * Screen.TwipsPerPixelY) .Left = (.Left * Screen.TwipsPerPixelX) .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .Top .Right = (.Right * Screen.TwipsPerPixelX) - .Left End With ' Now Reparent the Picturebox to the statusbar With PB SetParent .hwnd, StatusBar1.hwnd .Move tRC.Left, tRC.Top, tRC.Right, tRC.Bottom .Visible = True End With End Sub --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: mscir on 30 Dec 2009 15:43 Martin wrote: > I've googled around a bit but couldn't find anything. > > Is there a way to set the BackColor of a panel in a StatusBar? Also the CCRP project has a really nice full featured statusbar, that uses their downloadable ccrpsbrb.ocx. http://ccrp.mvps.org/ --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: MikeD on 30 Dec 2009 19:00 "Martin" <ironwoodcanyon(a)gmail.com> wrote in message news:n4cnj5hpgpd71uma9b4p9fdjjakcftpr6m(a)4ax.com... > I've googled around a bit but couldn't find anything. > > Is there a way to set the BackColor of a panel in a StatusBar? Send it a SB_SETBKCOLOR message. Option Explicit Private Const CCM_SETBKCOLOR As Long = &H2001& Private Const SB_SETBKCOLOR As Long = CCM_SETBKCOLOR Private Const CLR_DEFAULT As Long = &HFF000000 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub Form_Click() Call SendMessage(StatusBar1.hwnd, SB_SETBKCOLOR, 0&, ByVal RGB(255, 0, 0)) End Sub Note that if the status bar has a sizing handle, the sizing handle doesn't change color. So, this "works" best if the status bar is using the simple style. -- Mike
From: LondonLad on 1 Jan 2010 07:11
Hi MikeD Q. Would it also be possible to change the font color in the statusbar? "MikeD" wrote: > > > "Martin" <ironwoodcanyon(a)gmail.com> wrote in message > news:n4cnj5hpgpd71uma9b4p9fdjjakcftpr6m(a)4ax.com... > > I've googled around a bit but couldn't find anything. > > > > Is there a way to set the BackColor of a panel in a StatusBar? > > Send it a SB_SETBKCOLOR message. > > Option Explicit > > Private Const CCM_SETBKCOLOR As Long = &H2001& > Private Const SB_SETBKCOLOR As Long = CCM_SETBKCOLOR > Private Const CLR_DEFAULT As Long = &HFF000000 > Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" > (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As > Any) As Long > > Private Sub Form_Click() > > Call SendMessage(StatusBar1.hwnd, SB_SETBKCOLOR, 0&, ByVal RGB(255, 0, > 0)) > > End Sub > > > Note that if the status bar has a sizing handle, the sizing handle doesn't > change color. So, this "works" best if the status bar is using the simple > style. > > -- > Mike > > > . > |