Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Editable ListView not Working

$
0
0

Hi all,

I am developing in Native C++ in a Win32 API environment using Visual Studio 2008. I am trying to edit a Subitem in a ListView with checkboxes. Although I have done a lot of research on this subject, I am very confused as I still cannot get it to work and I now really need some help.

The ListView is created as follows:

if(GetDlgItem(hWnd, IDLV_TICK_EDIT) == 0)

{

           hLV_Tick_Edit = CreateWindowEx(

           NULL,

           WC_LISTVIEW,

           NULL,

           WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE | WS_GROUP |

           WS_TABSTOP | LVS_REPORT | LVS_SINGLESEL | LVS_EDITLABELS,

           2, 309, 1006, 215,

           hWnd,

           (HMENU) IDLV_TICK_EDIT,

           (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),

           NULL);

           

           ListView_SetExtendedListViewStyle(hLV_Tick_Edit, LVS_EX_CHECKBOXES |

           LVS_EX_ONECLICKACTIVATE | LVS_EX_FULLROWSELECT, 0);

}

Excerpts fromWM_NOTIFY are as follows:

case WM_NOTIFY:

case LVN_ODSTATECHANGED:

           if(((LPNMHDR)lParam) -> idFrom == IDLV_GROUP)

           {

           //....Program lines

           }

switch(((LPNMHDR)lParam)->code)

{

case LVN_KEYDOWN:

           //....Program lines

           break;

case NM_DBLCLK:

           if(((LPNMHDR)lParam) -> idFrom == IDLV_TICK_EDIT)

           {

                       //....Program lines

nmh.hwndFrom = GetDlgItem(hWnd, IDLV_TICK_EDIT);

nmh.idFrom     = GetDlgCtrlID(GetDlgItem(hWnd, IDLV_TICK_EDIT));

                       nmh.code         = LVN_ENDLABELEDIT;

SendMessage(GetParent(GetDlgItem(hWnd, IDLV_TICK_EDIT)), WM_NOTIFY, (WPARAM) nmh.hwndFrom, (LPARAM)&nmh);

                       break;

           }

case LVN_BEGINLABELEDIT:

hEdit = ListView_GetEditControl(GetDlgItem(hWnd, IDLV_TICK_EDIT));

           break;

case LVN_ENDLABELEDIT:

           //....Program lines not yet done. To be done only when a valid value is stored in hEdit.

break;

}

I have the following points/questions:

  1. When the program is sent toLVN_ENDLABELEDIT, there is no handel value in hEdit.
  2. I am unsure what to put into LVN_ENDLABELEDIT, mostly because the examples I have seen are extremely confusing.
  3. I read somewhere that a subitem cannot be edited and that the only way to edit a subitem is through an edit control. Then useListView_SetItemText() to change the respective subitem’s text. Is this the true?

Any suggestions, comments etc would be appreciated.

Regards,

Richard


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>