Answered by:
Add 2 line at a listitem.

Question
-
Hello i am developing a win32 windows mobile application using win32 by c++. I want to know how can I add 2 line at listitem like : phone number at line and duratio to other line.
Syed JamilWednesday, September 7, 2011 8:54 AM
Answers
-
You are using a List View. A CListCtrl is an MFC wrapper for a List View.
Your LVITEM.cchTextMax value should be the "Number of TCHARs in the buffer pointed to by pszText, including the terminating NULL."
Is the code you posted not working at all or is it just not doing what you want? I only see one call to LVM_INSERTITEM in here. So, if you want to add two row, you will need a second LVM_INSERTITEM call.
If these changes don't fix your problem, post the return value of the SendMessage( ..., LVM_INSERTITEM,...); call and post the code used to create the List View control.
-PaulH
- Proposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
- Marked as answer by Jesse Jiang Tuesday, September 13, 2011 9:43 AM
Thursday, September 8, 2011 2:11 PM -
If you want one (1) list view item to draw on two lines
I'd consider implementing a owner-draw List-View control. This would give you the ability to draw the item yourself.
A sample showing how to do this can be found here: http://msdn.microsoft.com/en-us/library/bb158680.aspxThe basic concept is briefly eyplanined here: http://msdn.microsoft.com/en-us/library/bb775501(VS.85).aspx#ownerdrawn_user
MVP Windows Embedded- Proposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
- Marked as answer by Jesse Jiang Tuesday, September 13, 2011 9:43 AM
Friday, September 9, 2011 6:42 AM
All replies
-
Are you using a List Box control? Then, you can send an LB_ADDSTRING message to the list box window.
If you're using a List View, then you can send an LVM_INSERTITEM message to the list view window.
-PaulH
Wednesday, September 7, 2011 1:58 PM -
Thank you PaulH,
I am not using list Box or list View. I am working with list control. Please tell me what may be the step for this.
Syed JamilThursday, September 8, 2011 6:32 AM -
You sould show us the code you have for:
- creating the "list control" and adding itemsWithout additional information, it is hard for us to help you.
MVP Windows EmbeddedThursday, September 8, 2011 7:06 AM -
Hello,
This is my code for inserting item to the list control which I have added to my dialog by dragging from the toolbox.
void InsertCallLogTableList(HWND hTableList)
{
LVITEM listItem;
memset(&listItem, 0, sizeof(LVITEM));
// 1. one
listItem.mask = LVIF_IMAGE | LVIF_TEXT;
listItem.cchTextMax = 256;
TCHAR Temp[MAX_PATH] = {0};
for(int j = 0;j<100; j++)
{
//contactInfo c=p.contacts[j];
//listItem.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_INDENT;
listItem.iItem = j;
listItem.iSubItem = 0;
listItem.iImage = j%(MAX_LISTITEM + 1); // important: sign which image in imageList
listItem.pszText=_T("01748293456");
//SendMessage(hTableList,LB_SETITEMHEIGHT,0,(LPARAM)50);
SendMessage(hTableList, LVM_SETITEMSTATE, j, (LPARAM)&listItem);
SendMessage(hTableList,LVM_INSERTITEM,0,(LPARAM)&listItem); // Send info to the Listview
listItem.iSubItem=1;
//char phoneNumber[MAX_PATH];
//sprintf(phoneNumber,"%s \n %s","01748293456","3s");
//listItem.pszText=getTchar(phoneNumber);
listItem.pszText=_T("3s");
SendMessage(hTableList,LVM_SETITEM,0,(LPARAM)&listItem); // Enter text to SubItems
//listItem.cchTextMax
char dateTime[MAX_PATH];
int hour=0,minute=0,second=0,date=0,month=0,year=0;
sprintf(dateTime,"%d:%d %d/%d/%d",12,30,27,4,2011);
listItem.iSubItem=2;
listItem.pszText=getTchar(dateTime);
SendMessage(hTableList,LVM_SETITEM,0,(LPARAM)&listItem); // Enter text to SubItems
}
for(int i = 0; i <= 100; i++)
{
ListView_SetItemState(hTableList, i, 0, LVIS_SELECTED | LVIS_FOCUSED);
}
//ListView_DeleteAllItems(hTableList);
//istView_SetExtendedListViewStyle
}
Syed Jamil- Proposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
- Unproposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
Thursday, September 8, 2011 8:22 AM -
You are using a List View. A CListCtrl is an MFC wrapper for a List View.
Your LVITEM.cchTextMax value should be the "Number of TCHARs in the buffer pointed to by pszText, including the terminating NULL."
Is the code you posted not working at all or is it just not doing what you want? I only see one call to LVM_INSERTITEM in here. So, if you want to add two row, you will need a second LVM_INSERTITEM call.
If these changes don't fix your problem, post the return value of the SendMessage( ..., LVM_INSERTITEM,...); call and post the code used to create the List View control.
-PaulH
- Proposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
- Marked as answer by Jesse Jiang Tuesday, September 13, 2011 9:43 AM
Thursday, September 8, 2011 2:11 PM -
If you want one (1) list view item to draw on two lines
I'd consider implementing a owner-draw List-View control. This would give you the ability to draw the item yourself.
A sample showing how to do this can be found here: http://msdn.microsoft.com/en-us/library/bb158680.aspxThe basic concept is briefly eyplanined here: http://msdn.microsoft.com/en-us/library/bb775501(VS.85).aspx#ownerdrawn_user
MVP Windows Embedded- Proposed as answer by Jesse Jiang Monday, September 12, 2011 7:15 AM
- Marked as answer by Jesse Jiang Tuesday, September 13, 2011 9:43 AM
Friday, September 9, 2011 6:42 AM