//wparam=MenuObjectHandle //lparam=vKey int MO_ProcessHotKeys(WPARAM wParam,LPARAM lParam) { int objidx;//pos in array PMO_IntMenuItem pimi; int i; int vKey=(int)lParam; if (!isGenMenuInited) return -1; lockmo(); objidx=GetMenuObjbyId((int)wParam); if (objidx==-1){unlockmo();return(FALSE);} for(i=0;i<MenuObjects[objidx].MenuItemsCount;i++) { pimi=&MenuObjects[objidx].MenuItems[i]; if (pimi->mi.hotKey==0) continue; if (HIWORD(pimi->mi.hotKey)!=vKey) continue; if (!(LOWORD(pimi->mi.hotKey)&MOD_ALT)!=!(GetKeyState(VK_MENU)&0x8000)) continue; if (!(LOWORD(pimi->mi.hotKey)&MOD_CONTROL)!=!(GetKeyState(VK_CONTROL)&0x8000)) continue; if (!(LOWORD(pimi->mi.hotKey)&MOD_SHIFT)!=!(GetKeyState(VK_SHIFT)&0x8000)) continue; MO_ProcessCommand((WPARAM)getGlobalId(MenuObjects[objidx].id,pimi->id),(LPARAM)0); unlockmo(); return TRUE; } unlockmo(); return(FALSE); }
//wparam=MenuObjectHandle //lparam=vKey INT_PTR MO_ProcessHotKeys( HANDLE menuHandle, INT_PTR vKey ) { if ( !bIsGenMenuInited) return -1; EnterCriticalSection( &csMenuHook ); int objidx = GetMenuObjbyId( (int)menuHandle ); if ( objidx == -1 ) { LeaveCriticalSection( &csMenuHook ); return FALSE; } for ( PMO_IntMenuItem pimi = g_menus[objidx]->m_items.first; pimi != NULL; pimi = pimi->next ) { if ( pimi->mi.hotKey == 0 ) continue; if ( HIWORD(pimi->mi.hotKey) != vKey) continue; if ( !(LOWORD(pimi->mi.hotKey) & MOD_ALT ) != !( GetKeyState( VK_MENU ) & 0x8000)) continue; if ( !(LOWORD(pimi->mi.hotKey) & MOD_CONTROL ) != !( GetKeyState( VK_CONTROL ) & 0x8000)) continue; if ( !(LOWORD(pimi->mi.hotKey) & MOD_SHIFT ) != !( GetKeyState( VK_SHIFT ) & 0x8000)) continue; MO_ProcessCommand( pimi, 0 ); LeaveCriticalSection( &csMenuHook ); return TRUE; } LeaveCriticalSection( &csMenuHook ); return FALSE; }
int TryProcessDoubleClick( HANDLE hContact ) { int iMenuID = GetMenuObjbyId( (int)hContactMenuObject ); if ( iMenuID != -1 ) { NotifyEventHooks(hPreBuildContactMenuEvent,(WPARAM)hContact,0); PMO_IntMenuItem pimi = ( PMO_IntMenuItem )MO_GetDefaultMenuItem(( WPARAM )g_menus[ iMenuID ]->m_items.first, 0 ); if ( pimi != NULL ) { MO_ProcessCommand( pimi, ( LPARAM )hContact ); return 0; } } return 1; }
INT_PTR MO_ProcessCommandByMenuIdent(WPARAM wParam,LPARAM lParam) { if ( !bIsGenMenuInited ) return -1; EnterCriticalSection( &csMenuHook ); for ( int i=0; i < g_menus.getCount(); i++ ) { PMO_IntMenuItem pimi = MO_RecursiveWalkMenu( g_menus[i]->m_items.first, FindMenuByCommand, ( void* )wParam ); if ( pimi ) { LeaveCriticalSection( &csMenuHook ); return MO_ProcessCommand( pimi, lParam ); } } LeaveCriticalSection( &csMenuHook ); return FALSE; }
//LOWORD(wparam) menuident int MO_ProcessCommandByMenuIdent(WPARAM wParam,LPARAM lParam) { int i,j; if (!isGenMenuInited) return -1; lockmo(); for (i=0;i<MenuObjectsCount;i++) { for (j=0;j<MenuObjects[i].MenuItemsCount;j++) { if (MenuObjects[i].MenuItems[j].id==(int)wParam) { int globid; globid=getGlobalId(MenuObjects[i].id,MenuObjects[i].MenuItems[j].id); unlockmo(); return(MO_ProcessCommand(globid,lParam)); } } } unlockmo(); return(FALSE); }
int MO_ProcessCommandBySubMenuIdent(int menuID, int command, LPARAM lParam) { if ( !bIsGenMenuInited ) return -1; EnterCriticalSection( &csMenuHook ); int objidx = GetMenuObjbyId( menuID ); if ( objidx == -1 ) { LeaveCriticalSection( &csMenuHook ); return -1; } PMO_IntMenuItem pimi = MO_RecursiveWalkMenu( g_menus[objidx]->m_items.first, FindMenuByCommand, ( void* )command ); if ( pimi ) { LeaveCriticalSection( &csMenuHook ); return MO_ProcessCommand( pimi, lParam ); } LeaveCriticalSection( &csMenuHook ); return -1; }
INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam) { WORD cmd = LOWORD(wParam); if (HIWORD(wParam) & MPCF_MAINMENU) { int hst = LOWORD(wParam); if (hst >= ID_STATUS_OFFLINE && hst <= ID_STATUS_OUTTOLUNCH) { int pos = statustopos(hst); if (pos != -1 && hStatusMainMenuHandles != NULL) return MO_ProcessCommand(hStatusMainMenuHandles[pos], lParam); } } if (!(cmd >= CLISTMENUIDMIN && cmd <= CLISTMENUIDMAX)) return 0; // DO NOT process ids outside from clist menu id range v0.7.0.27+ //process old menu sys if (HIWORD(wParam) & MPCF_CONTACTMENU) return MO_ProcessCommandBySubMenuIdent((int)hContactMenuObject, LOWORD(wParam), lParam); //unknown old menu return MO_ProcessCommandByMenuIdent(LOWORD(wParam), lParam); }