Click to See Complete Forum and Search --> : Alt key
Don Janik
May 20th, 1999, 08:34 PM
In my app when the user presses the alt key then releases it my custom cursor changes to an arrow and the file pull down menu is waiting for input. If the user again presses the alt key then my apps custom cursor is restored. Other apps (like Photoshop) behave differently. The alt key can be pressed repeatedly with nothing happening. If alt "F" are pressed then you get the file menu. How can I do this?? I have an OnKeyDown handler in my view class but alt key presses neve go there.
Saeed R
May 20th, 1999, 09:23 PM
&File on the menu means ALT+F means =click on File
E&xit is another example..
Hope this has cleared up the problem.
Don Janik
May 20th, 1999, 11:21 PM
I understand about the &File on the menu, mine works fine. Here is an example of what I am talking about. I am in internet explorer typing into a test box. When I put the mouse arrow in the text box it changes to an I beam cursor. However while the I beam cursor is up if you press the alt key the I beam cursor changes to an arrow. When you press the alt key a second time the cursor will return to an I beam. Apps like Adobe's Photoshop somehow trap the alt key and prevent the system from displaying the arrow cursor. How can I do this also??
Saeed R
May 23rd, 1999, 04:21 PM
here is an exmaple in a treectrl
void CServiceTreeVw::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CTreeCtrlEx& m_treeCtrl = (CTreeCtrlEx &) GetTreeCtrl();
m_tSel = m_treeCtrl.GetSelectedItem();
if ( GetAsyncKeyState(VK_ALT) < 0 && nChar == VK_F)
{
//AfxMessageBox("ALT+ F");
return;
}
...etc
Dan Haddix
May 23rd, 1999, 06:25 PM
Actually the Alt key is a system key so you will need to overload the OnSysKeyDown function in your view class to catch it. However OnSysKeyDown is not supported by class wizard so you will need to add it by hand like this.
1) Add afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); to your class just before the call to DECLARE_MESSAGE_MAP()
2) Add ON_WM_SYSKEYDOWN() between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP
3) Impliment the function like this
void CYourView::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar != 18)
CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}
This should be all you need to get it working like you want.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.