Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.10.17;
Скачать: CL | DM;

Вниз

Как узнать нажат ли 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 вся ветка

Текущий архив: 2002.10.17;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.016 c
1-56094
AL2002
2002-10-08 21:11
2002.10.17
Задать свойства сразу нескольким контролам?


7-56357
_landy
2002-08-07 09:49
2002.10.17
SysInfo


1-56160
SinnerPro
2002-10-07 12:11
2002.10.17
Вопрос о форме ( окне программы )


3-55953
Natangelina
2002-09-25 10:44
2002.10.17
dateTimePicker


3-55968
Bishop
2002-09-25 11:51
2002.10.17
View