I want to override the normal keypress event Alt+F4 in my application.
I am using borland builder 6.
i wrote a fn for Application->OnMessage = msghandler;
In this handler I am checking for the Key State of the Alt & F4 & then if the key is pressed I am calling some fns. This works fine. But when I press Alt+F4 the function gets called a lot of times if the key is pressed normally. I want my fn to be called only once. Is the way that I have handled correct or should i try to handle this in some other way? Please help!!!
here is my code
msghandler(tagMSG &message, bool &handled)
{
short shRet;
shRet = GetAsyncKeyState(VK_MENU);
bool bVal = (shRet >> 1)&& 1;
short key = GetAsyncKeyState(VK_F4);
bool keyState = (key >> 1)&& 1;
if(bVal == true && keyState == true)
{
handled = true;
// I am calling my fns here which has to be called on press of Alt+F4
}
}