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

  • Home
  • SEARCH
  • 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 390731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:59:35+00:00 2026-05-12T15:59:35+00:00

I am making a dll that controls a dialogue box. I like to get

  • 0

I am making a dll that controls a dialogue box. I like to get a certain area to have red text. This code does compile, but the effect is not seen. Here is the area where the dialogProc is done:

LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_INITDIALOG:     
        CheckDlgButton(hDlg, IDC_CHECK, FALSE);
        EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDC_CHECK:
            if (IsDlgButtonChecked(hDlg, IDC_CHECK))
            {
                EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
                EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
            }
            else
            {
                EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
                EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
            }
            break;
        case IDOK:
            {           
                EndDialog(hDlg, TRUE);
                return FALSE;
            }
        case IDCANCEL:
            {               
                EndDialog(hDlg, FALSE);
                return FALSE;
            }
        case WM_CTLCOLORSTATIC:
            // Set the colour of the text for our URL
            if ((HWND)lParam == GetDlgItem(hDlg,IDC_WARNING)) 
            {
                // we're about to draw the static
                // set the text colour in (HDC)lParam
                SetBkMode((HDC)wParam,TRANSPARENT);
                SetTextColor((HDC)wParam, RGB(255,0,0));
                return (BOOL)CreateSolidBrush (GetSysColor(COLOR_MENU));
            }
    return TRUE;
        }
    }
    return FALSE;
}
  • 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-12T15:59:35+00:00Added an answer on May 12, 2026 at 3:59 pm

    WM_CTLCOLORSTATIC is a separate message from WM_COMMAND. Your desired handling of the message appears to be correct except that the check for the message is inside your check for WM_COMMAND specific items. Try reorganizing your outer switch statement. Perhaps something like the following:

    LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, 
                                WPARAM wParam, LPARAM lParam)
    {
        switch(message)
        {
        case WM_INITDIALOG:         
            // ...
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
            case IDC_CHECK:
                // ...
                break;
            case IDOK:
                // ...
                break;
            case IDCANCEL:
                // ...
                break;
            }
            break;
        case WM_CTLCOLORSTATIC:
            // Set the colour of the text for our URL
            if ((HWND)lParam == GetDlgItem(hDlg, IDC_WARNING)) 
            {
                    // we're about to draw the static
                    // set the text colour in (HDC)lParam
                    SetBkMode((HDC)wParam,TRANSPARENT);
                    SetTextColor((HDC)wParam, RGB(255,0,0));
                    // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle.
                    return (BOOL)GetSysColorBrush(COLOR_MENU);
            }
            break;
        }
        return FALSE;
    }
    

    Also note that it would be kinda weird to filter WM_COMMAND’s wParam argument when wParam is supposed to provide the HDC for WM_CTLCOLORSTATIC.

    WM_CTLCOLORSTATIC Notification at MSDN

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

Sidebar

Related Questions

I have a bit of code for a dll that is needed by two
How can I have code-sharing between two projects without making a dll? The issue
My project uses several dll files with activex controls. Now I am making a
I'm making a game that will allow content development and I'd like it to
I have a windows DLL that currently only supports ASCII and I need to
I am currently making a application that has several reference DLL and i am
This might be a duplicate question as I have found a few that are
I have written a DLL that uses MS Word to spell check the content
I have a VB6 Active DLL that I'm trying to call from C#. I've
I'm making a program (think: something like Launchy ) that, more or less, goes

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.