Context Menu on Windows95 designed keyboard
Sergey S. Zyablitskiy -- Sergey@Redcom.Ru
Friday, November 01, 1996
Environment: VC++ 4.1, Win 95
I implement context menu like this:
void CClientsView::OnContextMenu(CWnd* pWnd, CPoint point) 
{  // make sure window is active
   GetParentFrame()->ActivateFrame();
   int nItem = GetSelectedItem();
   if (nItem != -1)
   {  CMenu menu;
      if (menu.LoadMenu(ID_POPUP_MENU))
      {  CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL);
         pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,
            point.x,point.y,AfxGetMainWnd());
      }
   }
}
It works, but when I press "context menu" key on my keyboard, which is
Windows95 designed, menu appears at top left corner of the screen.
How to obtain an information about how menu was activated: by pressing a
key or by clicking right mouse button?
With best wishes, Sergey S. Zyablitskiy.
Mike Blaszczak -- mikeblas@nwlink.com
Sunday, November 03, 1996
[Mini-digest: 3 responses]
At 16:39 11/1/96 +1000, "Sergey S. Zyablitskiy"  wrote:
>Environment: VC++ 4.1, Win 95
>I implement context menu like this:
> [...]
>It works, but when I press "context menu" key on my keyboard, which is
>Windows95 designed, menu appears at top left corner of the screen.
>How to obtain an information about how menu was activated: by pressing a
>key or by clicking right mouse button?
If the keyboard key is pressed, the point parameter is (-1, -1).
.B ekiM
http://www.nwlink.com/~mikeblas/
I'm afraid I've become some sort of speed freak.
These words are my own. I do not speak on behalf of Microsoft.
-----From: "Quang Ngo" 
Try this:
void CClientsView::OnContextMenu(CWnd* pWnd, CPoint point) 
	{
	if (GetAsyncKeyState(VK_RBUTTON) < 0)
		TRACE0("It was activated by the left button\n");
	else
		TRACE0("It was activated by keyboard (F10)\n");
	....
	}
        _,'|             _.-''``-...___..--';)  
        /_ \'.      __..-' ,      ,--...--'''   Quang Ngo
       <\    .`--'''       `     /'             jaguar@gaianet.net
        `-';'               ;   ; ;             
  __...--''     ___...--_..'  .;.'              
 (,__....----'''       (,..--''                
-----From: Jim Barry 
When the menu key is pressed, the OnContextMenu handler receives (-1, =
-1) in the 'point' argument. I usually just test whether or not the =
point lies within the window's client area.
- Jim
 
  
   
     
  | Вернуться в корень Архива
  |