Форум: "WinAPI";
Текущий архив: 2002.10.17;
Скачать: [xml.tar.bz2];
ВнизКак узнать нажат ли CTRL Найти похожие ветки
← →
NAlexey (2002-09-03 13:33) [0]Здравствуйте. Помогите пожалуйста советом. Проблема в следующем: Пеерехватываю событие OnMessage -
procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_KEYDOWN then
if (Msg.wParam = VK_F1) or (Msg.wParam = VK_F2)then
{Какие то действия}
...
end;
Так вот надо с помощью этой конструкции узнавать нажат ли CTRL? Прочитал совет что надо отлавливать еще и WM_KEYUP. А нельзя ли как нибудь сделать покрасивше?
← →
Ученик (2002-09-03 13:51) [1]function CtrlPressed : Boolean;
begin
Result := (GetKeyState(VK_CONTROL) and $8000) <> 0
end;
← →
NAlexey (2002-09-03 13:59) [2]Спасибо большое! если не трудно разъяснить почему $8000? Если трудно, то необязательно.
← →
Ученик (2002-09-03 14:08) [3]SHORT GetKeyState(
int nVirtKey // virtual-key code
);
Parameters
nVirtKey
Specifies a virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code.
If a non-English keyboard layout is used, virtual keys with values in the range ASCII A through Z and 0 through 9 are used to specify most of the character keys. For example, for the German keyboard layout, the virtual key of value ASCII O (0x4F) refers to the "o" key, whereas VK_OEM_1 refers to the "o with umlaut" key.
Return Values
If the function succeeds, the return value specifies the status of the given virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key"s indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.
← →
s.kaster (2002-09-05 11:09) [4]http://www.sources.ru/delphi_system.shtml#11
Страницы: 1 вся ветка
Форум: "WinAPI";
Текущий архив: 2002.10.17;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.015 c