How to Disable Alt F4 Acceletartor Key when i disable CANCEL Button in MFC Dialog Based application.
Printable View
How to Disable Alt F4 Acceletartor Key when i disable CANCEL Button in MFC Dialog Based application.
Find or add the OnSysCommand message handler and add some code similar to this:
<P>
<PRE>
void CJunkDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if (bPreventClose && (nID == SC_CLOSE))
{
return;
}
//... rest of function ...
}
</PRE>
Toggle bPreventClose to be true or false as you enable or disable the Cancel button.
This will also disable the close button. How can only Alt+F4 be disabled?