Button should send BM_SETSTATE message after it has changed its
[wine] / programs / taskmgr / optnmenu.c
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22     
23 /*
24  * options.c
25  *
26  * Menu item handlers for the options menu.
27  */
28
29 #define WIN32_LEAN_AND_MEAN    /* Exclude rarely-used stuff from Windows headers */
30 #include <windows.h>
31 #include <commctrl.h>
32 #include <stdlib.h>
33 #include <malloc.h>
34 #include <memory.h>
35 #include <tchar.h>
36 #include <stdio.h>
37     
38 #include "taskmgr.h"
39
40 #define OPTIONS_MENU_INDEX    1
41
42 void TaskManager_OnOptionsAlwaysOnTop(void)
43 {
44     HMENU    hMenu;
45     HMENU    hOptionsMenu;
46
47     hMenu = GetMenu(hMainWnd);
48     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
49
50     /*
51      * Check or uncheck the always on top menu item
52      * and update main window.
53      */
54     if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
55     {
56         CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
57         TaskManagerSettings.AlwaysOnTop = FALSE;
58         SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
59     }
60     else
61     {
62         CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
63         TaskManagerSettings.AlwaysOnTop = TRUE;
64         SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
65     }
66 }
67
68 void TaskManager_OnOptionsMinimizeOnUse(void)
69 {
70     HMENU    hMenu;
71     HMENU    hOptionsMenu;
72
73     hMenu = GetMenu(hMainWnd);
74     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
75
76     /*
77      * Check or uncheck the minimize on use menu item.
78      */
79     if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
80     {
81         CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
82         TaskManagerSettings.MinimizeOnUse = FALSE;
83     }
84     else
85     {
86         CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
87         TaskManagerSettings.MinimizeOnUse = TRUE;
88     }
89 }
90
91 void TaskManager_OnOptionsHideWhenMinimized(void)
92 {
93     HMENU    hMenu;
94     HMENU    hOptionsMenu;
95
96     hMenu = GetMenu(hMainWnd);
97     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
98
99     /*
100      * Check or uncheck the hide when minimized menu item.
101      */
102     if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
103     {
104         CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
105         TaskManagerSettings.HideWhenMinimized = FALSE;
106     }
107     else
108     {
109         CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
110         TaskManagerSettings.HideWhenMinimized = TRUE;
111     }
112 }
113
114 void TaskManager_OnOptionsShow16BitTasks(void)
115 {
116     HMENU    hMenu;
117     HMENU    hOptionsMenu;
118
119     hMenu = GetMenu(hMainWnd);
120     hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
121
122     /*
123      * FIXME: Currently this is useless because the
124      * current implemetation doesn't list the 16-bit
125      * processes. I believe that would require querying
126      * each ntvdm.exe process for it's children.
127      */
128
129     /*
130      * Check or uncheck the show 16-bit tasks menu item
131      */
132     if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
133     {
134         CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
135         TaskManagerSettings.Show16BitTasks = FALSE;
136     }
137     else
138     {
139         CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
140         TaskManagerSettings.Show16BitTasks = TRUE;
141     }
142
143     /*
144      * Refresh the list of processes.
145      */
146     RefreshProcessPage();
147 }