Re: Read-only CCheckListBox?
#pragma once
// CMyCheckListBox
class CMyCheckListBox : public CCheckListBox
{
DECLARE_DYNAMIC(CMyCheckListBox)
public:
CMyCheckListBox();
virtual ~CMyCheckListBox();
protected:
virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
DECLARE_MESSAGE_MAP()
};
// MyCheckListBox.cpp : implementation file
//
#include "stdafx.h"
#include "MyCheckListBox.h"
// CMyCheckListBox
IMPLEMENT_DYNAMIC(CMyCheckListBox, CCheckListBox)
CMyCheckListBox::CMyCheckListBox()
{
}
CMyCheckListBox::~CMyCheckListBox()
{
}
BEGIN_MESSAGE_MAP(CMyCheckListBox, CCheckListBox)
END_MESSAGE_MAP()
// CMyCheckListBox message handlers
void CMyCheckListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (lpDrawItemStruct->rcItem.left == 0)
{
return;
}
CDC DC;
DC.Attach(lpDrawItemStruct->hDC);
CString Text;
GetText(lpDrawItemStruct->itemID,Text);
DC.DrawText(Text,&lpDrawItemStruct->rcItem,DT_SINGLELINE);
DC.Detach();
}
AliR.
"dB." <dblock@dblock.org> wrote in message
news:f4e9aae5-a03e-4696-8aca-110911a63b43@j1g2000yqi.googlegroups.com...
Right, I don't want to gray things out. Any sample(s) of an ownerdraw
listbox based on the CCheckListBox code? I don't want to rewrite the
whole thing.
On Feb 19, 11:16 am, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
CCheckListBox has a method called Enable. This method will let you
enable/disable individuale items in your listbox. This way the checkbox's
can't be manupuliated but the list can be scrolled.
void CMyCheckListBox::SetReadOnly(BOOL ReadOnly)
{
for (int i = 0; i < GetCount();i++)
{
Enable(i,!ReadOnly);
}
}
But it grays the item text. If you don't want that to happen, then you
need
to create an ownerdraw listbox.
AliR.
"dB." <dbl...@dblock.org> wrote in message
news:8881c572-0875-464a-80ff-de71030bbed5@e18g2000yqo.googlegroups.com...
I am trying to get a read-only (but not disabled) CCheckListBox. Is
this possible?
Thx
dB.- Hide quoted text -
- Show quoted text -