optnmenu.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * ReactOS Task Manager
  3. *
  4. * optnmenu.c
  5. *
  6. * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  21. */
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <windows.h>
  25. #include <commctrl.h>
  26. #include "taskmgr.h"
  27. void TaskManager_OnOptionsAlwaysOnTop(void)
  28. {
  29. HMENU hMenu;
  30. HMENU hOptionsMenu;
  31. hMenu = GetMenu(hMainWnd);
  32. hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
  33. /*
  34. * Check or uncheck the always on top menu item
  35. * and update main window.
  36. */
  37. if ((GetWindowLongW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0)
  38. {
  39. CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
  40. TaskManagerSettings.AlwaysOnTop = FALSE;
  41. SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  42. }
  43. else
  44. {
  45. CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
  46. TaskManagerSettings.AlwaysOnTop = TRUE;
  47. SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
  48. }
  49. }
  50. void TaskManager_OnOptionsMinimizeOnUse(void)
  51. {
  52. HMENU hMenu;
  53. HMENU hOptionsMenu;
  54. hMenu = GetMenu(hMainWnd);
  55. hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
  56. /*
  57. * Check or uncheck the minimize on use menu item.
  58. */
  59. if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
  60. {
  61. CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
  62. TaskManagerSettings.MinimizeOnUse = FALSE;
  63. }
  64. else
  65. {
  66. CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
  67. TaskManagerSettings.MinimizeOnUse = TRUE;
  68. }
  69. }
  70. void TaskManager_OnOptionsHideWhenMinimized(void)
  71. {
  72. HMENU hMenu;
  73. HMENU hOptionsMenu;
  74. hMenu = GetMenu(hMainWnd);
  75. hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
  76. /*
  77. * Check or uncheck the hide when minimized menu item.
  78. */
  79. if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
  80. {
  81. CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
  82. TaskManagerSettings.HideWhenMinimized = FALSE;
  83. }
  84. else
  85. {
  86. CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
  87. TaskManagerSettings.HideWhenMinimized = TRUE;
  88. }
  89. }
  90. void TaskManager_OnOptionsShow16BitTasks(void)
  91. {
  92. HMENU hMenu;
  93. HMENU hOptionsMenu;
  94. hMenu = GetMenu(hMainWnd);
  95. hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
  96. /*
  97. * FIXME: Currently this is useless because the
  98. * current implementation doesn't list the 16-bit
  99. * processes. I believe that would require querying
  100. * each ntvdm.exe process for its children.
  101. */
  102. /*
  103. * Check or uncheck the show 16-bit tasks menu item
  104. */
  105. if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
  106. {
  107. CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
  108. TaskManagerSettings.Show16BitTasks = FALSE;
  109. }
  110. else
  111. {
  112. CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
  113. TaskManagerSettings.Show16BitTasks = TRUE;
  114. }
  115. /*
  116. * Refresh the list of processes.
  117. */
  118. RefreshProcessPage();
  119. }