Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > CWnd::OnKeyDown


Автор: gepard 12.8.2004, 07:19
Код

CWnd::OnKeyDown(unsigned int, unsigned int, unsigned int)

Что означает второй параметр, передаваемый в эту функцию?
В MSDN'е написано:
Цитата

Specifies the repeat count, that is, the number of times the keystroke is repeated as a result of the user holding down the key.

Он у меня всегда равен 1.

Автор: mr.DUDA 12.8.2004, 09:03
Вчитайся в MSDN внимательней - найдёшь ответы на все свои вопросы biggrin.gif
Цитата
The framework calls this member function when a nonsystem key is pressed.

afx_msg void OnKeyDown(
  UINT nChar,
  UINT nRepCnt,
  UINT nFlags
);


Parameters
nChar
Specifies the virtual key code of the given key. For a list of of standard virtual key codes, see Winuser.h
nRepCnt
Repeat count (the number of times the keystroke is repeated as a result of the user holding down the key).
nFlags
Specifies the scan code, key-transition code, previous key state, and context code, as shown in the following list:

Value Description
0–7 Scan code (OEM-dependent value).
8 Extended key, such as a function key or a key on the numeric keypad (1 if it is an extended key).
9–10 Not used.
11–12 Used internally by Windows.
13 Context code (1 if the ALT key is held down while the key is pressed; otherwise 0).
14 Previous key state (1 if the key is down before the call, 0 if the key is up).
15 Transition state (1 if the key is being released, 0 if the key is being pressed).

For a WM_KEYDOWN message, the key-transition bit (bit 15) is 0 and the context-code bit (bit 13) is 0.


Кстати, как по параметрам, переданным в OnKeyDown, определить ASCII-код нажатой клавиши (а не виртуальный код как в nChar) - такая тема есть в FAQ.
Добавлено @ 09:06
З.Ы. фраза означает "определяет количество раз, которые повторяется нажатие клавиши в то время как она удерживается", т.е. кол-во символов при повторе.

Автор: gepard 12.8.2004, 12:17
Я и так час вчитывался в этот MSDN.
Кажется я понял.
Хотя не уверен. Ночью проверю.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)