c++ - Ignoring Listcontrol 'DELETE_ALL_ITEMS' Event when closing application -
i have mfc listcontrol in application. have event occurs when "all items in view deleted". event throws error message , closes program.
my problem event gets called if x(close) button clicked.
here code lvn_deleteallitems event:
void users::onlvndeleteallitemslist1(nmhdr *pnmhdr, lresult *presult) { lpnmlistview pnmlv = reinterpret_cast<lpnmlistview>(pnmhdr); messagebox("the sql connection has been dropped. please restart application.","sql connection error",mb_iconstop); exit(exit_failure); *presult = 0; }
is there way keep event being called if application closed correctly (with button in top right corner)?
this normal behavior. when x button gets pressed, main window receives wm_close, , start call children destructors. when listview destructor called item cleaned up, there goes lvn_deleteallitems
notification.
the (logical) error connection db being dropped test being performed here (and abnormal exit
procedure). here listview additional tasks should performed. database connection check should handled higher in callstack: example place in code sent lvm_deleteallitems
(note lvm_deleteallitems), , triggered listview emptied.
Comments
Post a Comment