c++ - No LVIF_TEXT in LVN_GETDISPINFO message using LVS_OWNERDATA mode -
i've encountered unusual behavior in mfc when using list control (clistctrl
) lvs_report
style in "virtual mode" i.e. lvs_ownerdata
style. list view placed on modeless dialog.
in dialog's oninitdialog
method add together 2 columns -- "column 1" , "column 2" in 2 different ways -- using lvcolumn
, listview_insertcolumn
macro (1) , using cheaderctrl
class hditem
construction (2).
when using first method (1), in lvn_getdispinfo
message handler (message handled dialog, simple on_notify
) receive mask (nmlvdispinfo.item.mask
member) different bits set (lvif_text
, lvif_image
, lvif_state
, lvif_indent
etc.), after filling appropriate fields in nmlvdispinfo.item
structure, works fine.
but, when using sec method (2) involving cheaderctrl
class, bit in mask set lvif_indent
, never receive mask else set.
here pieces of code utilize add together columns:
method 1 (1):
lvcolumn col; col.mask = lvcf_text | lvcf_width; col.psztext = _t("column 1"); col.cx = 100; listview_insertcolumn(m_mylist, 0, &col); //m_mylist of clistctrl type col.psztext = _t("column 2"); listview_insertcolumn(m_mylist, 1, &col);
and method 2 (2):
hditem hditem; hditem.mask = hdi_text | hdi_format | hdi_width; hditem.fmt = hdf_string; hditem.cxy = 100; hditem.psztext = _t("column 1"); hditem.cchtextmax = _tcslen(hditem.psztext); m_mylist.getheaderctrl()->insertitem(0, &hditem); others_info.psztext = _t("column 2"); others_info.cchtextmax = _tcslen(hditem.psztext); m_mylist.getheaderctrl()->insertitem(1, &hditem);
what perchance cause such behavior?
method 2 incorrectly using others_info operations not others. looks first insertitem using text length perchance 0. sec phone call insertitem reuses same hditem construction hasn't been changed since first call.
c++ mfc
No comments:
Post a Comment