Форум программистов «Весельчак У»
  *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

  • Рекомендуем проверить настройки временной зоны в вашем профиле (страница "Внешний вид форума", пункт "Часовой пояс:").
  • У нас больше нет рассылок. Если вам приходят письма от наших бывших рассылок mail.ru и subscribe.ru, то знайте, что это не мы рассылаем.
   Начало  
Наши сайты
Помощь Поиск Календарь Почта Войти Регистрация  
 
Страниц: [1]   Вниз
  Печать  
Автор Тема: WM_HOTKEY и RegisterHotKey  (Прочитано 17854 раз)
0 Пользователей и 1 Гость смотрят эту тему.
Axenic
Гость
« : 12-02-2010 06:25 » 

Как их использовать? Можно како-нибудь пример кода?

И самое главное: почему, когда я подключаю библиотеку Hotkey.lib вот так:
Код:
#pragma comment(lib,"Hotkey.lib")
Коспилятор выдает мне такую ошибку:
Цитата
fatal error LNK1104: не удается открыть файл ''Hotkey.lib''
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #1 : 12-02-2010 06:30 » 

а зачем подключать эту библиотеку ?

Код:
The WM_HOTKEY message is posted when the user presses a hot key registered by the RegisterHotKey function. The message is placed at
the top of the message queue associated with the thread that registered the hot key.

Syntax

WM_HOTKEY

    WPARAM wParam
    LPARAM lParam;
   
Parameters

wParam - Specifies the identifier of the hot key that generated the message. If the message was generated by a system-defined hot key,
 this parameter will be one of the following values.

IDHOT_SNAPDESKTOP
The "snap desktop" hot key was pressed.
IDHOT_SNAPWINDOW
The "snap window" hot key was pressed.

lParam - The low-order word specifies the keys that were to be pressed in combination with the key specified by the high-order word to
 generate the WM_HOTKEY message. This word can be one or more of the following values. The high-order word specifies the virtual key
 code of the hot key.

MOD_ALT
Either ALT key was held down.
MOD_CONTROL
Either CTRL key was held down.
MOD_SHIFT
Either SHIFT key was held down.
MOD_WIN
Either WINDOWS key was held down. These keys are labeled with the Microsoft® Windows® logo.

Return Value - No return value.
Remarks - WM_HOTKEY is unrelated to the WM_GETHOTKEY and WM_SETHOTKEY hot keys. The WM_HOTKEY message is sent for generic hot keys while the WM_SETHOTKEY and WM_GETHOTKEY messages relate to window activation hot keys.


Код:
The RegisterHotKey function defines a system-wide hot key.

Syntax

BOOL RegisterHotKey(          HWND hWnd,
    int id,
    UINT fsModifiers,
    UINT vk
);
Parameters

hWnd - [in] Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.

id - [in] Specifies the identifier of the hot key. No other hot key in the calling thread should have the same identifier. An application must specify a value in the range 0x0000 through 0xBFFF. A shared dynamic-link library (DLL) must specify a value in the range 0xC000 through 0xFFFF (the range returned by the GlobalAddAtom function). To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the GlobalAddAtom function to obtain the hot-key identifier.

fsModifiers - [in] Specifies keys that must be pressed in combination with the key specified by the uVirtKey parameter in order to generate the WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values.
MOD_ALT
Either ALT key must be held down.
MOD_CONTROL
Either CTRL key must be held down.
MOD_SHIFT
Either SHIFT key must be held down.
MOD_WIN
Either WINDOWS key was held down. These keys are labeled with the Microsoft® Windows® logo.

vk - [in] Specifies the virtual-key code of the hot key.

Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.


Remarks

When a key is pressed, the system looks for a match against all hot keys. Upon finding a match, the system posts the WM_HOTKEY message to the message queue of the thread that registered the hot key. This message is posted to the beginning of the queue so it is removed by the next iteration of the message loop.

This function cannot associate a hot key with a window created by another thread.

RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key.

If the window identified by the hWnd parameter already registered a hot key with the same identifier as that specified by the id parameter, the new values for the fsModifiers and vk parameters replace the previously specified values for these parameters.

Windows NT4 and Windows 2000/XP: The F12 key is reserved for use by the debugger at all times, so it should not be registered as a hot key. Even when you are not debugging an application, F12 is reserved in case a kernel-mode debugger or a just-in-time debugger is resident.

« Последнее редактирование: 12-02-2010 06:33 от Алексей1153++ » Записан

Axenic
Гость
« Ответ #2 : 12-02-2010 06:37 » 

В Майкрософте пишут:
Цитата
Requirements

OS Versions: Windows CE 2.0 and later.
Header: Winuser.h.
Link Library: Hotkey.lib.
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #3 : 12-02-2010 06:42 » 

а ты пробовал без подключения то ?

не знаю, что в мелкософт написано, а в МСДН

Цитата
Declared in Winuser.h, include Windows.h

если у тебя  MFC , то всё уже включено в stdafx.h , иначе - достаточно

#include "Windows.h"
Записан

Axenic
Гость
« Ответ #4 : 12-02-2010 06:44 » 

Если без этой библиотеки, то при компоновке пишет:
Цитата
1>eve-bot-program.obj : error LNK2001: неразрешенный внешний символ ""extern "C" int __stdcall RegisterHotKey(struct HWND__ *,int,unsigned int,unsigned int)" (?RegisterHotKey@@$$J216YGHPAUHWND__@@HII@Z)"
1>C:\Documents and Settings\Root\Мои документы\Visual Studio 2008\Projects\Project1\eve-bot-program\Release\eve-bot-program.exe : fatal error LNK1120: 1 неразрешенных внешних элементов
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #5 : 12-02-2010 06:46 » new

Axenic, а проект визардом создавал или вручную ? Тип проекта какой ?
Записан

Axenic
Гость
« Ответ #6 : 12-02-2010 06:48 » 

Приложение Windows Form
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #7 : 12-02-2010 06:50 » 

дотнет ? Разделом ошибся, значит Улыбаюсь
Записан

Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #8 : 12-02-2010 06:51 » 

ещё настоятельно не советую хранить проекты по такому пути
Цитата
C:\Documents and Settings\Root\Мои документы\....

в крайнем случае - начать с "d:\..." а не с системного раздела
Записан

Axenic
Гость
« Ответ #9 : 12-02-2010 06:52 » 

А где нужный раздел Улыбаюсь?
Записан
Алексей++
глобальный и пушистый
Глобальный модератор

ru
Offline Offline
Сообщений: 13


« Ответ #10 : 12-02-2010 06:53 » 

сейчас перенесу
Записан

Axenic
Гость
« Ответ #11 : 12-02-2010 07:35 » 

Оказывается надо было подключить библиотеку User32.lib
Записан
Страниц: [1]   Вверх
  Печать  
 

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines