??? ?????????? mnemonic ??? 4.0 MFC 4.0 Visual Basic

?????? ????????? ?????? ?????????
???? ???????: 145698 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
?????? Microsoft Visual C++ .NET 2002 Microsoft Visual C++ .NET 2003 ???? ?? ?? ???? ????????? ???????? ??????? ???? ?? ??????? ?? ??? Microsoft .NET Framework ? ????? ????????? ???????? ??? ???????? Microsoft Windows ??????. ????? ????????? ??????? ?? ??? ??????? ??? ??? ????????? ???????? ??? ???????? Visual C++.????? Microsoft Visual C++ 2005 ????? ????????? ???????? ??????? ???? ?? ??????? ?? ??? Microsoft .NET Framework ?????? ????? ????????? ???????? ??? ???????? Microsoft Windows ??????.
????? ???? | ?? ????

?? ??? ??????

???????

?? ???? ???? ???? ???? ?????? ?????? COleControl::OnGetControlInfo ??? ?????? mnemonic ???? ???? OLE ?? ?? ?? 4.0 MFC ? Visual Basic 4.0 OLE ?????? ??????.

?????

4.0 Visual Basic ? 4.0 MFC ???? mnemonic ?????? ?????? ????????? ???? ????? ??????? ???? ?????? ??????.

????

????? ??????? ???? ???? ???? ???? ???? ????????? ??????? ??????? ?????? ?? ????? ?????? ?? 4.0 Visual Basic ? MFC 4.0 OLE ???????.

?????

????? ??? ?????? ??? ???????.

??????? ????

?????? ???? ???? OLE ????? COleControl::OnGetControlInfo ????? ?????? ??????? ?????? ??? ??? ?????? mnemonic ???? ??????. ???? ??????? OnGetControlInfo ???? ????? ????? ?? ????? CONTROLINFO ????? ???? ??? ???? ???? ??? ????? ????. ??? ??????? ??? ?????? ??????? ?????? ??????? ?????? ?????? ??? ?????? mnemonic. ????? ???? ??????? ???? ???? ????? mnemonic ??? ?????, ???? ???????? IOleControl::OnMnemonic ???? ?????? ???????. ???? ??? ???? ??? MFC ??????? ??????? COleControl::OnMnemonic ??????? ???? ???? ????? ???? ?????? ????? ?????? ????.

??????? ?????? ???? ?????? mnemonic Visual Basic 4.0 ? MFC 4.0 OLE ?? ???? ???? ??????? ?????? ????????? ?? ???? ??????? ?? ??????? ?????? ?????? ?? OnGetControlInfo.

??? ????? ????? ????? ????????? ?? ???? ???? ?????? ???? ACCEL. ACCEL ????? ???? ??????? ??????:
   typedef struct tagACCEL
   {
       BYTE   fVirt;
       WORD   key;
       WORD   cmd;
   } ACCEL;
				
??? fVirt ????? ?????? ???????. ???? ?? ???? ??? ????? ?????? ?? ????? ???????:
   Value       Meaning
   ---------------------------------------------------------------------
   FALT        The ALT key must be held down when the accelerator key is
               pressed.

   FCONTROL    The CTRL key must be held down when the accelerator key
               is pressed.

   FNOINVERT   Specifies that no top-level menu item is highlighted when
               the accelerator is used. If this flag is not specified, a
               top-level menu item will be highlighted, if possible,
               when the accelerator is used.

   FSHIFT      The SHIFT key must be held down when the accelerator key
               is pressed.

   FVIRTKEY    The key member specifies a virtual-key code. If this flag
               is not specified, key is assumed to specify an ASCII
               character code.
				
??? ??????? ???? ????? ???????. ???? ?? ???? ??? ????? ??? ??????? ??????? ?? ??? ??? ASCII.

????? ??? cmd ???? ???????. ??? ??? ??? ?????? ?? ?????? ?? ??????? ??????? ??????? wParam ????? WM_COMMAND ?? WM_SYSCOMMAND ??? ????? ??? ??????.

4.0 Visual Basic ????? ????????? ??????? ??????? ???? ?????? ??????? ?????? mnemonic:

  • ??? ?? ???? ????? fVirt ?????? (FVIRTKEY | FALT) ?? (FVIRTKEY | FALT | FSHIFT).
  • ??? ?? ???? ????? ???????? ??????.
  • ?? ??? ?? ???? ????? cmd ????? 0.
????? 4.0 MFC ????????? ??????? ??????? ???? ?????? ??????? ?????? mnemonic:

  • ??? ?? ???? ??? fVirt FALT ?? 0.
  • ??? ?? ???? ????? ??????? ??????.
  • ??? ????? ??? cmd.
