1
0

local_menu.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "main.h"
  2. #include "./local_menu.h"
  3. #include "./wasabi.h"
  4. #include "./resource.h"
  5. #include "./navigation.h"
  6. #include "../gen_ml/ml_ipc_0313.h"
  7. #include "../nu/menuHelpers.h"
  8. #define SUBMENU_NAVIGATIONCONTEXT 0
  9. static HMENU Menu_GetNavigationContext(HMENU baseMenu)
  10. {
  11. HMENU hMenu = GetSubMenu(baseMenu, SUBMENU_NAVIGATIONCONTEXT);
  12. if (NULL == hMenu) return NULL;
  13. hMenu = MenuHelper_DuplcateMenu(hMenu);
  14. if (NULL == hMenu) return NULL;
  15. HNAVITEM hActive = Navigation_GetActive(NULL);
  16. if (NULL != hActive)
  17. {
  18. EnableMenuItem(hMenu, ID_NAVIGATION_OPEN, MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
  19. }
  20. else
  21. {
  22. EnableMenuItem(hMenu, ID_NAVIGATION_OPEN, MF_BYCOMMAND | MF_ENABLED);
  23. SetMenuDefaultItem(hMenu, ID_NAVIGATION_OPEN, FALSE);
  24. }
  25. return hMenu;
  26. }
  27. HMENU Menu_GetMenu(UINT menuKind)
  28. {
  29. HMENU baseMenu = WASABI_API_LOADMENUW(IDR_CONTEXTMENU);
  30. if (NULL == baseMenu)
  31. return NULL;
  32. switch(menuKind)
  33. {
  34. case MENU_NAVIGATIONCONTEXT:
  35. {
  36. HMENU menu = Menu_GetNavigationContext(baseMenu);
  37. if (!GetModuleHandle(L"ml_online.dll"))
  38. {
  39. if (DeleteMenu(menu, ID_PLUGIN_PREFERENCES, MF_BYCOMMAND))
  40. {
  41. DeleteMenu(menu, 2, MF_BYPOSITION);
  42. }
  43. }
  44. return menu;
  45. }
  46. }
  47. return NULL;
  48. }
  49. BOOL Menu_ReleaseMenu(HMENU hMenu, UINT menuKind)
  50. {
  51. if (NULL == hMenu) return FALSE;
  52. switch(menuKind)
  53. {
  54. case MENU_NAVIGATIONCONTEXT:
  55. return DestroyMenu(hMenu);
  56. }
  57. return FALSE;
  58. }