CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    129

    Question CDockBar background color?

    I have a legacy Visual Studio 6.0 application. I need to change the color of the Dockbar (as illustrated in the attached picture). I have tried the implementation found here to no effect.

    I'm not having much luck in my internet search endeavors.

    Basically, can't I grab a dockbar (top, bottom, left, etc...) at paint (or in CMainFrame::OnNotify) time like: (where m_BrushDocBar is my initialized brush of my preferred color.)??

    Code:
    	
           CControlBar* pTopDockBar = GetControlBar(AFX_IDW_DOCKBAR_TOP);
    	if (pTopDockBar != NULL)
    	{
    		SetClassLong(pTopDockBar->m_hWnd, GCL_HBRBACKGROUND, (LONG)m_BrushDocBar.GetSafeHandle());
    	}
    I'd really appreciate any pointers on how to accomplish this. Thanks.

    Edit: I tried the code below in CMainFrame::OnCreate. No effect
    Code:
    CControlBar* pTopDockBar = GetControlBar(AFX_IDW_DOCKBAR_TOP);
    	HWND hBar = pTopDockBar->GetSafeHwnd();
    	::SetClassLongPtr(
    		hBar,
    		GCLP_HBRBACKGROUND,
    		(LONG_PTR)GetSysColorBrush(COLOR_ACTIVECAPTION));
    Name:  DockBarColor.png
Views: 380
Size:  6.5 KB
    Last edited by mega Kluge; September 17th, 2015 at 11:04 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: CDockBar background color?

    Maybe you implemented the sample code from http://www.codeproject.com/Articles/...ed&tid=2502599 not 100% correct?
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    129

    Re: CDockBar background color?

    That was my initial thought and I went back and double checked. Everything looks OK. Furthermore, I downloaded the sample from the site, compiled it with VS2015, and ran it. It doesn't work.

    One of the comments in that article stated that the sample didn't work with a more recent version (than the date of the article) of VS. Whatever mechanism caused this to work in previous versions of VS obviously doesn't work now.

    Also, the comments state that this isn't the "right" way to achieve this effect anyway. I was hoping that maybe someone here would know the exact and correct way to achieve this behavior or at least point me in the right direction. Thanks!

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: CDockBar background color?

    Try the way suggested in the comments
    Victor Nijegorodov

Tags for this Thread

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

Featured