ReactOS 0.4.15-dev-8339-g4028de8
window.c
Go to the documentation of this file.
1/*
2 * WINDOW.C - activate & window internal commands.
3 *
4 * clone from 4nt activate command
5 *
6 * 10 Sep 1999 (Paolo Pantaleo)
7 * started (window command in WINDOW.c)
8 *
9 * 29 Sep 1999 (Paolo Pantaleo)
10 * activate and window in a single file using mainly the same code
11 * (nice size optimization :)
12 *
13 * 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
14 * Remove all hardcoded strings in En.rc
15 */
16
17
18#include "precomp.h"
19
20#if defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE)
21
22
23#define A_MIN 0x01
24#define A_MAX 0x02
25#define A_RESTORE 0x04
26#define A_POS 0x08
27#define A_SIZE 0x10
28#define A_CLOSE 0x20
29
30
31/*
32 * service function to perform actions on windows
33 *
34 * param is a string to parse for options/actions
35 * hWnd is the handle of window on which to perform actions
36 */
37static INT ServiceActivate (LPTSTR param, HWND hWnd)
38{
39 LPTSTR *p = 0, p_tmp;
40 INT argc = 0, i;
41 INT iAction = 0;
42 LPTSTR title = 0;
44 RECT pos;
45 LPTSTR tmp;
46
47 if (*param)
48 p = split(param, &argc, FALSE);
49
50 for (i = 0; i < argc; i++)
51 {
52 p_tmp = p[i];
53 if (*p_tmp == _T('/'))
54 p_tmp++;
55
56 if (_tcsicmp(p_tmp, _T("min")) == 0)
57 {
58 iAction |= A_MIN;
59 continue;
60 }
61
62 if (_tcsicmp(p_tmp, _T("max")) == 0)
63 {
64 iAction |= A_MAX;
65 continue;
66 }
67
68 if (_tcsicmp(p_tmp, _T("restore")) == 0)
69 {
70 iAction |= A_RESTORE;
71 continue;
72 }
73
74 if (_tcsicmp(p_tmp, _T("close")) == 0)
75 {
76 iAction |= A_CLOSE;
77 continue;
78 }
79
80 if (_tcsnicmp(p_tmp, _T("pos"), 3) == 0)
81 {
82 iAction |= A_POS;
83 tmp = p_tmp+3;
84 if (*tmp == _T('='))
85 tmp++;
86
87 pos.left= _ttoi(tmp);
88 if (!(tmp=_tcschr(tmp, _T(','))))
89 {
91 freep(p);
92 return 1;
93 }
94
95 pos.top = _ttoi (++tmp);
96 if (!(tmp=_tcschr(tmp, _T(','))))
97 {
99 freep(p);
100 return 1;
101 }
102
103 pos.right = _ttoi(++tmp) + pos.left;
104 if (!(tmp = _tcschr(tmp, _T(','))))
105 {
107 freep(p);
108 return 1;
109 }
110 pos.bottom = _ttoi(++tmp) + pos.top;
111 continue;
112 }
113
114 if (_tcsnicmp(p_tmp, _T("size"), 4)==0)
115 {
116 iAction |=A_SIZE;
117 continue;
118 }
119
120 /* none of them=window title */
121 if (title)
122 {
124 freep(p);
125 return 1;
126 }
127
128 if (p_tmp[0] == _T('"'))
129 {
130 title = (p_tmp + 1);
131 *_tcschr(p_tmp + 1, _T('"')) = 0;
132 continue;
133 }
134 title = p_tmp;
135 }
136
137 if (title)
139
140 wp.length = sizeof(WINDOWPLACEMENT);
142
143 if (iAction & A_POS)
145
146 if (iAction & A_MIN)
147 wp.showCmd = SW_MINIMIZE;
148
149 if (iAction & A_MAX)
151
152 /* if no actions are specified default is SW_RESTORE */
153 if ((iAction & A_RESTORE) || (!iAction))
154 wp.showCmd = SW_RESTORE;
155
156 if (iAction & A_CLOSE)
157 {
158 FIXME("!!!FIXME: CLOSE Not implemented!!!\n");
159 }
160
161 wp.length = sizeof(WINDOWPLACEMENT);
163
164 if (p)
165 freep(p);
166
167 return 0;
168}
169
170
171
172
174{
175 HWND hwnd;
176
177 if (_tcsncmp (param, _T("/?"), 2) == 0)
178 {
180 return 0;
181 }
182
184 Sleep(0);
185 return ServiceActivate(param, hwnd);
186}
187
188
190{
191 HWND hwnd;
192 LPTSTR *arg;
193 INT argc;
194
195 if (_tcsncmp (param, _T("/?"), 2) == 0)
196 {
198 return 0;
199 }
200
201 if (!(*param))
202 return 1;
203
204 /* Split the user input into array */
205 arg = split (param, &argc, FALSE);
206 if (argc < 2)
207 {
208 if (arg != NULL)
209 freep(arg);
210 }
211 hwnd = FindWindow(NULL, arg[0]);
212 if (hwnd == NULL)
213 {
214 if (arg != NULL)
215 freep(arg);
217 return 1;
218 }
219 if (arg != NULL)
220 freep(arg);
221
222 return ServiceActivate(param, hwnd);
223}
224
225#endif /* defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) */
static int argc
Definition: ServiceArgs.c:12
HWND hWnd
Definition: settings.c:17
INT CommandActivate(LPTSTR)
INT CommandWindow(LPTSTR)
VOID error_invalid_parameter_format(PCTSTR s)
Definition: error.c:145
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
#define ConErrResPuts(uID)
Definition: console.h:38
#define FIXME(fmt,...)
Definition: precomp.h:53
#define STRING_WINDOW_HELP1
Definition: resource.h:207
#define STRING_WINDOW_ERROR
Definition: resource.h:66
#define STRING_WINDOW_HELP2
Definition: resource.h:208
static VOID freep(LPSTR *p)
Definition: cmdcons.c:98
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
Definition: console.c:2729
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _tcsncmp
Definition: tchar.h:1428
#define _tcschr
Definition: tchar.h:1406
static char title[]
Definition: ps.c:92
RECT rcNormalPosition
Definition: winuser.h:3295
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
void * arg
Definition: msvc.h:10
#define SW_SHOWMAXIMIZED
Definition: winuser.h:773
#define FindWindow
Definition: winuser.h:5786
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define SW_MINIMIZE
Definition: winuser.h:776
#define SW_RESTORE
Definition: winuser.h:779
#define SetWindowText
Definition: winuser.h:5866
struct _WINDOWPLACEMENT WINDOWPLACEMENT
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)
#define _ttoi
Definition: xmlstorage.h:195
#define _tcsnicmp
Definition: xmlstorage.h:207
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcsicmp
Definition: xmlstorage.h:205