visual c++ - Is there a way to override the handler called when a user clicks a checkbox in a CListCtrl? (MFC) -


i trying disable user's ability alter state of checkbox in list control. changing state pragmatically. handle lvn_itemchanged message, , trying alter state there isn't option due layout of rest of program. have tried doing hittest when user clicks in list control , resetting checkbox there isn't giving me exact results looking for.

is there specific message sent or function can override when user clicks checkbox itself? override handler or catch message doesn't go anywhere.

solution:

i ended removing lvs_ex_checkboxes flag , created own implementation. way there 1 way change icons. reading link previous question gave me idea set "busy" flag, otherwise stack overflow errors.

// in dialog class m_clistctrl.setimagelist(&m_imglist, lvsil_small);    // custom checkboxes (only 2 images)  // ... void cmydialog::onlvnitemchangedlist(nmhdr *pnmhdr, lresult *presult) {    if(busy) { return; }    // .... }   // when calling setcheck function: busy = true;   // avoid stack overflow errors m_clistctrl.setcheck(index, fcheck); busy = false;  // derived class clistctrl , did override on get/set check: class ccustomlistctrl : public clistctrl {     bool ccustomlistctrl::setcheck(int nitem, bool fcheck)     {         tchar szbuf[1024];         dword ccbuf(1024);         lvitem lvi;         lvi.iitem = nitem;         lvi.isubitem = 0;         lvi.mask = lvif_text | lvif_image;         lvi.psztext = szbuf;         lvi.cchtextmax = ccbuf;         getitem(&lvi);         lvi.iimage = (int)fcheck;         setitem(&lvi);         return true;     }     // need determine image set in list control item     bool ccustomlistctrl::getcheck(int nitem)     {         lvitem lvi;         lvi.iitem = nitem;         lvi.isubitem = 0;         lvi.mask = lvif_image;         getitem(&lvi);         return (bool)(lvi.iimage);     } } 

this not elegant had hoped, works flawlessly.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -