mirror of
https://github.com/reactos/reactos.git
synced 2025-04-29 01:48:42 +00:00
1. implemented GetGUIThreadInfo()
2. added test app for GetGUIThreadInfo() svn path=/trunk/; revision=6696
This commit is contained in:
parent
fc42ec41b9
commit
1bcf21b057
12 changed files with 275 additions and 28 deletions
6
reactos/apps/tests/guithreadinfo/.cvsignore
Normal file
6
reactos/apps/tests/guithreadinfo/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
125
reactos/apps/tests/guithreadinfo/guithreadinfo.c
Normal file
125
reactos/apps/tests/guithreadinfo/guithreadinfo.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static GUITHREADINFO gti;
|
||||
//HFONT tf;
|
||||
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
|
||||
wc.lpszClassName = "GuiThreadInfoClass";
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClass(&wc) == 0)
|
||||
{
|
||||
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow("GuiThreadInfoClass",
|
||||
"GetGUIThreadInfo",
|
||||
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
|
||||
0,
|
||||
0,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
//tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
// ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
// DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
|
||||
|
||||
gti.cbSize = sizeof(GUITHREADINFO);
|
||||
GetGUIThreadInfo(0, >i);
|
||||
|
||||
SetTimer(hWnd, 1, 1000, NULL);
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
//DeleteObject(tf);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
char str[255];
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
wsprintf(str, "flags: ");
|
||||
if(gti.flags & GUI_16BITTASK) lstrcat(str, "GUI_16BITTASK ");
|
||||
if(gti.flags & GUI_CARETBLINKING) lstrcat(str, "GUI_CARETBLINKING ");
|
||||
if(gti.flags & GUI_INMENUMODE) lstrcat(str, "GUI_INMENUMODE ");
|
||||
if(gti.flags & GUI_INMOVESIZE) lstrcat(str, "GUI_INMOVESIZE ");
|
||||
if(gti.flags & GUI_POPUPMENUMODE) lstrcat(str, "GUI_POPUPMENUMODE ");
|
||||
if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE ");
|
||||
TextOut(hDC, 10, 10, str, strlen(str));
|
||||
|
||||
wsprintf(str, "hwndActive == %04x", gti.hwndActive);
|
||||
TextOut(hDC, 10, 30, str, strlen(str));
|
||||
wsprintf(str, "hwndFocus == %04x", gti.hwndFocus);
|
||||
TextOut(hDC, 10, 50, str, strlen(str));
|
||||
wsprintf(str, "hwndCapture == %04x", gti.hwndCapture);
|
||||
TextOut(hDC, 10, 70, str, strlen(str));
|
||||
wsprintf(str, "hwndMenuOwner == %04x", gti.hwndMenuOwner);
|
||||
TextOut(hDC, 10, 90, str, strlen(str));
|
||||
wsprintf(str, "hwndMoveSize == %04x", gti.hwndMoveSize);
|
||||
TextOut(hDC, 10, 110, str, strlen(str));
|
||||
wsprintf(str, "hwndCaret == %04x", gti.hwndCaret);
|
||||
TextOut(hDC, 10, 130, str, strlen(str));
|
||||
wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom);
|
||||
TextOut(hDC, 10, 150, str, strlen(str));
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
GetGUIThreadInfo(0, >i);
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
23
reactos/apps/tests/guithreadinfo/makefile
Normal file
23
reactos/apps/tests/guithreadinfo/makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
# $Id: makefile,v 1.1 2003/11/18 23:33:31 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = guithreadinfo
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a user32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1569,6 +1569,14 @@ extern "C" {
|
|||
#define GM_COMPATIBLE (1)
|
||||
#define GM_ADVANCED (2)
|
||||
|
||||
/* GetGUIThreadInfo */
|
||||
#define GUI_CARETBLINKING (1)
|
||||
#define GUI_INMOVESIZE (2)
|
||||
#define GUI_INMENUMODE (4)
|
||||
#define GUI_SYSTEMMENUMODE (8)
|
||||
#define GUI_POPUPMENUMODE (16)
|
||||
#define GUI_16BITTASK (32)
|
||||
|
||||
/* GetHandleInformation */
|
||||
#define HANDLE_FLAG_INHERIT (1)
|
||||
#define HANDLE_FLAG_PROTECT_FROM_CLOSE (2)
|
||||
|
|
|
@ -9326,6 +9326,13 @@ GetWindowThreadProcessId(
|
|||
HWND hWnd,
|
||||
LPDWORD lpdwProcessId);
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GetGUIThreadInfo(
|
||||
DWORD idThread,
|
||||
LPGUITHREADINFO lpgui);
|
||||
|
||||
|
||||
HWND
|
||||
STDCALL
|
||||
|
|
|
@ -697,11 +697,11 @@ NtUserGetGuiResources(
|
|||
DWORD Unknown0,
|
||||
DWORD Unknown1);
|
||||
|
||||
DWORD
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetGUIThreadInfo(
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1);
|
||||
DWORD idThread,
|
||||
LPGUITHREADINFO lpgui);
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: window.c,v 1.81 2003/11/11 20:28:21 gvg Exp $
|
||||
/* $Id: window.c,v 1.82 2003/11/18 23:33:31 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS user32.dll
|
||||
|
@ -966,14 +966,13 @@ GetClientRect(HWND hWnd, LPRECT lpRect)
|
|||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
WINBOOL STDCALL
|
||||
GetGUIThreadInfo(DWORD idThread,
|
||||
LPGUITHREADINFO lpgui)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
return (WINBOOL)NtUserGetGUIThreadInfo(idThread, lpgui);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _WIN32K_MSGQUEUE_H
|
||||
#define _WIN32K_MSGQUEUE_H
|
||||
|
||||
#include <internal/ex.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _USER_MESSAGE
|
||||
|
@ -34,6 +35,8 @@ typedef struct _USER_SENT_MESSAGE_NOTIFY
|
|||
|
||||
typedef struct _USER_MESSAGE_QUEUE
|
||||
{
|
||||
/* Owner of the message queue */
|
||||
struct _ETHREAD *Thread;
|
||||
/* Queue of messages sent to the queue. */
|
||||
LIST_ENTRY SentMessagesListHead;
|
||||
/* Queue of messages posted to the queue. */
|
||||
|
@ -95,11 +98,11 @@ MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
|
|||
IN UINT MsgFilterHigh,
|
||||
OUT PUSER_MESSAGE* Message);
|
||||
VOID FASTCALL
|
||||
MsqInitializeMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
|
||||
MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
|
||||
VOID FASTCALL
|
||||
MsqFreeMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
|
||||
PUSER_MESSAGE_QUEUE FASTCALL
|
||||
MsqCreateMessageQueue(VOID);
|
||||
MsqCreateMessageQueue(struct _ETHREAD *Thread);
|
||||
VOID FASTCALL
|
||||
MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
|
||||
PUSER_MESSAGE_QUEUE FASTCALL
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: dllmain.c,v 1.50 2003/11/11 22:17:18 weiden Exp $
|
||||
/* $Id: dllmain.c,v 1.51 2003/11/18 23:33:31 weiden Exp $
|
||||
*
|
||||
* Entry Point for win32k.sys
|
||||
*/
|
||||
|
@ -125,7 +125,7 @@ Win32kThreadCallback (struct _ETHREAD *Thread,
|
|||
#endif
|
||||
|
||||
IntDestroyCaret(Win32Thread);
|
||||
Win32Thread->MessageQueue = MsqCreateMessageQueue();
|
||||
Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
|
||||
Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
|
||||
InitializeListHead(&Win32Thread->WindowListHead);
|
||||
ExInitializeFastMutex(&Win32Thread->WindowListLock);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: misc.c,v 1.23 2003/11/11 20:28:21 gvg Exp $
|
||||
/* $Id: misc.c,v 1.24 2003/11/18 23:33:31 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -427,3 +427,89 @@ NtUserGetDoubleClickTime(VOID)
|
|||
return Result;
|
||||
}
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserGetGUIThreadInfo(
|
||||
DWORD idThread,
|
||||
LPGUITHREADINFO lpgui)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PTHRDCARETINFO CaretInfo;
|
||||
GUITHREADINFO SafeGui;
|
||||
PDESKTOP_OBJECT Desktop;
|
||||
PUSER_MESSAGE_QUEUE MsgQueue;
|
||||
PETHREAD Thread = NULL;
|
||||
|
||||
Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD));
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(SafeGui.cbSize != sizeof(GUITHREADINFO))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(idThread)
|
||||
{
|
||||
Status = PsLookupThreadByThreadId((PVOID)idThread, &Thread);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
}
|
||||
Desktop = Thread->Win32Thread->Desktop;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get the foreground thread */
|
||||
PW32THREAD W32Thread = PsGetCurrentThread()->Win32Thread;
|
||||
Desktop = W32Thread->Desktop;
|
||||
if(Desktop)
|
||||
{
|
||||
MsgQueue = Desktop->ActiveMessageQueue;
|
||||
if(MsgQueue)
|
||||
{
|
||||
Thread = MsgQueue->Thread;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!Thread || !Desktop)
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CaretInfo = ThrdCaretInfo(Thread->Win32Thread);
|
||||
MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue;
|
||||
|
||||
SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
|
||||
/* FIXME add flags GUI_16BITTASK, GUI_INMENUMODE, GUI_INMOVESIZE,
|
||||
GUI_POPUPMENUMODE, GUI_SYSTEMMENUMODE */
|
||||
|
||||
SafeGui.hwndActive = MsgQueue->ActiveWindow;
|
||||
SafeGui.hwndFocus = MsgQueue->FocusWindow;
|
||||
SafeGui.hwndCapture = MsgQueue->CaptureWindow;
|
||||
SafeGui.hwndMenuOwner = 0; /* FIXME */
|
||||
SafeGui.hwndMoveSize = 0; /* FIXME */
|
||||
SafeGui.hwndCaret = CaretInfo->hWnd;
|
||||
|
||||
SafeGui.rcCaret.left = CaretInfo->Pos.x;
|
||||
SafeGui.rcCaret.top = CaretInfo->Pos.y;
|
||||
SafeGui.rcCaret.right = SafeGui.rcCaret.left + CaretInfo->Size.cx;
|
||||
SafeGui.rcCaret.bottom = SafeGui.rcCaret.top + CaretInfo->Size.cy;
|
||||
|
||||
Status = MmCopyToCaller(lpgui, &SafeGui, sizeof(GUITHREADINFO));
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: msgqueue.c,v 1.30 2003/11/03 18:52:21 ekohl Exp $
|
||||
/* $Id: msgqueue.c,v 1.31 2003/11/18 23:33:31 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -798,8 +798,9 @@ MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue)
|
|||
}
|
||||
|
||||
VOID FASTCALL
|
||||
MsqInitializeMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
|
||||
MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue)
|
||||
{
|
||||
MessageQueue->Thread = Thread;
|
||||
InitializeListHead(&MessageQueue->PostedMessagesListHead);
|
||||
InitializeListHead(&MessageQueue->SentMessagesListHead);
|
||||
InitializeListHead(&MessageQueue->HardwareMessagesListHead);
|
||||
|
@ -828,7 +829,7 @@ MsqFreeMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
|
|||
}
|
||||
|
||||
PUSER_MESSAGE_QUEUE FASTCALL
|
||||
MsqCreateMessageQueue(VOID)
|
||||
MsqCreateMessageQueue(struct _ETHREAD *Thread)
|
||||
{
|
||||
PUSER_MESSAGE_QUEUE MessageQueue;
|
||||
|
||||
|
@ -839,7 +840,7 @@ MsqCreateMessageQueue(VOID)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
MsqInitializeMessageQueue(MessageQueue);
|
||||
MsqInitializeMessageQueue(Thread, MessageQueue);
|
||||
|
||||
return MessageQueue;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: stubs.c,v 1.35 2003/11/18 20:49:39 navaraf Exp $
|
||||
/* $Id: stubs.c,v 1.36 2003/11/18 23:33:31 weiden Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -536,17 +536,6 @@ NtUserGetGuiResources(
|
|||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserGetGUIThreadInfo(
|
||||
DWORD Unknown0,
|
||||
DWORD Unknown1)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
NtUserGetImeHotKey(
|
||||
|
|
Loading…
Reference in a new issue