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)) )
88 if (ProcessId
== (HANDLE
)1 ||
89 ((LONG
)ProcessId
& 0xfffc) == ((ULONG
)pEntry
->ProcessId
& 0xfffc))
91 handle
= GDI_HANDLE_CREATE(i
, pEntry
->Type
);
92 index
= ListView_GetItemCount(hHandleListCtrl
);
95 item
.lParam
= (LPARAM
)handle
;
97 wsprintf(strText
, L
"%d", index
);
98 (void)ListView_InsertItem(hHandleListCtrl
, &item
);
100 wsprintf(strText
, L
"%d", i
);
101 ListView_SetItemText(hHandleListCtrl
, index
, 1, strText
);
103 wsprintf(strText
, L
"%#08x", handle
);
104 ListView_SetItemText(hHandleListCtrl
, index
, 2, strText
);
106 str2
= GetTypeName(handle
);
107 ListView_SetItemText(hHandleListCtrl
, index
, 3, str2
);
109 wsprintf(strText
, L
"%#08x", (UINT
)pEntry
->ProcessId
);
110 ListView_SetItemText(hHandleListCtrl
, index
, 4, strText
);
112 wsprintf(strText
, L
"%#08x", (UINT
)pEntry
->KernelData
);
113 ListView_SetItemText(hHandleListCtrl
, index
, 5, strText
);
115 wsprintf(strText
, L
"%#08x", (UINT
)pEntry
->UserData
);
116 ListView_SetItemText(hHandleListCtrl
, index
, 6, strText
);
118 wsprintf(strText
, L
"%#08x", (UINT
)pEntry
->Type
);
119 ListView_SetItemText(hHandleListCtrl
, index
, 7, strText
);
126 GetTypeName(HANDLE handle
)
129 UINT Type
= GDI_HANDLE_GET_TYPE(handle
);
133 case GDI_OBJECT_TYPE_DC
:
136 case GDI_OBJECT_TYPE_REGION
:
139 case GDI_OBJECT_TYPE_BITMAP
:
142 case GDI_OBJECT_TYPE_PALETTE
:
143 strText
= L
"Palette";
145 case GDI_OBJECT_TYPE_FONT
:
148 case GDI_OBJECT_TYPE_BRUSH
:
151 case GDI_OBJECT_TYPE_EMF
:
154 case GDI_OBJECT_TYPE_PEN
:
157 case GDI_OBJECT_TYPE_EXTPEN
:
160 case GDI_OBJECT_TYPE_COLORSPACE
:
161 strText
= L
"ColSpace";
163 case GDI_OBJECT_TYPE_METADC
:
166 case GDI_OBJECT_TYPE_METAFILE
:
167 strText
= L
"Metafile";
169 case GDI_OBJECT_TYPE_ENHMETAFILE
:
172 case GDI_OBJECT_TYPE_ENHMETADC
:
175 case GDI_OBJECT_TYPE_MEMDC
:
178 case GDI_OBJECT_TYPE_DCE
:
181 case GDI_OBJECT_TYPE_PFE
:
184 case GDI_OBJECT_TYPE_DONTCARE
:
185 strText
= L
"anything";
187 case GDI_OBJECT_TYPE_SILENT
:
189 strText
= L
"unknown";