help coloring individual listview item instead of all listview item in visual c++ [modified]
-
Hi all. i am using this code to change color of listview item. But unfortunetly it goes and changes color of all item instead of only changing the color selected listview item. Could an expert look at this and show me how i can only change color of selected listview item instead of coloring all items in listview.Thanks
void CColor1Dlg::OnButton1() { HWND hPalWnd = ::FindWindow("my window class", NULL); HWND spilterwindow = FindWindowEx(hPalWnd, 0, "WTL_SplitterWindow", 0); spilterwindow = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0); HWND ATL = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0); HWND ATLWIN = FindWindowEx(ATL, 0, "atl:0053c8d0", 0); HWND Dialog = FindWindowEx(ATLWIN, 0, "SysListView32", 0); HWND Rich = FindWindowEx(Dialog, 0, "SysHeader32", 0); CButton *pButton1 = (CButton*)GetDlgItem(IDC_BUTTON1); COLORREF GetBkColor(IDC_BUTTON1); //COLORREF color = m_color.GetColor(); **COLORREF color = 33023;** TRACE("Color of the selected font = %8x\n", color); //CButton *pButton = (CButton*)GetDlgItem(IDC_BUTTON2); //pButton->SetWindowText("Shoot"); **::SendMessage(Dialog, LVM_SETTEXTCOLOR, 0, color);** }
-- modified at 12:16 Friday 7th July, 2006 -
Hi all. i am using this code to change color of listview item. But unfortunetly it goes and changes color of all item instead of only changing the color selected listview item. Could an expert look at this and show me how i can only change color of selected listview item instead of coloring all items in listview.Thanks
void CColor1Dlg::OnButton1() { HWND hPalWnd = ::FindWindow("my window class", NULL); HWND spilterwindow = FindWindowEx(hPalWnd, 0, "WTL_SplitterWindow", 0); spilterwindow = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0); HWND ATL = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0); HWND ATLWIN = FindWindowEx(ATL, 0, "atl:0053c8d0", 0); HWND Dialog = FindWindowEx(ATLWIN, 0, "SysListView32", 0); HWND Rich = FindWindowEx(Dialog, 0, "SysHeader32", 0); CButton *pButton1 = (CButton*)GetDlgItem(IDC_BUTTON1); COLORREF GetBkColor(IDC_BUTTON1); //COLORREF color = m_color.GetColor(); **COLORREF color = 33023;** TRACE("Color of the selected font = %8x\n", color); //CButton *pButton = (CButton*)GetDlgItem(IDC_BUTTON2); //pButton->SetWindowText("Shoot"); **::SendMessage(Dialog, LVM_SETTEXTCOLOR, 0, color);** }
-- modified at 12:16 Friday 7th July, 2006That code looks like an absolute nightmare... I think that in order to do what you want you would need to have to do custom draw for your list view.
-
That code looks like an absolute nightmare... I think that in order to do what you want you would need to have to do custom draw for your list view.
could u help me how to make a code that custom draw for my list view. I am not very expert in visual c++ so i be happy if u show how this can be done. Furthermore, why u say the code i a nightmare!! it does not crash any thing!!! it just does more then what i wanted it to do!
-
could u help me how to make a code that custom draw for my list view. I am not very expert in visual c++ so i be happy if u show how this can be done. Furthermore, why u say the code i a nightmare!! it does not crash any thing!!! it just does more then what i wanted it to do!
-
could u help me how to make a code that custom draw for my list view. I am not very expert in visual c++ so i be happy if u show how this can be done. Furthermore, why u say the code i a nightmare!! it does not crash any thing!!! it just does more then what i wanted it to do!
If not crashing is your metric by which you judge a piece of code... then there's nothing much I can say. Why do you have such a long chain of FindWindow() functions? And why aren't you using the RGB macro for generating the COLORREF. I'm sure not many people would know what RGB values make up 33023 offhand. MFC custom draw article http://www.codeproject.com/listctrl/lvcustomdraw.asp[^] WTL custom draw article. http://www.codeproject.com/wtl/customdrawlist_wtl.asp[^]