Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5974947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:00:51+00:00 2026-05-22T21:00:51+00:00

I have searched the net looking for a way to set background color a

  • 0

I have searched the net looking for a way to set background color a dialog control.

I have managed to do this with this code:

case WM_CTLCOLORSTATIC:
{
    HDC hdcStatic = (HDC) wParam;
    SetTextColor(hdcStatic, RGB(255,255,255));
    SetBkColor(hdcStatic, RGB(0,0,0));

    if (hbrBkgnd == NULL)
    {
        hbrBkgnd = CreateSolidBrush(RGB(0,0,0));
    }
    return (INT_PTR)hbrBkgnd;
}

However, what I am actually looking for is to color only a specific static control, not all the static controls I have in my dialog. Is there anyway to do this? Perhaps set the hdc to something using GetDlgItem(hdlg,”IDC_MYCONTROL”) ?

— UPDATE

After the suggestions I ended up with this :

case WM_CTLCOLORSTATIC:
{
    HDC hdcStatic = (HDC) lParam;
    HWND hWnd =  (HWND)lParam;
    HWND dlg =GetDlgItem(hDlg, IDC_STATIC2);
    if (hWnd == dlg)
    {
        SetTextColor(hdcStatic, RGB(255,255,255));
        SetBkColor(hdcStatic, RGB(0,0,0));
    }
    if (hbrBkgnd == NULL)
    {
        hbrBkgnd = CreateSolidBrush(RGB(0,0,0));
    }
    return (INT_PTR)hbrBkgnd;
}

And it seems that even if SetBkColor is run nothing changes on the dialog, leading on the wierd problem described below.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:00:52+00:00Added an answer on May 22, 2026 at 9:00 pm

    Check lParam matches the handle to the child that you want to change the colour of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched this across the net and found many codes for retrieving the
I have searched the net and searched the net only to not quite find
I have searched through the net and still have no clue how to do
I am using c# .net. Thanks in advance for any help. I have searched
I have tried everything, searched the net for two hours or even more and
I have tried dllimport and extern command without any success. Searched the net for
I have searched for this, and i found that for api less than 12,
I have searched for a general solution to this but only find answers to
I have searched and searched for this but I think my terminology isn't correct
.NET/MVC3 newbie, so please bear with me! I've searched for this answer all over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.