Question

I am rewiting the older application to get the modern look in Windows 7. The GUI elements are created and moved via the explicit code (no special layout manager). Because of some historic reasons, the GUI events were not processed the standard way. They were redirected. It is rather difficult to track them, especially when I do not know what should I focus for.

Here is the example of the window that should be polished. It is not a dialog. It is classical, sizable window placed on the top. However, it should mimic the dialog look. The window uses WTL::CTabControlT<CControl> where the CControl is my class based on the ATL::CWindow -- see the picture first:

The window with the TabControls

It man not be well visible from the picture, but the ends of the red arrows show the grey background of the static texts. However, the backround of the tab itself is white.

  1. What event causes the grey background of the static texts? Is it the WM_CTLCOLORSTATIC. Or, where is the problem? Is the background of the tab expected to be white or grey (standard behaviour)?
  2. Is it recommended (by designers of the visual interface, user experience) to have also the listboxes in the tab the same (white) background?
  3. The outer window has COLOR_3DFACE defined via ATL macro DECLARE_WND_CLASS_EX. What event is responsible for painting the bacground around the tab windows?

Thanks for your help, Petr

Was it helpful?

Solution

The missing grey background around the tabs was solved by processing the WM_ERASEBKGND message explicitly (the redirection somehow prevented the default processing):

if (uMsg == WM_ERASEBKGND)
{
    WTL::CDCHandle dc(reinterpret_cast<HDC>(wParam));
    RECT rc;
    GetClientRect(&rc);
    dc.FillRect(&rc, GetWndClassInfo().m_wc.hbrBackground);
    return TRUE;
}

Similarly, the grey background of the static texts on the white tabs was whitened by processing WM_CTLCOLORSTATIC in the ProcessWindowMessage of the TabControl window this way:

else if (uMsg == WM_CTLCOLORSTATIC)
    return TRUE;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top