2013-03-16 20:08:56 +00:00
|
|
|
/*
|
2006-02-16 23:23:37 +00:00
|
|
|
* WINDOW.C - activate & window internal commands.
|
|
|
|
*
|
|
|
|
* clone from 4nt activate command
|
|
|
|
*
|
2013-06-29 23:50:13 +00:00
|
|
|
* 10 Sep 1999 (Paolo Pantaleo)
|
2006-02-16 23:23:37 +00:00
|
|
|
* started (window command in WINDOW.c)
|
|
|
|
*
|
2013-06-29 23:50:13 +00:00
|
|
|
* 29 Sep 1999 (Paolo Pantaleo)
|
2006-02-16 23:23:37 +00:00
|
|
|
* activate and window in a single file using mainly the same code
|
|
|
|
* (nice size optimization :)
|
|
|
|
*
|
2013-06-30 13:23:30 +00:00
|
|
|
* 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
|
2013-06-29 23:50:13 +00:00
|
|
|
* Remove all hardcoded strings in En.rc
|
2006-02-16 23:23:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
#if defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE)
|
2006-02-16 23:23:37 +00:00
|
|
|
|
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
#define A_MIN 0x01
|
|
|
|
#define A_MAX 0x02
|
|
|
|
#define A_RESTORE 0x04
|
|
|
|
#define A_POS 0x08
|
|
|
|
#define A_SIZE 0x10
|
|
|
|
#define A_CLOSE 0x20
|
2006-02-16 23:23:37 +00:00
|
|
|
|
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
/*
|
|
|
|
* service function to perform actions on windows
|
|
|
|
*
|
|
|
|
* param is a string to parse for options/actions
|
|
|
|
* hWnd is the handle of window on which to perform actions
|
|
|
|
*/
|
2006-02-16 23:23:37 +00:00
|
|
|
static INT ServiceActivate (LPTSTR param, HWND hWnd)
|
|
|
|
{
|
2013-06-29 23:50:13 +00:00
|
|
|
LPTSTR *p = 0, p_tmp;
|
|
|
|
INT argc = 0, i;
|
|
|
|
INT iAction = 0;
|
|
|
|
LPTSTR title = 0;
|
|
|
|
WINDOWPLACEMENT wp;
|
|
|
|
RECT pos;
|
|
|
|
LPTSTR tmp;
|
|
|
|
|
|
|
|
if (*param)
|
|
|
|
p = split(param, &argc, FALSE);
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
p_tmp = p[i];
|
|
|
|
if (*p_tmp == _T('/'))
|
|
|
|
p_tmp++;
|
|
|
|
|
|
|
|
if (_tcsicmp(p_tmp, _T("min")) == 0)
|
|
|
|
{
|
|
|
|
iAction |= A_MIN;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcsicmp(p_tmp, _T("max")) == 0)
|
|
|
|
{
|
|
|
|
iAction |= A_MAX;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcsicmp(p_tmp, _T("restore")) == 0)
|
|
|
|
{
|
|
|
|
iAction |= A_RESTORE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcsicmp(p_tmp, _T("close")) == 0)
|
|
|
|
{
|
|
|
|
iAction |= A_CLOSE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcsnicmp(p_tmp, _T("pos"), 3) == 0)
|
|
|
|
{
|
|
|
|
iAction |= A_POS;
|
|
|
|
tmp = p_tmp+3;
|
|
|
|
if (*tmp == _T('='))
|
|
|
|
tmp++;
|
|
|
|
|
|
|
|
pos.left= _ttoi(tmp);
|
2013-06-30 16:10:54 +00:00
|
|
|
if (!(tmp=_tcschr(tmp, _T(','))))
|
2013-06-29 23:50:13 +00:00
|
|
|
{
|
|
|
|
error_invalid_parameter_format(p[i]);
|
|
|
|
freep(p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos.top = _ttoi (++tmp);
|
2013-06-30 16:10:54 +00:00
|
|
|
if (!(tmp=_tcschr(tmp, _T(','))))
|
2013-06-29 23:50:13 +00:00
|
|
|
{
|
|
|
|
error_invalid_parameter_format(p[i]);
|
|
|
|
freep(p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos.right = _ttoi(++tmp) + pos.left;
|
|
|
|
if (!(tmp = _tcschr(tmp, _T(','))))
|
|
|
|
{
|
|
|
|
error_invalid_parameter_format(p[i]);
|
|
|
|
freep(p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
pos.bottom = _ttoi(++tmp) + pos.top;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcsnicmp(p_tmp, _T("size"), 4)==0)
|
|
|
|
{
|
|
|
|
iAction |=A_SIZE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* none of them=window title */
|
|
|
|
if (title)
|
|
|
|
{
|
|
|
|
error_invalid_parameter_format(p[i]);
|
|
|
|
freep(p);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_tmp[0] == _T('"'))
|
|
|
|
{
|
|
|
|
title = (p_tmp + 1);
|
|
|
|
*_tcschr(p_tmp + 1, _T('"')) = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
title = p_tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (title)
|
|
|
|
SetWindowText(hWnd, title);
|
|
|
|
|
|
|
|
wp.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(hWnd, &wp);
|
|
|
|
|
|
|
|
if (iAction & A_POS)
|
|
|
|
wp.rcNormalPosition = pos;
|
|
|
|
|
|
|
|
if (iAction & A_MIN)
|
|
|
|
wp.showCmd = SW_MINIMIZE;
|
|
|
|
|
|
|
|
if (iAction & A_MAX)
|
|
|
|
wp.showCmd = SW_SHOWMAXIMIZED;
|
|
|
|
|
|
|
|
/* if no actions are specified default is SW_RESTORE */
|
|
|
|
if ((iAction & A_RESTORE) || (!iAction))
|
|
|
|
wp.showCmd = SW_RESTORE;
|
|
|
|
|
|
|
|
if (iAction & A_CLOSE)
|
|
|
|
{
|
|
|
|
FIXME("!!!FIXME: CLOSE Not implemented!!!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
wp.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
SetWindowPlacement(hWnd, &wp);
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
freep(p);
|
|
|
|
|
|
|
|
return 0;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandWindow (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-29 23:50:13 +00:00
|
|
|
HWND hwnd;
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
|
|
|
{
|
2006-02-16 23:23:37 +00:00
|
|
|
ConOutResPaging(TRUE,STRING_WINDOW_HELP1);
|
2013-06-29 23:50:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
hwnd = GetConsoleWindow();
|
|
|
|
Sleep(0);
|
|
|
|
return ServiceActivate(param, hwnd);
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandActivate (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-29 23:50:13 +00:00
|
|
|
HWND hwnd;
|
|
|
|
LPTSTR *arg;
|
|
|
|
INT argc;
|
|
|
|
|
|
|
|
if (_tcsncmp (param, _T("/?"), 2) == 0)
|
|
|
|
{
|
|
|
|
ConOutResPaging(TRUE,STRING_WINDOW_HELP2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-30 16:10:54 +00:00
|
|
|
if (!(*param))
|
2013-06-29 23:50:13 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Split the user input into array */
|
|
|
|
arg = split (param, &argc, FALSE);
|
2013-06-30 16:10:54 +00:00
|
|
|
if (argc < 2)
|
2013-06-29 23:50:13 +00:00
|
|
|
{
|
2013-06-30 16:10:54 +00:00
|
|
|
if (arg != NULL)
|
2013-06-29 23:50:13 +00:00
|
|
|
freep(arg);
|
|
|
|
}
|
|
|
|
hwnd = FindWindow(NULL, arg[0]);
|
|
|
|
if (hwnd == NULL)
|
|
|
|
{
|
2013-06-30 16:10:54 +00:00
|
|
|
if (arg != NULL)
|
2013-06-29 23:50:13 +00:00
|
|
|
freep(arg);
|
|
|
|
ConErrResPuts(STRING_WINDOW_ERROR1);
|
|
|
|
return 1;
|
|
|
|
}
|
2013-06-30 16:10:54 +00:00
|
|
|
if (arg != NULL)
|
2013-06-29 23:50:13 +00:00
|
|
|
freep(arg);
|
|
|
|
|
|
|
|
return ServiceActivate(param, hwnd);
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 23:50:13 +00:00
|
|
|
#endif /* defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) */
|