delphi - How to detect a click on the CheckBox in the TListView -


so when user clicks on checkbox, want add item in list, have tried using onchange event not working me gets fired when checkbox not clicked.

my code simple , straightforward

procedure lvuserchange(sender: tobject; item: tlistitem;change: titemchange);  var  objuser : tusers; begin    if not assigned(objlistofchangedusers)    objlistofchangedusers := tobjectlist.create;     objuser := item.data;    objlistofchangedusers.add(objuser); end; 

i want code fired when checkbox clicked in listview

in delphi 2009 , later, can use tlistview.onitemchecked event detect checkbox clicks. delphi 2007 not have such event, in case need detect notification manually in own code. demonstrate interposer class, there other ways this.

uses   ..., commctrl, comctrls, ...;  type   tlistview = class(comctrls.tlistview)   protected     procedure cnnotify(var message: twmnotifylv); message cn_notify;   end;  ....  procedure tlistview.cnnotify(var message: twmnotifylv); begin   inherited;   if message.nmhdr.code = lvn_itemchanged   begin     if (message.nmlistview.uchanged = lvif_state) ,        ( ((message.nmlistview.uoldstate , lvis_stateimagemask) shr 12)          <> ((message.nmlistview.unewstate , lvis_stateimagemask) shr 12))     begin       // changing check box state land here     end;   end; end; 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -