WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  C / C++ / Visual C++
  Сообщение не ативному окну

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Сообщение не ативному окну
NULL опубликован 17-01-2002 13:20 MSK   Click Here to See the Profile for NULL   Click Here to Email NULL  
Помогите!

Прога валяется в трее. Ставлю хук на нажатие клавиш. По определенной кнопке прога должна выскочить из него. Проблема в том, как отловить сообщение моему не активному окну?

ADK опубликован 17-01-2002 13:31 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Ты локальный хук ставил что ли? Или, что того хуже, писал DLL? А RegisterHotKey не пробовал юзать?
NULL опубликован 17-01-2002 13:50 MSK     Click Here to See the Profile for NULL  Click Here to Email NULL     
Ну ессно DLL делал. Я впервые с этим столкнулся, начитался хелпов ну и ...
А вааще как лучше это сделать
ADK опубликован 18-01-2002 05:47 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Я же сказал, смотри RegisterHotKey!
NULL опубликован 18-01-2002 12:01 MSK     Click Here to See the Profile for NULL  Click Here to Email NULL     
Посмотрел, и ни фига не понял.
Откель взять параметы для ее и как окно отловит WM
purpe опубликован 18-01-2002 12:24 MSK     Click Here to See the Profile for purpe  Click Here to Email purpe     
из моей проги на чистом WinAPI:

//Регистрируем ALT-E, чтобы при нажатии этой комбинации прога всплывала из любого состояния :)

int vk = 0x45; // клавиша "Е" латинская
RegisterHotKey(hWnd,1000+(MOD_ALT*0x100)+vk,MOD_ALT,vk); // регистрируем ALT-E как горячую клавишу


//а вот так горячая клавиша удаляется:

UnregisterHotKey(hWnd,1000+(MOD_ALT*0x100)+vk);


а вот так получается сообщение от горячей клавиши:

LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_HOTKEY:
...
// здесь делаем то, что нам нужно
...
break;
}
return 0;
}

ADK опубликован 18-01-2002 12:25 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Всё проще пареной репы.

BOOL RegisterHotKey(
HWND hWnd, // window to receive hot-key notification
int id, // identifier of hot key
UINT fsModifiers, // key-modifier flags
UINT vk // virtual-key code
);

Parameters
hWnd
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
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 theGlobalAddAtom 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
Specifies keys that must be pressed in combination with the key specified by the nVirtKey parameter in order to generate the WM_HOTKEY message. The fsModifiers parameter can be a combination of the following values. Value Meaning
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
Specifies the virtual-key code of the hot key.

Id придумай сам. Пусть это будет порядковый номер клавиши, так проще. Остальное - код клавиши ('F' или VK_F10, например) и модификаторы (с Alt и т.д.).

Ну вот, потом сделай обработку WM_HOTKEY (вручную):

ON_MESSAGE(WM_HOTKEY, OnHotKeys)

//////////////////////////////

LRESULT CLCDlg::OnHotKeys(WPARAM wParam, LPARAM)
{
int idHotKey = (int) wParam;

switch(idHotKey)
{
case 0: // id = 0
{
// do what you want break;
}

case 1: // id = 1
{
break;
}
return TRUE;
}

ADK опубликован 18-01-2002 12:28 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
2Purpe: в одно время набивали, я не видел ;-))
purpe опубликован 18-01-2002 12:29 MSK     Click Here to See the Profile for purpe  Click Here to Email purpe     
ну так у мине на API а у тя на MFC, вот пусть и выбирает, что ему нужнее :)
NULL опубликован 18-01-2002 12:48 MSK     Click Here to See the Profile for NULL  Click Here to Email NULL     
Вообще-то я на Билдере, на апи что-то больно нравится. Спасибо за советы.Если бы кусок на Билдере - ну это МНОГО ПИВА
purpe опубликован 18-01-2002 13:18 MSK     Click Here to See the Profile for purpe  Click Here to Email purpe     
можно и всю прогу за тебя наваять!
но только вместо пива прийдётся зелёненькими бумажками раскошелиться :)
NULL опубликован 18-01-2002 13:31 MSK     Click Here to See the Profile for NULL  Click Here to Email NULL     
Оно было бы классно. А распространял бы сам, мне сам процесс катит Ж%-))
purpe опубликован 18-01-2002 13:47 MSK     Click Here to See the Profile for purpe  Click Here to Email purpe     
процесс распространения или процесс написания ?
NULL опубликован 18-01-2002 14:45 MSK     Click Here to See the Profile for NULL  Click Here to Email NULL     
Написания. Это для души, я снабжением в фирме занимаюсь

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.