dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Changing color of CProgressBarCtrl in MFC C++

  1. #1
    Join Date
    Oct 2019
    Posts
    45

    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
    324

    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,227

    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
    45

    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
    324

    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,151

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)