Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "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
3-55918
volph777
2002-09-26 19:28
2002.10.17
цветной dxDBgrid


1-56151
Zuvom
2002-10-06 14:30
2002.10.17
Файлы данных


3-55928
Вольный Стрелок
2002-09-23 13:05
2002.10.17
UpdateSQL.DeleteSQL - update failed


14-56327
Lancelot
2002-09-21 01:06
2002.10.17
American Beauty


7-56388
2UT
2002-08-07 12:45
2002.10.17
И снова о СОМ - портах (скорость выше 115200 ???)





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский