2003-08-29 09:29:11 +00:00
|
|
|
/* $Id: misc.c,v 1.15 2003/08/29 09:29:11 gvg Exp $
|
2003-05-26 18:52:37 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: Misc User funcs
|
|
|
|
* FILE: subsys/win32k/ntuser/misc.c
|
|
|
|
* PROGRAMER: Ge van Geldorp (ge@gse.nl)
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 2003/05/22 Created
|
|
|
|
*/
|
|
|
|
#include <ddk/ntddk.h>
|
2003-08-24 23:52:29 +00:00
|
|
|
#include <ddk/ntddmou.h>
|
2003-05-26 18:52:37 +00:00
|
|
|
#include <win32k/win32k.h>
|
2003-08-24 23:52:29 +00:00
|
|
|
#include <win32k/dc.h>
|
2003-05-26 18:52:37 +00:00
|
|
|
#include <include/error.h>
|
|
|
|
#include <include/window.h>
|
|
|
|
#include <include/painting.h>
|
2003-08-17 09:17:04 +00:00
|
|
|
#include <include/dce.h>
|
2003-08-24 23:52:29 +00:00
|
|
|
#include <include/mouse.h>
|
2003-08-24 18:52:18 +00:00
|
|
|
#include <include/winsta.h>
|
2003-05-26 18:52:37 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
|
2003-08-28 18:04:59 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2003-08-06 11:32:17 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
NtUserCallNoParam(
|
|
|
|
DWORD Routine)
|
|
|
|
{
|
2003-08-28 18:04:59 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
DWORD Result = 0;
|
|
|
|
PWINSTATION_OBJECT WinStaObject;
|
|
|
|
|
2003-08-06 11:32:17 +00:00
|
|
|
switch(Routine)
|
|
|
|
{
|
2003-08-28 18:04:59 +00:00
|
|
|
case NOPARAM_ROUTINE_GETDOUBLECLICKTIME:
|
|
|
|
Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
|
|
|
|
KernelMode,
|
|
|
|
0,
|
|
|
|
&WinStaObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return (DWORD)FALSE;
|
|
|
|
|
|
|
|
Result = WinStaObject->SystemCursor.DblClickSpeed;
|
|
|
|
|
|
|
|
ObDereferenceObject(WinStaObject);
|
|
|
|
return Result;
|
2003-08-06 11:32:17 +00:00
|
|
|
}
|
|
|
|
DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam()\n", Routine);
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 18:04:59 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2003-08-06 11:32:17 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
NtUserCallOneParam(
|
|
|
|
DWORD Param,
|
|
|
|
DWORD Routine)
|
|
|
|
{
|
2003-08-28 14:22:05 +00:00
|
|
|
NTSTATUS Status;
|
2003-08-06 11:32:17 +00:00
|
|
|
DWORD Result = 0;
|
2003-08-28 14:22:05 +00:00
|
|
|
PWINSTATION_OBJECT WinStaObject;
|
2003-08-06 11:32:17 +00:00
|
|
|
PWINDOW_OBJECT WindowObject;
|
2003-08-28 14:22:05 +00:00
|
|
|
|
2003-08-06 11:32:17 +00:00
|
|
|
switch(Routine)
|
|
|
|
{
|
|
|
|
case ONEPARAM_ROUTINE_GETMENU:
|
2003-08-19 11:48:50 +00:00
|
|
|
WindowObject = IntGetWindowObject((HWND)Param);
|
2003-08-06 11:32:17 +00:00
|
|
|
if(!WindowObject)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-08-18 00:11:17 +00:00
|
|
|
|
2003-08-11 21:10:49 +00:00
|
|
|
Result = (DWORD)WindowObject->Menu;
|
2003-08-18 00:11:17 +00:00
|
|
|
|
2003-08-19 11:48:50 +00:00
|
|
|
IntReleaseWindowObject(WindowObject);
|
2003-08-06 11:32:17 +00:00
|
|
|
return Result;
|
2003-08-06 13:17:44 +00:00
|
|
|
|
2003-08-06 11:32:17 +00:00
|
|
|
case ONEPARAM_ROUTINE_ISWINDOWUNICODE:
|
2003-08-19 11:48:50 +00:00
|
|
|
WindowObject = IntGetWindowObject((HWND)Param);
|
2003-08-06 11:32:17 +00:00
|
|
|
if(!WindowObject)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
Result = WindowObject->Unicode;
|
2003-08-19 11:48:50 +00:00
|
|
|
IntReleaseWindowObject(WindowObject);
|
2003-08-06 11:32:17 +00:00
|
|
|
return Result;
|
2003-08-17 09:17:04 +00:00
|
|
|
|
|
|
|
case ONEPARAM_ROUTINE_WINDOWFROMDC:
|
2003-08-19 11:48:50 +00:00
|
|
|
return (DWORD)IntWindowFromDC((HDC)Param);
|
2003-08-18 00:11:17 +00:00
|
|
|
|
|
|
|
case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID:
|
2003-08-19 11:48:50 +00:00
|
|
|
WindowObject = IntGetWindowObject((HWND)Param);
|
2003-08-18 00:11:17 +00:00
|
|
|
if(!WindowObject)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result = WindowObject->ContextHelpId;
|
|
|
|
|
2003-08-19 11:48:50 +00:00
|
|
|
IntReleaseWindowObject(WindowObject);
|
2003-08-18 00:11:17 +00:00
|
|
|
return Result;
|
2003-08-28 14:22:05 +00:00
|
|
|
case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON:
|
|
|
|
Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
|
|
|
|
KernelMode,
|
|
|
|
0,
|
|
|
|
&WinStaObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return (DWORD)FALSE;
|
|
|
|
|
|
|
|
Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param);
|
|
|
|
|
|
|
|
ObDereferenceObject(WinStaObject);
|
|
|
|
return Result;
|
2003-08-06 11:32:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param=0x%x\n",
|
|
|
|
Routine, Param);
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 18:04:59 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2003-05-26 18:52:37 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
NtUserCallTwoParam(
|
|
|
|
DWORD Param1,
|
|
|
|
DWORD Param2,
|
|
|
|
DWORD Routine)
|
|
|
|
{
|
2003-08-24 18:52:18 +00:00
|
|
|
NTSTATUS Status;
|
2003-08-18 00:11:17 +00:00
|
|
|
PWINDOW_OBJECT WindowObject;
|
2003-08-24 23:52:29 +00:00
|
|
|
PSYSTEM_CURSORINFO CurInfo;
|
2003-08-24 18:52:18 +00:00
|
|
|
PWINSTATION_OBJECT WinStaObject;
|
|
|
|
PPOINT Pos;
|
|
|
|
|
2003-05-26 18:52:37 +00:00
|
|
|
switch(Routine)
|
2003-08-06 11:32:17 +00:00
|
|
|
{
|
|
|
|
case TWOPARAM_ROUTINE_ENABLEWINDOW:
|
|
|
|
UNIMPLEMENTED
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_UNKNOWN:
|
|
|
|
UNIMPLEMENTED
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS:
|
|
|
|
UNIMPLEMENTED
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW:
|
|
|
|
UNIMPLEMENTED
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_VALIDATERGN:
|
|
|
|
return (DWORD)NtUserValidateRgn((HWND) Param1, (HRGN) Param2);
|
2003-08-18 00:11:17 +00:00
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID:
|
2003-08-19 11:48:50 +00:00
|
|
|
WindowObject = IntGetWindowObject((HWND)Param1);
|
2003-08-18 00:11:17 +00:00
|
|
|
if(!WindowObject)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
2003-08-21 16:04:26 +00:00
|
|
|
return (DWORD)FALSE;
|
2003-08-18 00:11:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowObject->ContextHelpId = Param2;
|
|
|
|
|
2003-08-19 11:48:50 +00:00
|
|
|
IntReleaseWindowObject(WindowObject);
|
2003-08-21 16:04:26 +00:00
|
|
|
return (DWORD)TRUE;
|
2003-08-24 18:52:18 +00:00
|
|
|
|
|
|
|
case TWOPARAM_ROUTINE_CURSORPOSITION:
|
|
|
|
if(!Param1)
|
|
|
|
return (DWORD)FALSE;
|
|
|
|
Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
|
|
|
|
KernelMode,
|
|
|
|
0,
|
|
|
|
&WinStaObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return (DWORD)FALSE;
|
|
|
|
|
|
|
|
Pos = (PPOINT)Param1;
|
|
|
|
|
|
|
|
if(Param2)
|
|
|
|
{
|
|
|
|
/* set cursor position */
|
2003-08-24 23:52:29 +00:00
|
|
|
|
|
|
|
CurInfo = &WinStaObject->SystemCursor;
|
2003-08-24 18:52:18 +00:00
|
|
|
/* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
|
|
|
|
|
2003-08-25 00:28:23 +00:00
|
|
|
//CheckClipCursor(&Pos->x, &Pos->y, CurInfo);
|
2003-08-24 23:52:29 +00:00
|
|
|
if((Pos->x != CurInfo->x) || (Pos->y != CurInfo->y))
|
|
|
|
{
|
|
|
|
MouseMoveCursor(Pos->x, Pos->y);
|
|
|
|
}
|
|
|
|
|
2003-08-24 18:52:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* get cursor position */
|
|
|
|
/* FIXME - check if process has WINSTA_READATTRIBUTES */
|
|
|
|
Pos->x = WinStaObject->SystemCursor.x;
|
|
|
|
Pos->y = WinStaObject->SystemCursor.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObDereferenceObject(WinStaObject);
|
|
|
|
|
|
|
|
return (DWORD)TRUE;
|
2003-08-06 11:32:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam()\n Param1=0x%x Parm2=0x%x\n",
|
|
|
|
Routine, Param1, Param2);
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
2003-05-26 18:52:37 +00:00
|
|
|
}
|
2003-08-28 18:04:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
NtUserSystemParametersInfo(
|
|
|
|
UINT uiAction,
|
|
|
|
UINT uiParam,
|
|
|
|
PVOID pvParam,
|
|
|
|
UINT fWinIni)
|
|
|
|
{
|
2003-08-29 09:29:11 +00:00
|
|
|
/* FIXME: This should be obtained from the registry */
|
|
|
|
static LOGFONTW CaptionFont =
|
|
|
|
{ 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"" };
|
|
|
|
/* { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, FF_MODERN, L"Bitstream Vera Sans Bold" };*/
|
2003-08-28 18:04:59 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PWINSTATION_OBJECT WinStaObject;
|
|
|
|
|
|
|
|
switch(uiAction)
|
|
|
|
{
|
|
|
|
case SPI_SETDOUBLECLKWIDTH:
|
|
|
|
case SPI_SETDOUBLECLKHEIGHT:
|
|
|
|
case SPI_SETDOUBLECLICKTIME:
|
|
|
|
Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
|
|
|
|
KernelMode,
|
|
|
|
0,
|
|
|
|
&WinStaObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return (DWORD)FALSE;
|
|
|
|
|
|
|
|
switch(uiAction)
|
|
|
|
{
|
|
|
|
case SPI_SETDOUBLECLKWIDTH:
|
|
|
|
/* FIXME limit the maximum value? */
|
|
|
|
WinStaObject->SystemCursor.DblClickWidth = uiParam;
|
|
|
|
break;
|
|
|
|
case SPI_SETDOUBLECLKHEIGHT:
|
|
|
|
/* FIXME limit the maximum value? */
|
|
|
|
WinStaObject->SystemCursor.DblClickHeight = uiParam;
|
|
|
|
break;
|
|
|
|
case SPI_SETDOUBLECLICKTIME:
|
|
|
|
/* FIXME limit the maximum time to 1000 ms? */
|
|
|
|
WinStaObject->SystemCursor.DblClickSpeed = uiParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME save the value to the registry */
|
|
|
|
|
|
|
|
ObDereferenceObject(WinStaObject);
|
|
|
|
return TRUE;
|
2003-08-29 09:29:11 +00:00
|
|
|
|
|
|
|
case SPI_GETWORKAREA:
|
|
|
|
{
|
|
|
|
((PRECT)pvParam)->left = 0;
|
|
|
|
((PRECT)pvParam)->top = 0;
|
|
|
|
((PRECT)pvParam)->right = 640;
|
|
|
|
((PRECT)pvParam)->bottom = 480;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case SPI_GETICONTITLELOGFONT:
|
|
|
|
{
|
|
|
|
memcpy(pvParam, &CaptionFont, sizeof(CaptionFont));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case SPI_GETNONCLIENTMETRICS:
|
|
|
|
{
|
|
|
|
LPNONCLIENTMETRICSW pMetrics = (LPNONCLIENTMETRICSW)pvParam;
|
|
|
|
|
|
|
|
if (pMetrics->cbSize != sizeof(NONCLIENTMETRICSW) ||
|
|
|
|
uiParam != sizeof(NONCLIENTMETRICSW))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset((char *)pvParam + sizeof(pMetrics->cbSize), 0,
|
|
|
|
pMetrics->cbSize - sizeof(pMetrics->cbSize));
|
|
|
|
|
|
|
|
pMetrics->iBorderWidth = 1;
|
|
|
|
pMetrics->iScrollWidth = NtUserGetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
pMetrics->iScrollHeight = NtUserGetSystemMetrics(SM_CYHSCROLL);
|
|
|
|
pMetrics->iCaptionWidth = NtUserGetSystemMetrics(SM_CXSIZE);
|
|
|
|
pMetrics->iCaptionHeight = NtUserGetSystemMetrics(SM_CYSIZE);
|
|
|
|
memcpy((LPVOID)&(pMetrics->lfCaptionFont), &CaptionFont, sizeof(CaptionFont));
|
|
|
|
pMetrics->lfCaptionFont.lfWeight = FW_BOLD;
|
|
|
|
pMetrics->iSmCaptionWidth = NtUserGetSystemMetrics(SM_CXSMSIZE);
|
|
|
|
pMetrics->iSmCaptionHeight = NtUserGetSystemMetrics(SM_CYSMSIZE);
|
|
|
|
memcpy((LPVOID)&(pMetrics->lfSmCaptionFont), &CaptionFont, sizeof(CaptionFont));
|
|
|
|
pMetrics->iMenuWidth = NtUserGetSystemMetrics(SM_CXMENUSIZE);
|
|
|
|
pMetrics->iMenuHeight = NtUserGetSystemMetrics(SM_CYMENUSIZE);
|
|
|
|
memcpy((LPVOID)&(pMetrics->lfMenuFont), &CaptionFont, sizeof(CaptionFont));
|
|
|
|
memcpy((LPVOID)&(pMetrics->lfStatusFont), &CaptionFont, sizeof(CaptionFont));
|
|
|
|
memcpy((LPVOID)&(pMetrics->lfMessageFont), &CaptionFont, sizeof(CaptionFont));
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-08-28 18:04:59 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|