Originally posted by: dsfy
in dire need of this ,please help me !thanks
ReplyOriginally posted by: MikeGong
Please tell me how to change background color of
Header control.
thanks
Originally posted by: Moisha
The only bad thing about SetBkColor() and SetTextBkColor()
The rest is very simple.
#define RGB_INFOCUS RGB(0xff,0xff,0xff)
....
void CXYZView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
COLORREF c=bActivate?RGB_INFOCUS:RGB_NOFOCUS;
And it is also important to Create() views with
BOOL CXYZView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
That's all!
I had to indicate in some way which of the two
CListView-derived views has the input focus.
Changing background color would be ok.
is that you have to invoke them both.
#define RGB_NOFOCUS RGB(0xe0,0xe0,0xe0)
{
CListCtrl&l=GetListCtrl();
l.SetBkColor(c);
l.SetTextBkColor(c);
l.Invalidate(TRUE);
CListView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
the BgColor that corresponds to "no focus" state:
{
....
CListCtrl&l=GetListCtrl();
l.SetBkColor(RGB_NOFOCUS);
l.SetTextBkColor(RGB_NOFOCUS);
....
}
Reply
Originally posted by: Radu
Here is an example:
typedef struct
TXREF Channels[] =
m_bluecolor=RGB(225,240,250); // blue
CDialog::OnInitDialog();
//insert 2 columns m_listCtrl.InsertColumn(0,"Values",LVCFMT_LEFT,50,0); m_listCtrl.InsertColumn(1,"Channels",LVCFMT_LEFT,80,1);
//populate columns with values and labels
//Sets the text background color
//Sets the the background color of the control so you don't //need to handle OnEraseBkgnd
Then you don't need OWNERDRAWFIXED. So you don't need all the code to draw everything yourself.Also you don't need to handle OnEraseBkgnd to change the background color of the control itself(se example below).
BOOL ConfigEditDlg::OnInitDialog()
{
listVals = "0x18";
{
TCHAR Name[10];
}TXREF;
{
{"TX0"},
{"TX1"},
{"TX2"},
{"TX3"},
{"TX4"},
{"TX5"},
{"TX6"},
{"TX7"},
{"TX8"},
{"TX9"},
{"TX10"},
{"TX11"},
};
UpdateData(TRUE); // bring the information from the dialog.
//list control initializing
for (int k= 0; k<12; k++)
{
m_listCtrl.InsertItem(k,listVals);
m_listCtrl.SetItemText(k,1,Channels[k].Name);
}
m_listCtrl.SetTextBkColor(m_bluecolor);
m_listCtrl.SetBkColor(m_bluecolor);
return TRUE;
}
Originally posted by: Duke
I can't find Demo Project or Source Code....
Where can I get it?
Thank you in advance...
plz tell me where i found source code thanks yogesh yogesh28577@yahoo.co.in
ReplyOriginally posted by: Jesvh
DrawItem() is not a member function of CListView....
If you use GetListCtrl() to get list control of CListView , how can I override its member function DrawItem()?
Thank you for your help!!
Reply
Originally posted by: mouse
Hi,
Any source code for this?
Thx,
Zhou Hao
ReplyOriginally posted by: toreaian
Is there any problem if I use SetBkColor() and
SetTextBkColor()?
Reply
Originally posted by: Broderick
I was wondering how to change the background color if you have a class derived from CListView.
Does this code only work if you use CListCtrl?
Thanks!
ReplyOriginally posted by: Jaewoon Lee
From:
pDC->DrawText(sLabel,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP
To:
// Draw normal and overlay icon
pDC->SetTextColor(GetTextColor()); // Insert this code
pDC->DrawText(sLabel,-1,rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP
I think hard coding is not good style... :-(
So, I changed some codes in ListCtrlEx.cpp.
1.
From "pDC->FillRect(rcRow, &CBrush(RGB(255,255,0));"
To "pDC->FillRect(rcRow, &CBrush(GetBkCOlor()));"
2.
// Draw normal and overlay icon
pImageList = GetImageList(LVSIL_SMALL);
if (pImageList) {
UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK;
pImageList->Draw(pDC, lvi.iImage,
CPoint(rcIcon.left, rcIcon.top),
(bHighlight?ILD_BLEND50:0) | ILD_TRANSPARENT | nOvlImageMask );
}
// Draw item label - Column 0
rcLabel.left += offset/2;
rcLabel.right -= offset;
| DT_VCENTER | DT_END_ELLIPSIS);
pImageList = GetImageList(LVSIL_SMALL);
if (pImageList) {
UINT nOvlImageMask=lvi.state & LVIS_OVERLAYMASK;
pImageList->Draw(pDC, lvi.iImage,
CPoint(rcIcon.left, rcIcon.top),
(bHighlight?ILD_BLEND50:0) | ILD_TRANSPARENT | nOvlImageMask );
}
// Draw item label - Column 0
rcLabel.left += offset/2;
rcLabel.right -= offset;
pDC->SetBkColor(GetTextBkColor()); // Insert this code
| DT_VCENTER | DT_END_ELLIPSIS);