????? MFC 4.0 OLE ?????? ?????? ????? 4.0 ?????? ????? ?? ??????? ???? ?????? ??????? ?????? mnemonic ????? ???? ???? ???? UI ?????. ??? ?????? ?????? MFC ????? ???? ???????? ???? ????? ?????? ?? ??? ??? OLE ?????? ???????. ??? ??? ???? ????????? ?????? ??????? IOleInPlaceActiveObject::TranslateAccelerator ????? ???. ?? COleControl ????? ??? ??????? ?? ??????? ?????? PreTranslateMessage ???? ??????. ?? ????? ????? ???? OLE ?? ?????? ????????? ??????? ??????? ?? ???? ???? ????? ???? ???? ?????? UI ????? ??? ?? ?????? ???? ???? OLE PreTranslateMessage ????? ?? ???? ??????? ???????? ?????? ??.

??????: ????? PreTranslateMessage ??? ????? ??? ?? ????? ???? ?????? ?? 5.0 Visual C++ ?? ????? ???? ???? ???????? OnMnemonic ????? ???? ???? ?????? ????? ??? ?????? ?? SendMnemonic ?? COccManager::IsDialogMessage UI.

????? ????? ????????? ???????? ?????? ??????? OnGetControlInfo PreTranslateMessage ? OnMnemonic ?????? ????????? ??????? ??????? ???? ?????? ????? ???? ???? ?? MFC 4.0 OLE ???? ????? ???????? ??? ????? 4.0 Visual Basic.

??? ?????

/* Compile options needed: None
*/ 
#define NUM_ENTRIES 4
void CMnemonicCtrl::OnGetControlInfo(LPCONTROLINFO lpi)
{
  HACCEL hAccel = NULL;
  TCHAR ch = 'm';   // Hard code the mnemonic key to 'm' for this
                    // example.
  ACCEL accKey[NUM_ENTRIES];
  // Accel table entries 0 and 1 are to work with Visual Basic 4.0 as a
  // container. Visual Basic 4.0 has the following requirements for
  // accel table entries for a control's mnemonics:
  // 
  //  (fVirt == FVIRTKEY | FALT) || (fVirt == FVIRTKEY | FALT | FSHIFT)
  //  key must be uppercase
  //  (cmd != 0)
  accKey[0].fVirt = FVIRTKEY | FALT;
  accKey[1].fVirt = FVIRTKEY | FALT | FSHIFT;
  accKey[0].key = accKey[1].key = LOBYTE(VkKeyScan(ch));
  accKey[0].cmd = accKey[1].cmd = 1;
  // Accel table entries 2 and 3 are to work with MFC 4.0 containers.
  // MFC containers have the following requirements for accel table
  // entries for a control's mnemonics:
  // 
  //  (fVirt == FALT) || (fVirt == 0)
  //  key should be lowercase
  //  cmd is ignored
  accKey[2].fVirt = FALT;
  accKey[3].fVirt = 0;
  accKey[2].key = accKey[3].key = ch;
  accKey[2].cmd = accKey[3].cmd = 1;
  // Create the accel table.
  hAccel = CreateAcceleratorTable(accKey, NUM_ENTRIES);
  if (hAccel != NULL)
  {
    // Fill in the CONTROLINFO structure passed in.
    lpi -> hAccel = hAccel;
    lpi -> cAccel = NUM_ENTRIES;
    lpi -> dwFlags = 0;
  }
  else
    COleControl::OnGetControlInfo(lpi);
}
// NO need to override PreTranslateMessage if the control is generated in
// Visual C++ 5.0 or above.
BOOL CMnemonicCtrl::PreTranslateMessage( MSG * pMsg )
{
  // Check for ALT-M key combination.
  if(pMsg->message == WM_SYSKEYDOWN) {
    if((pMsg->wParam == 'm')||(pMsg->wParam == 'M'))
    {
      // Do mnemonic key processing here.
      return TRUE;
    }
  }
  return COleControl::PreTranslateMessage(pMsg);
}
void CMnemonicCtrl::OnMnemonic(LPMSG pMsg)
{
  if ((pMsg->message == WM_SYSKEYDOWN)||
      (pMsg->message == WM_SYSCHAR))
  {
    if ((pMsg->wParam == 'm')||(pMsg->wParam == 'M'))
    {
      // Do mnemonic key processing here.
      return;
    }
  }
  COleControl::OnMnemonic(pMsg);
}
				

???????

???? ???????: 145698 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 5.1
????? ???
  • Microsoft Foundation Class Library 4.2, ????? ?????? ??:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft OLE Control Developer's Kit (CDK)
    • Microsoft Visual C++ 2005 Express Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition
    • Microsoft Visual C++ .NET 2002 Standard Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbinfo kbhowto kbtshoot kbacceleratorkey kbcode kbctrlcreate kbkeyaccel kbprb KB145698 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????145698

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com