MFC: How to custom draw a dynamically created CListCtrl -


i need customize head/row height of clistctrl. after googling, know need subclass clistctrl, wrote own list class, outline follows:

class clistctrlcl : public clistctrl {     declare_dynamic(clistctrlcl)  public: 

...

begin_message_map(clistctrlcl, clistctrl)     on_wm_measureitem()     on_wm_measureitem_reflect() end_message_map() void clistctrlcl::presubclasswindow() {     modifystyle(0,lvs_ownerdrawfixed);     clistctrl::presubclasswindow();     cheaderctrl *pheader = getheaderctrl();     m_header.subclasswindow(pheader->getsafehwnd()); } void clistctrlcl::measureitem(lpmeasureitemstruct lpmeasureitemstruct) {     if (m_nrowheight>0)     {         lpmeasureitemstruct->itemheight = 100;     } } 

the problem method worked if drag clistctrl control in dialog template, if create listctrl dynamically, like:

bool clistctrltestdlg::oninitdialog() { crect rect(7,7,300,300); this->m_listctrl.create(ws_child|ws_visible|ws_vscroll|lvs_report|lvs_alignleft|ws_border | ws_tabstop, rect, this,idc_list1 + 1); setwindowlong(m_listctrl.m_hwnd ,gwl_exstyle,ws_ex_clientedge); m_listctrl.setextendedstyle(lvs_ex_gridlines);                      ::sendmessage(m_listctrl.m_hwnd, lvm_setextendedlistviewstyle,lvs_ex_fullrowselect, lvs_ex_fullrowselect); 

...

then customization code doesn't take effect. whatever did, result listctrl standard 1 without customization. need create listctrl dynamically, tell me need make dynamically created clistctrl customizable?

thanks.

you've left off necessary style custom drawing when create control. add lvs_ownerdrawfixed. should fix problem.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -