* @param [in] elName String to format as beginning tag.
* @return String formatted as beginning tag.
*/
-static String BeginEl(const String& elName)
+static String BeginEl(const String& elName, const String& attr = _T(""))
{
- return string_format(_T("<%s>"), elName.c_str());
+ if (attr.empty())
+ return string_format(_T("<%s>"), elName.c_str());
+ else
+ return string_format(_T("<%s %s>"), elName.c_str(), attr.c_str());
}
/**
String rowEl = _T("tr");
if (xml)
+ {
rowEl = _T("filediff");
- WriteString(BeginEl(rowEl));
+ WriteString(BeginEl(rowEl));
+ }
+ else
+ {
+ COLORREF color = m_pList->GetBackColor(currRow);
+ String attr = string_format(_T("style='background-color: #%02x%02x%02x'"),
+ GetRValue(color), GetGValue(color), GetBValue(color));
+ WriteString(BeginEl(rowEl, attr));
+ }
for (int currCol = 0; currCol < m_nColumns; currCol++)
{
String colEl = _T("td");
-#include "IListCtrl.h"\r
-#include <commctrl.h>\r
-\r
-class IListCtrlImpl : public IListCtrl\r
-{\r
-public:\r
- IListCtrlImpl(HWND hwndListCtrl) : m_hwndListCtrl(hwndListCtrl)\r
- {\r
- }\r
-\r
+#include "IListCtrl.h"
+#include <commctrl.h>
+
+class IListCtrlImpl : public IListCtrl
+{
+public:
+ IListCtrlImpl(HWND hwndListCtrl) : m_hwndListCtrl(hwndListCtrl)
+ {
+ }
+
int GetColumnCount() const
{
return Header_GetItemCount(ListView_GetHeader(m_hwndListCtrl));
return lvc.pszText;
}
- String GetItemText(int row, int col) const\r
- {\r
+ String GetItemText(int row, int col) const
+ {
TCHAR text[512]; // Assuming max col header will never be > 512
- ListView_GetItemText(m_hwndListCtrl, row, col, text, sizeof(text)/sizeof(text[0]));\r
- return text;\r
- }\r
-\r
-protected:\r
- HWND m_hwndListCtrl;\r
-};
\ No newline at end of file
+ ListView_GetItemText(m_hwndListCtrl, row, col, text, sizeof(text)/sizeof(text[0]));
+ return text;
+ }
+
+ int GetBackColor(int row) const
+ {
+ NMLVCUSTOMDRAW nmlvcd = {0};
+ nmlvcd.nmcd.hdr.code = NM_CUSTOMDRAW;
+ nmlvcd.nmcd.hdr.idFrom = GetDlgCtrlID(m_hwndListCtrl);
+ nmlvcd.nmcd.hdr.hwndFrom = m_hwndListCtrl;
+ nmlvcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT | CDDS_SUBITEM;
+ nmlvcd.nmcd.dwItemSpec = row;
+ SendMessage(GetParent(m_hwndListCtrl), WM_NOTIFY, (WPARAM)m_hwndListCtrl, (LPARAM)&nmlvcd);
+ return nmlvcd.clrTextBk;
+ }
+
+protected:
+ HWND m_hwndListCtrl;
+};