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 » Custom background colour for CExtResizableDialog Collapse All
Subject Author Date
Vincent Wong Mar 14, 2007 - 8:21 AM

Hi,

What are the steps necessary for preventing the default painting of the gradient background for a CExtResizableDialog, and instead custom painting a flat background colour using FillSolidRect() on the dialog’s DC?

Thanks,

Vincent.

Technical Support Mar 14, 2007 - 11:48 AM

In addition we would like to add the following. If you look at the declaration of CExtResizableDialog, you will see that its parent classes are wrapped in templates. A CExtWS template adds a theme-based background to the resizable dialog window by overriding the WindowProc() virtual method and handling the WM_PAINT message there. You can also override WindowProc() method and handle WM_PAINT there:

class C_Your_Dialog : public CExtResizableDialog
{
protected:
    virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
    {
        if( message == WM_PAINT )
        {
            CPaintDC dc( this );
            // 
            // YOUR CUSTOM PAINTING CODE GOES HERE 
            //
            return 0;
        }
        return CExtResizableDialog::WindowProc( message, wParam, lParam );
    }
};
Please note that starting from v.2.62 you can get and set the background color using GetBkColor()/SetBkColor() methods of the CExtWS template.

Please also note that this background will not be consistent between controls anywhere inside the dialog. All the controls have its own background and you have to set the background color for all the controls manually or use the CExtPaintManager::g_nMsgPaintInheritedBackground registered message which allows painting a custom background that is consistent between controls.

Suhai Gyorgy Mar 14, 2007 - 9:41 AM

Support’s answer to almost the same question some minutes ago:

The CExtPaintManager::m_bCustomBackgroundInheritanceEnabled flag allows you to paint a custom background for windows in your application. By default, it is set to false and the background of a particular window is painted by the current paint manager. For example, if the current paint manager is CExtPaintManagerOffice2003, a gradient background will be painted.

Now suppose you need to paint some custom background for a window or you want to paint a custom background that is consistent between all the other windows in the application like in the Tabbed Bars sample. When CExtPaintManager::m_bCustomBackgroundInheritanceEnabled is true, the paint manager, instead of painting the standard background of the window, sends a CExtPaintManager:: g_nMsgPaintInheritedBackground message to the window back and allows it to paint the background in the handler of this message. If the message is not handled, the paint manager sends it to its parent and so forth until the message is processed, which means the background has been painted. If the message has not been processed by parent windows, the paint manager simply paints the standard background.

There is also a FAQ article relating to your question:

How to paint a custom background consistent between the windows in my application?