本程序 CColorListBox 实现彩色文本列表框(A list box with colored strings),如图:
彩色文本列表框(A list box with colored strings)程序拥有下列特性:
The focus rectangle is now drawn only when the control has the input focus.
Items in the list are properly colored when the list box is disabled.
Items in the list are properly displayed when the LBS_USETABSTOPS style is set.
The entire rectangle of the selected item is now colored, instead of just the text background rectangle.
When an item is selected, the text color inverts, and the highlight color is the original text color (like the Cyan list item in the above graphic).
彩色文本列表框(A list box with colored strings) 提供下列公共接口:
int AddString(LPCTSTR lpszItem);
int AddString(LPCTSTR lpszItem, COLORREF rgb);
int InsertString(int nIndex, LPCTSTR lpszItem);
int InsertString(int nIndex, LPCTSTR lpszItem, COLORREF rgb);
void SetItemColor(int nIndex, COLORREF rgb);
彩色文本列表框(A list box with colored strings) 示例代码:
m_lbColor.AddString("Green", RGB(0, 255, 0));
m_lbColor.InsertString(0, "Red", RGB(255, 0, 0));
下载彩色文本列表框(A list box with colored strings)源代码及演示程序