Click here to Skip to main content
16,006,531 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Doubt in ICON resource Pin
ThatsAlok13-May-06 3:04
ThatsAlok13-May-06 3:04 
AnswerRe: Doubt in ICON resource Pin
PJ Arends13-May-06 9:27
professionalPJ Arends13-May-06 9:27 
Questioncrazyyyy..Function listing not shown in VS Pin
ppatel56712-May-06 18:30
ppatel56712-May-06 18:30 
AnswerRe: crazyyyy..Function listing not shown in VS Pin
ThatsAlok12-May-06 20:36
ThatsAlok12-May-06 20:36 
QuestionDrawing my own list control question Pin
YaronNir12-May-06 11:12
YaronNir12-May-06 11:12 
AnswerRe: Drawing my own list control question Pin
led mike12-May-06 11:45
led mike12-May-06 11:45 
GeneralRe: Drawing my own list control question Pin
YaronNir13-May-06 0:41
YaronNir13-May-06 0:41 
QuestionCListCtrl OwnerDrawFixed serious problem Pin
YaronNir12-May-06 9:04
YaronNir12-May-06 9:04 
Hi all,

I've create a class named CListCtrlEx derived from CListCtrl.

it is created as follows:

BOOL CListCtrlEx::Create(CWnd* pParentWnd,UINT nID)
{
	DWORD dwFlags = WS_CHILD|WS_TABSTOP|LVS_SMALLICON|LVS_SINGLESEL|LVS_SHOWSELALWAYS|WS_VISIBLE|LVS_NOCOLUMNHEADER;
	return CListCtrl::Create( dwFlags, CRect(0,0,0,0) , pParentWnd , nID); 
}

BOOL CListCtrlEx::PreCreateWindow(CREATESTRUCT& cs)
{
	cs.dwExStyle |= WS_EX_CLIENTEDGE;
	cs.style	 &= ~LVS_TYPEMASK;
	cs.style	 |= (LVS_SHOWSELALWAYS | LVS_OWNERDRAWFIXED);

	return CListCtrl::PreCreateWindow(cs);
}


in the message map i use :

BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl)
	ON_WM_PAINT()
	ON_WM_CREATE()
	ON_WM_DESTROY()
	ON_WM_ERASEBKGND()
	ON_WM_MEASUREITEM_REFLECT()
END_MESSAGE_MAP()


in MeasureItem :

void CListCtrlEx::MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
{
	lpMeasureItemStruct->itemHeight = ITEM_HEIGHT;
}


and in OnPaint:

void CListCtrlEx::OnPaint()
{
	CPaintDC dc(this); 
	int nCount = GetItemCount();
	DRAWITEMSTRUCT drawItem;
	for(int i=0; i < nCount;i++)
	{
		drawItem.itemID		= i;
		drawItem.CtlID		= GetDlgCtrlID();
		drawItem.CtlType	= ODT_LISTVIEW;
		drawItem.hDC		= dc.m_hDC;
		drawItem.hwndItem	= m_hWnd;
		drawItem.itemAction = ODA_DRAWENTIRE;
		drawItem.itemState  = 0;
		GetItemRect(i,&drawItem.rcItem,LVIR_BOUNDS); 
		DrawItem(&drawItem);
	}

}


I add items as follows:
m_List.Create(this,IDC_MY_LIST);
m_List.InsertItem(0,_T("aaaaaaaa"));
m_List.InsertItem(1,_T("bbbbbbbb"));


Problem is that i see the fist item from the middle of the list and not the top of it??

Any suggestions?

thanks

Yaron

Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp

don't forget to vote Smile | :)


-- modified at 15:05 Friday 12th May, 2006
AnswerRe: CListCtrl OwnerDrawFixed serious problem Pin
Michael Dunn12-May-06 9:56
sitebuilderMichael Dunn12-May-06 9:56 
GeneralRe: CListCtrl OwnerDrawFixed serious problem Pin
YaronNir12-May-06 10:00
YaronNir12-May-06 10:00 
GeneralRe: CListCtrl OwnerDrawFixed serious problem Pin
YaronNir12-May-06 10:48
YaronNir12-May-06 10:48 
QuestionC++ .NET & DLL Pin
Cantona2k12-May-06 8:18
Cantona2k12-May-06 8:18 
AnswerRe: C++ .NET & DLL Pin
Andy Moore12-May-06 9:09
Andy Moore12-May-06 9:09 
AnswerRe: C++ .NET & DLL Pin
toxcct12-May-06 10:03
toxcct12-May-06 10:03 
GeneralRe: C++ .NET & DLL Pin
ThatsAlok12-May-06 20:55
ThatsAlok12-May-06 20:55 
GeneralRe: C++ .NET & DLL Pin
shadrach_india12-May-06 23:26
shadrach_india12-May-06 23:26 
GeneralRe: C++ .NET & DLL Pin
Cantona2k13-May-06 23:23
Cantona2k13-May-06 23:23 
GeneralRe: C++ .NET & DLL Pin
Cantona2k14-May-06 5:55
Cantona2k14-May-06 5:55 
QuestionHow to unlock an application associated file? Pin
HumanOsc12-May-06 7:39
HumanOsc12-May-06 7:39 
AnswerRe: How to unlock an application associated file? Pin
toxcct12-May-06 9:57
toxcct12-May-06 9:57 
GeneralRe: How to unlock an application associated file? Pin
HumanOsc12-May-06 10:28
HumanOsc12-May-06 10:28 
QuestionCHTMLView Bug with IE 7 Pin
HaraldS12-May-06 7:30
HaraldS12-May-06 7:30 
QuestionBitmap problem Pin
srija12-May-06 6:37
srija12-May-06 6:37 
AnswerRe: Bitmap problem Pin
Hamid_RT12-May-06 7:55
Hamid_RT12-May-06 7:55 
QuestionESC problem Pin
mkoliv12-May-06 4:54
mkoliv12-May-06 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.