15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OnKeyDown() kills accelerators

Isaac Katzenelson -- isaac_k@goldnet.net.il
Thursday, November 07, 1996

[Mini-digest: 2 responses]

George Grant wrote:
> 
> Environment: VC++4.0, Win95
> 
> I really hope someone can help... This one's got me stumped... I've implemented my own grid view, and I'm having a problem with key events.
> 
> I've implemented OnChar() to handle WM_CHAR messages (such as when keys are typed for entry into a cell) and WM_KEYDOWN messages (for when the arrow keys are used.)
> 
> I had to do a WM_KEYDOWN handler because my WM_CHAR handler wasn't getting called for the arrow keys. Now when I try to use "Alt+__" combinations for menu commands, they don't work (at least when the mouse is over my grid view.) My KEYDOWN handler is getting called, but I don't know what in MFC to call to pass the keydown to the menu!
> 
> The MFC docs seem even more obtuse on this than usual, or maybe I'm just an idiot; probably the latter.
> 
> -George

Hi George,
Try using WM_SYSCHAR.
Isaac.
-----From: Randy Taylor 

At 06:43 PM 11/4/96 -0800, you wrote:

[snip]
>
>My KEYDOWN handler is getting called, but I don't know what in MFC to call
to pass the keydown to the menu!
>

uh, what menu? How is the issue of key events related to menus in your
application?

randy_taylor@ebt.com




Mike Klimentiev -- mikek@rzs.com
Saturday, November 09, 1996

>----------
>From: 	George Grant[SMTP:doubleg@ix.netcom.com]
>Sent: 	Monday, November 04, 1996 6:43 PM
>To: 	'mfc-l@netcom.com'
>Subject: 	OnKeyDown() kills accelerators
>
>Environment: VC++4.0, Win95
>
>I really hope someone can help... This one's got me stumped... I've
>implemented my own grid view, and I'm having a problem with key events.
>
>I've implemented OnChar() to handle WM_CHAR messages (such as when keys
>are typed for entry into a cell) and WM_KEYDOWN messages (for when the
>arrow keys are used.)
>
>I had to do a WM_KEYDOWN handler because my WM_CHAR handler wasn't
>getting called for the arrow keys. Now when I try to use "Alt+__"
>combinations for menu commands, they don't work (at least when the
>mouse is over my grid view.) My KEYDOWN handler is getting called, but
>I don't know what in MFC to call to pass the keydown to the menu!
>
>The MFC docs seem even more obtuse on this than usual, or maybe I'm
>just an idiot; probably the latter.
>
>-George

Do you call base class implementation of OnChar()? Sometimes people
forget to do it. -Mike





George Grant -- doubleg@ix.netcom.com
Sunday, November 10, 1996

Environment: VC++4.0, Win95

That's the thing; I DID call CScrollView::OnChar() and =
CScrollView::OnKeyDown(). Those are the two I've overridden in =
CDiskView, which is my class (it's derived from CScrollView).

Does anybody have any more ideas? This has me completely baffled; I =
haven't overridden any more messages that have anything to do with =
keystrokes! Is there something more I need to do?

----------
From: 	Mike Klimentiev[SMTP:mikek@rzs.com]
Sent: 	Saturday, November 09, 1996 5:56 PM
To: 	'mfc-l@netcom.com'
Subject: 	RE: OnKeyDown() kills accelerators
...

Do you call base class implementation of OnChar()? Sometimes people
forget to do it. -Mike




GoroKhM1 -- gorokhm1@SMTP.ATG-NET.COM
Monday, November 11, 1996

Hi Mike,

The following may help you or give an idea:

  Q117500 Using Accelerators with an MFC Modeless Dialog Box
  Q100770 Accelerator Keys When Modal Dialog Box Main Window

Add a method to process accelerators _before_ standard routing:

BOOL CMyApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
  CMyFrame* pMainFrame = (CMyFrame*)AfxGetMainWnd();
  if (pMainFrame)
  {
    HACCEL hAccel = pMainFrame->m_hAccelTable;
    if (hAccel && ::TranslateAccelerator(pMainFrame->m_hWnd, hAccel, lpMsg))
      return TRUE; // key processed
  }

  return CWinApp::ProcessMessageFilter(code, lpMsg);
} // CMyApp::ProcessMessageFilter()


MarkG@usa.net






| Вернуться в корень Архива |