Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » CStatic - OnCtlColor Collapse All
Subject Author Date
Tor Erik Ottinsen Sep 20, 2005 - 10:31 AM

Before i upgraded my dialogs to CExtResizableDialog, i used CStatic with the WM_CTLCOLOR message to set custom background color to labels (and also icons). With CExtResizableDialog, this color seems to be overrided by the theme color. Is there any way to avoid this? Or another way to get CStatic to use custom background color?

zelda thehgd Jul 17, 2023 - 3:10 AM

When it comes to the hiring process, striking a balance https://2048cupcakes.io/ between IQ and EQ is critical. A candidate with exceptional technical prowess but lacking emotional intelligence may

Technical Support Sep 20, 2005 - 1:25 PM

The WM_CTLCOLOR windows message is handled in the CExtWS::WindowProc() method. The CExtWS template class is used as a base type for both CExtResizableDialog and CExtResizablePropertyPage classes. To get the colored static background, just override the WindowProc() virtual method in your dialog/property page class:

LRESULT CYourClass::WindowProc(
    UINT message, WPARAM wParam, LPARAM lParam )
{
    if(    message >= WM_CTLCOLORMSGBOX
        && message <= WM_CTLCOLORSTATIC
        )
    {
        HWND hWnd =
            __EXT_GET_WM_CTLCOLOR_HWND(
                wParam, lParam, message );
        ASSERT( hWnd != NULL );
        INT nCtlColor =
            __EXT_GET_WM_CTLCOLOR_TYPE(
                wParam, lParam, message );
        if( nCtlColor == CTLCOLOR_STATIC )
        {
            // DETECT YOUR COLORED STAIC HERE !!!
            if( hWnd == hWndOfYourColoredStatic )
                return
                    CDialog :: // or CPropertyPage
                        WindowProc(
                            wParam, lParam, message );
        }
    }
    return
        CExtResizableDialog :: // or CExtResizablePropertyPage
            WindowProc(
                wParam, lParam, message );
}


Tor Erik Ottinsen Sep 20, 2005 - 3:07 PM

Okay, thanks, I will try this.

Technical Support Sep 21, 2005 - 7:36 AM

Additionally we can suggest that you try the CExtLabel class, which is an enhanced version of the CStatic control. This class allows you to use the SetBkColor() method for setting the background color.