Thanks to the original author and the other contributors for this control!
I did observe one aesthetic issue, as follows:
Version 1.3 of the CColourPicker control is vertically "scrunched" when compared to the
equivalent controls in Microsoft Office 2000 (Beta). To achieve the same appearance as the MS-Office 2000
color picker controls, set the height of this control to same size as a default-sized combo box (14 vertical
dialog units) and use the new version of CColourPicker::SetWindowSize() shown below. This code contains a
small change to use the greater of the color picker's minimum height or the height of its window (for
example, a button laid out in the dialog editor).
// Get size dimensions of edges
CSize MarginSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));
// Get size of dropdown arrow
int nArrowWidth = max(::GetSystemMetrics(SM_CXHTHUMB), 5*MarginSize.cx);
int nArrowHeight = max(::GetSystemMetrics(SM_CYVTHUMB), 5*MarginSize.cy);
CSize ArrowSize(max(nArrowWidth, nArrowHeight), max(nArrowWidth, nArrowHeight));
// Get window size
CWnd* pParent = GetParent();
// Set window size at least as wide as 2 arrows, and as high as arrow + margins
int nWidth = max(rect.Width(), 2*ArrowSize.cx + 2*MarginSize.cx);
int nHeight = max(rect.Height(), ArrowSize.cy+2*MarginSize.cy);
MoveWindow(rect.left, rect.top, nWidth, nHeight, TRUE);
// Get the new coords of this window
// Get the rect where the arrow goes, and convert to client coords.
m_ArrowRect.SetRect(rect.right - ArrowSize.cx - MarginSize.cx,
rect.top + MarginSize.cy, rect.right - MarginSize.cx,
rect.bottom - MarginSize.cy);
Just two things when you add control into the CReBar:
I found easier to send notification messages to parent frame instead parent window. So, I changed calls
GetParent() into the GetParentFrame() in functions OnSelEndOK, OnSelEndCancel and OnSelChange. Otherwise,
messages comes to CReBar window.
Also, because of resizing bar features in CReBar, I added WM_SIZE handling in CColourPicker. It is needed
to update m_ArrowRect member:
void CColourPicker::OnSize(UINT nType, int cx, int cy)