1 /*
2  * PROJECT:     ReactOS Task Manager
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Menu item handlers for the options menu.
5  * COPYRIGHT:   Copyright 1999-2001 Brian Palmer <brianp@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 void TaskManager_OnOptionsAlwaysOnTop(void)
11 {
12     HMENU  hMenu;
13     HMENU  hOptionsMenu;
14 
15     hMenu = GetMenu(hMainWnd);
16     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
17 
18     /*
19      * Check or uncheck the always on top menu item
20      * and update main window.
21      */
22     if ((GetWindowLongPtrW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0)
23     {
24         CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
25         TaskManagerSettings.AlwaysOnTop = FALSE;
26         SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
27     }
28     else
29     {
30         CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
31         TaskManagerSettings.AlwaysOnTop = TRUE;
32         SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
33     }
34 }
35 
36 void TaskManager_OnOptionsMinimizeOnUse(void)
37 {
38     HMENU  hMenu;
39     HMENU  hOptionsMenu;
40 
41     hMenu = GetMenu(hMainWnd);
42     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
43 
44     /*
45      * Check or uncheck the minimize on use menu item.
46      */
47     if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
48     {
49         CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
50         TaskManagerSettings.MinimizeOnUse = FALSE;
51     }
52     else
53     {
54         CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
55         TaskManagerSettings.MinimizeOnUse = TRUE;
56     }
57 }
58 
59 void TaskManager_OnOptionsHideWhenMinimized(void)
60 {
61     HMENU  hMenu;
62     HMENU  hOptionsMenu;
63 
64     hMenu = GetMenu(hMainWnd);
65     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
66 
67     /*
68      * Check or uncheck the hide when minimized menu item.
69      */
70     if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
71     {
72         CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
73         TaskManagerSettings.HideWhenMinimized = FALSE;
74     }
75     else
76     {
77         CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
78         TaskManagerSettings.HideWhenMinimized = TRUE;
79     }
80 }
81 
82 void TaskManager_OnOptionsShow16BitTasks(void)
83 {
84     HMENU  hMenu;
85     HMENU  hOptionsMenu;
86 
87     hMenu = GetMenu(hMainWnd);
88     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
89 
90     /*
91      * FIXME: Currently this is useless because the
92      * current implementation doesn't list the 16-bit
93      * processes. I believe that would require querying
94      * each ntvdm.exe process for it's children.
95      */
96 
97     /*
98      * Check or uncheck the show 16-bit tasks menu item
99      */
100     if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
101     {
102         CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
103         TaskManagerSettings.Show16BitTasks = FALSE;
104     }
105     else
106     {
107         CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
108         TaskManagerSettings.Show16BitTasks = TRUE;
109     }
110 
111     /*
112      * Refresh the list of processes.
113      */
114     RefreshProcessPage();
115 }
116