6 * Copyright (C) 2007 Timo Kreuzer <timo <dot> kreuzer <at> reactos <dot> org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 HandleList_Create(HWND hListCtrl
)
30 column
.mask
= LVCF_TEXT
|LVCF_FMT
|LVCF_WIDTH
;
31 column
.fmt
= LVCFMT_LEFT
;
33 column
.pszText
= L
"Number";
35 (void)ListView_InsertColumn(hListCtrl
, 0, &column
);
37 column
.pszText
= L
"Index";
39 (void)ListView_InsertColumn(hListCtrl
, 1, &column
);
41 column
.pszText
= L
"Handle";
43 (void)ListView_InsertColumn(hListCtrl
, 2, &column
);
45 column
.pszText
= L
"Type";
47 (void)ListView_InsertColumn(hListCtrl
, 3, &column
);
49 column
.pszText
= L
"Process";
51 (void)ListView_InsertColumn(hListCtrl
, 4, &column
);
53 column
.pszText
= L
"KernelData";
55 (void)ListView_InsertColumn(hListCtrl
, 5, &column
);
57 column
.pszText
= L
"UserData";
59 (void)ListView_InsertColumn(hListCtrl
, 6, &column
);
61 column
.pszText
= L
"Type";
63 (void)ListView_InsertColumn(hListCtrl
, 7, &column
);
65 HandleList_Update(hListCtrl
, 0);
69 HandleList_Update(HWND hHandleListCtrl
, HANDLE ProcessId
)
73 PGDI_TABLE_ENTRY pEntry
;
78 (void)ListView_DeleteAllItems(hHandleListCtrl
);
79 item
.mask
= LVIF_TEXT
|LVIF_PARAM
;
80 item
.pszText
= strText
;
82 for (i
= 0; i
<= GDI_HANDLE_COUNT
; i
++)
84 pEntry
= &GdiHandleTable
[i
];
85 if ( ((ProcessId
!= (HANDLE
)1) && ((pEntry
->Type
& GDI_HANDLE_BASETYPE_MASK
) != 0)) ||
86 ((ProcessId
== (HANDLE
)1) && ((pEntry
->Type
& GDI_HANDLE_BASETYPE_MASK
) == 0)) ||
87 (ProcessId
== (HANDLE
)2) )
89 if (ProcessId
== (HANDLE
)1 || ProcessId
== (HANDLE
)2 ||
90 ((LONG_PTR
)ProcessId
& 0xfffc) == ((ULONG_PTR
)pEntry
->ProcessId
& 0xfffc))
92 handle
= GDI_HANDLE_CREATE(i
, (ULONG_PTR
)pEntry
->Type
);
93 index
= ListView_GetItemCount(hHandleListCtrl
);
96 item
.lParam
= (LPARAM
)handle
;
98 wsprintf(strText
, L
"%d", index
);
99 (void)ListView_InsertItem(hHandleListCtrl
, &item
);
101 wsprintf(strText
, L
"%d", i
);
102 ListView_SetItemText(hHandleListCtrl
, index
, 1, strText
);
104 wsprintf(strText
, L
"%#08x", handle
);
105 ListView_SetItemText(hHandleListCtrl
, index
, 2, strText
);
107 str2
= GetTypeName(handle
);
108 ListView_SetItemText(hHandleListCtrl
, index
, 3, str2
);
110 wsprintf(strText
, L
"%#08x", (UINT_PTR
)pEntry
->ProcessId
);
111 ListView_SetItemText(hHandleListCtrl
, index
, 4, strText
);
113 wsprintf(strText
, L
"%#08x", (UINT_PTR
)pEntry
->KernelData
);
114 ListView_SetItemText(hHandleListCtrl
, index
, 5, strText
);
116 wsprintf(strText
, L
"%#08x", (UINT_PTR
)pEntry
->UserData
);
117 ListView_SetItemText(hHandleListCtrl
, index
, 6, strText
);
119 wsprintf(strText
, L
"%#08x", (UINT
)pEntry
->Type
);
120 ListView_SetItemText(hHandleListCtrl
, index
, 7, strText
);
127 GetTypeName(HANDLE handle
)
130 UINT Type
= GDI_HANDLE_GET_TYPE(handle
);
134 case GDI_OBJECT_TYPE_DC
:
137 case GDI_OBJECT_TYPE_REGION
:
140 case GDI_OBJECT_TYPE_BITMAP
:
143 case GDI_OBJECT_TYPE_PALETTE
:
144 strText
= L
"Palette";
146 case GDI_OBJECT_TYPE_FONT
:
149 case GDI_OBJECT_TYPE_BRUSH
:
152 case GDI_OBJECT_TYPE_EMF
:
155 case GDI_OBJECT_TYPE_PEN
:
158 case GDI_OBJECT_TYPE_EXTPEN
:
161 case GDI_OBJECT_TYPE_COLORSPACE
:
162 strText
= L
"ColSpace";
164 case GDI_OBJECT_TYPE_METADC
:
167 case GDI_OBJECT_TYPE_METAFILE
:
168 strText
= L
"Metafile";
170 case GDI_OBJECT_TYPE_ENHMETAFILE
:
173 case GDI_OBJECT_TYPE_ENHMETADC
:
176 case GDI_OBJECT_TYPE_MEMDC
:
179 case GDI_OBJECT_TYPE_DCE
:
182 case GDI_OBJECT_TYPE_PFE
:
185 case GDI_OBJECT_TYPE_DONTCARE
:
186 strText
= L
"anything";
188 case GDI_OBJECT_TYPE_SILENT
:
190 strText
= L
"unknown";