Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I capture the backspace key as a trigger for a button?

If anyone could tell me how to set up a button on a formview document to be
triggered by the user hitting the backspace key, I would greatly appreciate
it.

Thanks,

Nick
0 Kudos
Message 1 of 3
(2,923 Views)
Hi, Nick
there are many way to process backspace key. One of them is using an accelerator (catch backspace pressing and notify client/button). It is possible if U have access to application and draw a notification isn't difficult...

Good luck 🙂
0 Kudos
Message 2 of 3
(2,923 Views)
Hallo Nick,

As Spivot stated, there are many ways to solve this problem, and adding an accelerator for backspace key is one solution.
Another solution is to override the "PreTranslateMessage" function in your FormView derived view and to notify the button about backspace key activity, as bellow:
BOOL CFormViewView::PreTranslateMessage(MSG* pMsg)
{
//IDC_BACKBUTTON - the id of button to be triggered
if ((pMsg->message == WM_KEYUP) && (pMsg->wParam == VK_BACK))
PostMessage(WM_COMMAND,MAKEWPARAM(IDC_BACKBUTTON,BN_CLICKED),NULL);
//finally call the base class implementation
return CFormView::PreTranslateMessage(pMsg);
}

Hope this helps,
Silvius
Silvius Iancu
0 Kudos
Message 3 of 3
(2,923 Views)