c++ - How to get left click notification on an edit control? -
i want track event of single left-click on edit control. override pretranslatemessage
function below:
bool cmyclass::pretranslatemessage(msg* pmsg) { switch(pmsg->message) case wm_lbuttondown: { cwnd* pwnd = getfocus(); if (pwnd->getdlgctrlid == my_edit_ctrl_id) { //do thing } break; } }
the problem when click on edit control, other control become disabled (for example buttons don't respond clicks etc.)
how can fix problem? or how can track click notificationn on edit box?
you need this:
bool cmyclass::pretranslatemessage(msg* pmsg) { switch(pmsg->message) { case wm_lbuttondown: { cwnd* pwnd = getfocus(); if (pwnd->getdlgctrlid() == my_edit_ctrl_id) // << typo corrected here { //do thing } break; } } return __super::pretranslatemessage(pmsg); //<< added }
btw bit awkword use switch statement here. following code cleaner imo, unless want add morecases wm_lbuttondown:
bool cmyclass::pretranslatemessage(msg* pmsg) { if (pmsg->message == wm_lbuttondown) { cwnd* pwnd = getfocus(); if (pwnd->getdlgctrlid() == my_edit_ctrl_id) { //do thing } } return __super::pretranslatemessage(pmsg); //<< added }
Comments
Post a Comment