I've a problem again, this time with a listview and style LVS_EDITLABELS. If I use a listview inside a dialog with the LVS_EDITLABELS Flag, the edit appear, but if I put one char inside the edit control, the dialog aborts immediately with the OnOK handler. If I add handlers for LVN_BEGINLABELEDIT and LVNENDLABELEDIT, the BEGIN is called, all is fine, after putting one (or here sometimes two chars) into the edit, the END is called also immediately and contains a null pointer to the text in the DISPINFO.
To reproduce my problem I have changed your "Dialog" sample in the following way:
CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,120,23,84,45
Add to class in MyDialog.h:
CListView m_listview;
Changes in MyDialog.cpp in OnInitDialog:
// Put some text in the list box//for (int i = 0 ; i < 8 ; i++)// SendDlgItemMessage(IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) _T("List Box"));AttachItem(IDC_LIST1,m_listview);LV_COLUMNlvColumn={0};lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT;lvColumn.fmt=LVCFMT_LEFT;lvColumn.cx=100;lvColumn.pszText=_T("Column");m_listview.InsertColumn(0,lvColumn);LVITEMlvi={0};lvi.mask=LVIF_TEXT;lvi.iItem=0;lvi.pszText=_T("HELLO");m_listview.InsertItem(lvi);
Compile and press left mouse twice (no doubleclick) on HELLO to change to edit mode.
Put a char into the edit.
OnOK appears
For me, this seems not ok, in a greater application this is the reason for aborting the dialog. If I do it in the same way in a simple real MFC app, this app works fine.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Further analysis say, that the problem is in wxx_dialog.h
The standard EDIT inside the LISTVIEW has the id 1, same as IDOK, but in the HIWORD of wParam is EN_CHANGE and not BN_CLICKED like clicking on buttons. Masking this out, the problem disappears.
Thanks for identifying this issue and describing it so clearly.
I've incorporated the fix you've suggested and posted the updated code to SourceForge. You can download the latest Win32++ code by going to the Code section and downloading the Snapshot.
If you download the latest code, be sure to check the changes.txt file in the include directory.
Best regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi David,
I've a problem again, this time with a listview and style LVS_EDITLABELS. If I use a listview inside a dialog with the LVS_EDITLABELS Flag, the edit appear, but if I put one char inside the edit control, the dialog aborts immediately with the OnOK handler. If I add handlers for LVN_BEGINLABELEDIT and LVNENDLABELEDIT, the BEGIN is called, all is fine, after putting one (or here sometimes two chars) into the edit, the END is called also immediately and contains a null pointer to the text in the DISPINFO.
To reproduce my problem I have changed your "Dialog" sample in the following way:
Replace inside the Resource.rc:
with
Add to class in MyDialog.h:
Changes in MyDialog.cpp in OnInitDialog:
For me, this seems not ok, in a greater application this is the reason for aborting the dialog. If I do it in the same way in a simple real MFC app, this app works fine.
Further analysis say, that the problem is in wxx_dialog.h
The standard EDIT inside the LISTVIEW has the id 1, same as IDOK, but in the HIWORD of wParam is EN_CHANGE and not BN_CLICKED like clicking on buttons. Masking this out, the problem disappears.
I played a little bit with the workaround and found no further problems, here my proposal
Hi Torsten,
Thanks for identifying this issue and describing it so clearly.
I've incorporated the fix you've suggested and posted the updated code to SourceForge. You can download the latest Win32++ code by going to the Code section and downloading the Snapshot.
If you download the latest code, be sure to check the changes.txt file in the include directory.
Best regards,
David