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 » Control not being painted correctly when using certain themes Collapse All
Subject Author Date
Justin Cornish May 17, 2006 - 2:47 PM

I am using the Office2003 theme for my application. I have a dialog created with the resource editor, and I’ve changed it’s base class to CExtResizableDialog instead of CDialog. The controls do not automatically get the theme of the application, but if I create a control variable for each one and use the prof ui classes instead of the standard ones, the controls do recieve the proper theme. The problem is that the controls do not paint themselves correctly when the dialog is resized. The Office2003 has a gradient color background, so when the window gets resized, it is essential that the controls be repainted so they will match the gradient color. So, how can I fix the problem? Also, is there a way to make each control recieve the theme of the application without creating a control variable for each using the ProfUI classes?

Justin Cornish May 17, 2006 - 3:15 PM

Also note that I have the clip siblings and clip children properties of the dialog set to true.

Technical Support May 18, 2006 - 4:34 AM

You have done all the things necessary to get the correct dialog background and controls in your dialog. Please check the following issues additionally:

1) If you have virtual methods in your dialog class, please ensure they invoke the correct parent class methods. If you have OnInitDialog(), PreSubclassWindow(), PreTranslateMessage() and/or WindowProc() methods, these methods should invoke the same methods of the CExtResizableDialog class -- NOT methods of the CDialog class. This is the common error when switching from CDialog to CExtResizableDialog.

2) Make sure the IMPLEMENT_DYN***() and BEGIN_MESSAGE_MAP() macros of your dialog class have the CExtResizableDialog specified in the second parameter. This is also the common error when switching from CDialog to CExtResizableDialog.

3) If you have group box controls on your dialog template resource, then please subclass them with CExtGroupBox and check the tab order for all the controls in your dialog template resource. The tab order of each group box control should be greater than the tab order of any control inside the group box.

As for your last question, the FAQ How to subclass controls on a CExtResizableDialog dialog dynamically? may be helpful with this regard.

Justin Cornish May 18, 2006 - 2:04 PM

I have done all of those things. I believe this is a bug in Prof UI. Here is the complete source code for my class:

#include "afxcmn.h"
#pragma once

// CDialog2 dialog
class CDialog2 : public CExtResizableDialog
{
    DECLARE_DYNAMIC(CDialog2)

public:
    CDialog2(CWnd* pParent = NULL); // standard constructor
    virtual ~CDialog2();

// Dialog Data
    enum { IDD = IDD_DIALOGTWO };

protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    virtual BOOL OnInitDialog();
    void OnSize(UINT nType, int cx, int cy);
    DECLARE_MESSAGE_MAP()

public:
    CExtSliderWnd m_wndSlider;
};

// Dialog2.cpp : implementation file
//

#include "stdafx.h"
#include "raweval.h"
#include "Dialog2.h"


// CDialog2 dialog

IMPLEMENT_DYNAMIC(CDialog2, CExtResizableDialog)

CDialog2::CDialog2(CWnd* pParent /*=NULL*/)
    : CExtResizableDialog(CDialog2::IDD, pParent)
{
}

CDialog2::~CDialog2()
{
}

void CDialog2::DoDataExchange(CDataExchange* pDX)
{
    CExtResizableDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_SLIDER1, m_wndSlider);
}

BOOL CDialog2::OnInitDialog()
{    
    if(!CExtResizableDialog::OnInitDialog())
        return FALSE;

    m_wndSlider.SetRange(0, 1000);
    m_wndSlider.SetPos(250);
    
    return TRUE;
}



BEGIN_MESSAGE_MAP(CDialog2, CExtResizableDialog)
END_MESSAGE_MAP()


// CDialog2 message handlers

Justin Cornish May 18, 2006 - 2:17 PM

This appears to only be an issue with certain controls. Sliders have the problem, buttons and check boxes do not. I haven’t tried others yet. Is there a workaround I can use for the problem?

Technical Support May 19, 2006 - 6:50 AM

We believe the problem hides somewhere in your project because did not receive any feedback about this problem from our users. Please check again issue 3 (with group boxes) in our message and, if the problem persists, please send us a project that shows the problem so that we can quickly find out what’s wrong.

Justin Cornish May 19, 2006 - 11:02 AM

There are no group boxes. It’s a dialog with nothing but a slider. It’s 100% reproducible. Create a dialog with a slider, change it’s base class to CExtResizableDialog, and make all of the appropriate changes in the .cpp file. Make sure your dialog template has all of the appropriate flags set. Add a control variable for the slider and change it’s class to CExtSliderWnd. Make sure you have a theme enabled that uses a gradient, such as Office2003 or Studio2005. The slider control receives the correct theme, but is not painted correctly when the dialog is resized. Only when you click on the slider does it repaint itself correctly.

Technical Support May 20, 2006 - 8:47 AM

Thank you for the details. Please handle the WM_SIZE message and invoke the UpdateSliderWnd() method inside:

void CChildView::OnSize(UINT nType, int cx, int cy) 
{
   CFormView::OnSize(nType, cx, cy);
   if( m_wndSliderHTBB.GetSafeHwnd() != NULL )
      m_wndSliderHTBB.UpdateSliderWnd();
}