ReactOS  0.4.14-dev-1332-g6db3d88
guithreadinfo.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <string.h>
4 
6 //HFONT tf;
8 
9 int WINAPI
11  HINSTANCE hPrevInstance,
12  LPSTR lpszCmdLine,
13  int nCmdShow)
14 {
15  WNDCLASS wc;
16  MSG msg;
17  HWND hWnd;
18 
19  wc.lpszClassName = "GuiThreadInfoClass";
22  wc.hInstance = hInstance;
26  wc.lpszMenuName = NULL;
27  wc.cbClsExtra = 0;
28  wc.cbWndExtra = 0;
29  if (RegisterClass(&wc) == 0)
30  {
31  fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
32  GetLastError());
33  return(1);
34  }
35 
36  hWnd = CreateWindow("GuiThreadInfoClass",
37  "GetGUIThreadInfo",
39  0,
40  0,
43  NULL,
44  NULL,
45  hInstance,
46  NULL);
47  if (hWnd == NULL)
48  {
49  fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
50  GetLastError());
51  return(1);
52  }
53 
54  //tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
55  // ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
56  // DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
57 
58  gti.cbSize = sizeof(GUITHREADINFO);
59  GetGUIThreadInfo(0, &gti);
60 
61  SetTimer(hWnd, 1, 1000, NULL);
62  ShowWindow(hWnd, nCmdShow);
63 
64  while(GetMessage(&msg, NULL, 0, 0))
65  {
68  }
69 
70  //DeleteObject(tf);
71 
72  return msg.wParam;
73 }
74 
76 {
77  PAINTSTRUCT ps;
78  HDC hDC;
79  char str[255];
80 
81  switch(msg)
82  {
83 
84  case WM_PAINT:
85  hDC = BeginPaint(hWnd, &ps);
86  wsprintf(str, "flags: ");
87  if(gti.flags & GUI_16BITTASK) lstrcat(str, "GUI_16BITTASK ");
88  if(gti.flags & GUI_CARETBLINKING) lstrcat(str, "GUI_CARETBLINKING ");
89  if(gti.flags & GUI_INMENUMODE) lstrcat(str, "GUI_INMENUMODE ");
90  if(gti.flags & GUI_INMOVESIZE) lstrcat(str, "GUI_INMOVESIZE ");
91  if(gti.flags & GUI_POPUPMENUMODE) lstrcat(str, "GUI_POPUPMENUMODE ");
92  if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE ");
93  TextOut(hDC, 10, 10, str, strlen(str));
94 
95  wsprintf(str, "hwndActive == %08X", gti.hwndActive);
96  TextOut(hDC, 10, 30, str, strlen(str));
97  wsprintf(str, "hwndFocus == %08X", gti.hwndFocus);
98  TextOut(hDC, 10, 50, str, strlen(str));
99  wsprintf(str, "hwndCapture == %08X", gti.hwndCapture);
100  TextOut(hDC, 10, 70, str, strlen(str));
101  wsprintf(str, "hwndMenuOwner == %08X", gti.hwndMenuOwner);
102  TextOut(hDC, 10, 90, str, strlen(str));
103  wsprintf(str, "hwndMoveSize == %08X", gti.hwndMoveSize);
104  TextOut(hDC, 10, 110, str, strlen(str));
105  wsprintf(str, "hwndCaret == %08X", gti.hwndCaret);
106  TextOut(hDC, 10, 130, str, strlen(str));
107  wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom);
108  TextOut(hDC, 10, 150, str, strlen(str));
109 
110  wsprintf(str, "GetGuiResources for the current process: %08X", GetCurrentProcess());
111  TextOut(hDC, 10, 180, str, strlen(str));
112  wsprintf(str, "GetGuiResources: GR_GDIOBJECTS == %04X", GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS));
113  TextOut(hDC, 10, 200, str, strlen(str));
114  wsprintf(str, "GetGuiResources: GR_USEROBJECTS == %04x", GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS));
115  TextOut(hDC, 10, 220, str, strlen(str));
116  EndPaint(hWnd, &ps);
117  break;
118 
119  case WM_TIMER:
120  GetGUIThreadInfo(0, &gti);
122  break;
123 
124  case WM_DESTROY:
125  PostQuitMessage(0);
126  break;
127 
128  default:
129  return DefWindowProc(hWnd, msg, wParam, lParam);
130  }
131  return 0;
132 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HWND hwndMenuOwner
Definition: winable.h:75
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: guithreadinfo.c:10
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5729
static GUITHREADINFO gti
Definition: guithreadinfo.c:5
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DWORD cbSize
Definition: winable.h:70
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
int cbClsExtra
Definition: winuser.h:3140
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
HWND hwndActive
Definition: winable.h:72
EXTINLINE DWORD WINAPI GetGuiResources(HANDLE hProcess, DWORD uiFlags)
Definition: ntwrapper.h:64
#define IDI_APPLICATION
Definition: winuser.h:699
UINT_PTR WPARAM
Definition: windef.h:207
HBRUSH hbrBackground
Definition: winuser.h:3145
#define GUI_CARETBLINKING
Definition: winable.h:27
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
char * LPSTR
Definition: xmlstorage.h:182
LONG right
Definition: windef.h:308
WPARAM wParam
Definition: combotst.c:138
HWND hwndCaret
Definition: winable.h:77
struct tagGUITHREADINFO GUITHREADINFO
int cbWndExtra
Definition: winuser.h:3141
HINSTANCE hInstance
Definition: charmap.c:20
#define GUI_SYSTEMMENUMODE
Definition: winable.h:30
#define GUI_POPUPMENUMODE
Definition: winable.h:31
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HCURSOR hCursor
Definition: winuser.h:3144
HWND hwndFocus
Definition: winable.h:73
#define CW_USEDEFAULT
Definition: winuser.h:225
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define GRAY_BRUSH
Definition: wingdi.h:897
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define CS_VREDRAW
Definition: winuser.h:653
#define WM_TIMER
Definition: winuser.h:1724
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define GUI_INMOVESIZE
Definition: winable.h:28
#define WS_HSCROLL
Definition: pedump.c:628
#define WM_PAINT
Definition: winuser.h:1602
HWND hwndMoveSize
Definition: winable.h:76
LPCSTR lpszClassName
Definition: winuser.h:3147
#define GUI_INMENUMODE
Definition: winable.h:29
#define LoadCursor
Definition: winuser.h:5787
UINT style
Definition: winuser.h:3138
static HDC hDC
Definition: 3dtext.c:33
HINSTANCE hInstance
Definition: winuser.h:3142
unsigned int UINT
Definition: ndis.h:50
#define WS_VSCROLL
Definition: pedump.c:627
#define GetMessage
Definition: winuser.h:5765
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: guithreadinfo.c:75
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define TextOut
Definition: wingdi.h:4482
FILE * stderr
LONG bottom
Definition: windef.h:309
#define RegisterClass
Definition: winuser.h:5811
#define LoadIcon
Definition: winuser.h:5788
LONG_PTR LRESULT
Definition: windef.h:209
#define wsprintf
Definition: winuser.h:5840
#define lstrcat
Definition: winbase.h:3711
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HWND hwndCapture
Definition: winable.h:74
BOOL WINAPI GetGUIThreadInfo(DWORD, LPGUITHREADINFO)
Definition: ntwrapper.h:398
HICON hIcon
Definition: winuser.h:3143