How to Add String in MultiColumn ListBox
-
Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain
-
Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain
PK Jain wrote:
But it is not working.
What is exact problem ?
PK Jain wrote:
I want to Add "Hi" in one column and "All" other.
WPARAM
value refers to item index, not column index.Prasad Notifier using ATL | Operator new[],delete[][^]
-
PK Jain wrote:
But it is not working.
What is exact problem ?
PK Jain wrote:
I want to Add "Hi" in one column and "All" other.
WPARAM
value refers to item index, not column index.Prasad Notifier using ATL | Operator new[],delete[][^]
Thanks, But my query is not solved How to Add String in MultiColumn ListBox using SendDlgItemMessage
Pankaj Jain
-
Thanks, But my query is not solved How to Add String in MultiColumn ListBox using SendDlgItemMessage
Pankaj Jain
PK Jain wrote:
But my query is not solved
For that you need to answer questions asked. I asked, what do you mean by not working ?
PK Jain wrote:
How to Add String in MultiColumn ListBox using SendDlgItemMessage
Same as you written in in your original post. I think you mistaken multicolumn with number of columns as in list box. In case of list box, multi column means, there will be no vertical scrolling as number of string keeps increasing. Instead, string will be added to next column and so on, and horizontal scroll bar will appear. I hope this clear your doubts.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi All I m working on a ATL Project. I have to add string in a multi column List box using SendDlgItemMessage() but I dont get any idea about that. I m using it like this SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 0, (LPARAM)"Hi"); SendDlgItemMessage(IDC_LIST1, LB_INSERTSTRING, (WPARAM) 1, (LPARAM)"All"); But it is not working. I want to Add "Hi" in one column and "All" other. If u have any Idea Please suggest me Thanks & Regards Pankaj Jain
A MultiColumn ListBox doesn't give that functionality - you want a ListView instead. To add text to a ListView in the way you want, use something like:
// Set up the columns LVCOLUMN col = {0}; SendDlgItemMessage(IDC_LIST2, LVM_INSERTCOLUMN, 0, (LPARAM)&col); col.iSubItem = 1; SendDlgItemMessage(IDC_LIST2, LVM_INSERTCOLUMN, 1, (LPARAM)&col); LVITEM item = {0}; item.mask = LVIF_TEXT; item.iSubItem = 0; item.pszText = "Hi"; int itemIndex = (int)SendDlgItemMessage(IDC_LIST2, LVM_INSERTITEM, 0, (LPARAM)&item); item.iSubItem = 1; item.pszText = "All"; SendDlgItemMessage(IDC_LIST2, LVM_SETITEMTEXT, itemIndex, (LPARAM)&item); SendDlgItemMessage(IDC_LIST2, LVM_SETCOLUMNWIDTH, 0, LVSCW_AUTOSIZE); SendDlgItemMessage(IDC_LIST2, LVM_SETCOLUMNWIDTH, 1, LVSCW_AUTOSIZE);
[Updated to correct code, add column sizing]
Last modified: 17mins after originally posted --
-
PK Jain wrote:
But my query is not solved
For that you need to answer questions asked. I asked, what do you mean by not working ?
PK Jain wrote:
How to Add String in MultiColumn ListBox using SendDlgItemMessage
Same as you written in in your original post. I think you mistaken multicolumn with number of columns as in list box. In case of list box, multi column means, there will be no vertical scrolling as number of string keeps increasing. Instead, string will be added to next column and so on, and horizontal scroll bar will appear. I hope this clear your doubts.
Prasad Notifier using ATL | Operator new[],delete[][^]
Thanks Prasad, Thanks to clear my doubts
Pankaj Jain