How to develop a ListView that has No background so that my Background image is displayed properly... I' not able to get through with this...
+1
A:
Have a look at this article and there is a control library which supports alpha blending which you might be able to extend to the ListView control as well.
tomlog
2009-06-10 10:14:27
+1
A:
You do it the same way you would in win32.
All you need to do is subclass the control and override the WM_ERASEBKGND
window message. You can also override the WM_CTLCOLOR
message to set the text mode into TRANSPARENT.
I've done this on almost all the standard controls and it works fine.
Update:
This a starting example in MFC, you still need to draw the background onto the control by some method.
class TransparentListView : public CListView
{
public:
TransparentListView();
virtual ~ToolsListCtrl();
protected:
afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
private:
DECLARE_MESSAGE_MAP();
};
IMPLEMENT_DYNAMIC(TransparentListView , CListView)
TransparentListView::TransparentListView()
{
}
TransparentListView::~TransparentListView()
{
}
BEGIN_MESSAGE_MAP(TransparentListView, CListView)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
HBRUSH TransparentListView::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
BOOL TransparentListView::OnEraseBkgnd(CDC* pDC)
{
// You will need to force the drawing of the background here
// onto the pDC, there are lots of ways to do this.
// I've done it my having a pointer to a interface that
// draws the background image
return TRUE;
}
Shane Powell
2009-06-10 10:20:48
Can you please give more light on this method of your it would be highly helpful...
y ramesh rao
2009-06-10 12:37:29
Updated answer with example.
Shane Powell
2009-06-10 19:01:05