Thanks Frank J. Lagattuta!
It's really problem with coloring CListCtrl with using Geometry in Dialog!
NM_CUSTOMDRAW doesn't work cristal!
to get CDDS_ITEMPREPAINT you should use Frank J. Lagattuta OnNotify function!
Need help on how to use the Geometry templates in Composite
ATL controls used in MFC applications. For example a Composite ATL control has couple of edit controls and comboboxes. Need only to resize Edit controls.
I wanted to be able to allow the user to save the resized
window dimensions, but unfortunately I could not initialize
the window to the new size without experiencing some
amusing problems with the controls. That is, the controls
would be one size, while the window would be the original
size of the resource.
So, I modified and exposed the GeometryInitialize()
function to give me a way around the problem.
The new GeometryInitialized() function now looks like this:
// pExt is the new size of the parent rect
// mExt is the initial size of the parent rect
int x = m_rsctl.m_iRect.left;
int y = m_rsctl.m_iRect.top;
int cx = m_rsctl.m_iRect.Width();
int cy = m_rsctl.m_iRect.Height(); // the new coordinates of the control rect
if (m_constraint.m_options & CConstraint::eRatioX)
x = pExt.cx*m_rsctl.m_iRect.left/mExt.cx;
if (m_constraint.m_options & CConstraint::eRatioCX)
cx = pExt.cx*m_rsctl.m_iRect.Width()/mExt.cx;
if (m_constraint.m_options & CConstraint::eRatioY)
y = pExt.cy*m_rsctl.m_iRect.top/mExt.cy;
if (m_constraint.m_options & CConstraint::eRatioCY)
cy = pExt.cy*m_rsctl.m_iRect.Height()/mExt.cy;
if (m_constraint.m_options & CConstraint::eCenterX)
x += (pExt.cx-mExt.cx)/2;
if (m_constraint.m_options & CConstraint::eCenterY)
y += (pExt.cy-mExt.cy)/2;
if (m_constraint.m_options & CConstraint::eResizeCX)
cx += (int)((pExt.cx-mExt.cx) * m_constraint.m_cxratio);
if (m_constraint.m_options & CConstraint::eResizeCY)
cy += (int)((pExt.cy-mExt.cy) * m_constraint.m_cyratio);
if (m_constraint.m_options & CConstraint::eMoveX)
x += (int)((pExt.cx-mExt.cx) * m_constraint.m_xratio);
if (m_constraint.m_options & CConstraint::eMoveY)
y += (int)((pExt.cy-mExt.cy) * m_constraint.m_yratio);
if (x < m_rsctl.m_iRect.left)
x = m_rsctl.m_iRect.left;
if (y < m_rsctl.m_iRect.top)
y = m_rsctl.m_iRect.top;
if (cx < m_rsctl.m_iRect.Width())
cx = m_rsctl.m_iRect.Width();
if (cy < m_rsctl.m_iRect.Height())
cy = m_rsctl.m_iRect.Height();
Great code! I use it with a CFormView derived class of
mine - repositions/resizes controls, works great!
However, I ran into a problem. In my FormView I have
list ctrls and tree ctrls that allow for in-place editing
for subitems using dropdown list ctrl, spin ctrls, etc.
I have implemented this as described in other sections of
Basically, the list/tree ctrls use message reflection to
handle the BeginLabelEdit and EndLabelEdit notifications
and in their handling create an in-place ctrl of the proper
type, give it focus, and let the user edit. When the
in-place edit ctrl loses focus, it destroys itself and
sends an EndLabelEdit message back to the list/tree ctrl.
In geometry.h there is an override of the CWnd::OnNotify
function that looks like this: