CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2019
    Posts
    82

    Changing color of CProgressBarCtrl in MFC C++

    I have used following code for coloring the CProgressBarCtrl:

    Code:
    COLORREF clrBar = RGB(0, 0, 0); // the bar color
    progressBarCtrl.SendMessage(PBM_SETBARCOLOR, 0, (LPARAM) clrBar);
    But this is not working,instead i am getting windows dark blue color on CProgressBarCtrl
    Last edited by 2kaud; December 13th, 2019 at 04:23 AM. Reason: Fixed code tags - use [] and not <>

  2. #2
    Join Date
    Jan 2009
    Posts
    399

    Re: Changing color of CProgressBarCtrl in MFC C++

    Perhaps must be activated the application theme ... your app is UNICODE ? Take a look inside stdafx.h and see if this code is active:
    Code:
    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Changing color of CProgressBarCtrl in MFC C++

    Since you are using MFC, why not use the MFC CProgressBarCtrl methods instead of using the non-MFC ::SendMessage?

  4. #4
    Join Date
    Oct 2019
    Posts
    82

    Re: Changing color of CProgressBarCtrl in MFC C++

    I checked stdafx.h ,code you wrote above is not there

  5. #5
    Join Date
    Jan 2009
    Posts
    399

    Re: Changing color of CProgressBarCtrl in MFC C++

    Made a MFC test project (SDI or MDI) with VS wizard and you'll see what I am talking about (take a look inside stdafx.h as I said in previous post).
    Last edited by mesajflaviu; December 16th, 2019 at 12:41 PM.

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Changing color of CProgressBarCtrl in MFC C++

    As Arjay said, you can directly use methods on the CProgressBarCtrl. See MSDN: https://docs.microsoft.com/en-us/cpp...s?view=vs-2019
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

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