2 * OleView (interface.c)
4 * Copyright 2006 Piotr Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 BOOL
IsInterface(HTREEITEM item
)
33 memset(&tvi
, 0, sizeof(TVITEMW
));
36 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
37 if(!tvi
.lParam
) return FALSE
;
39 if(((ITEM_INFO
*)tvi
.lParam
)->cFlag
& INTERFACE
) return TRUE
;
43 static IUnknown
*GetInterface(void)
50 hSelect
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
53 memset(&tvi
, 0, sizeof(TVITEMW
));
55 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
56 CLSIDFromString(((ITEM_INFO
*)tvi
.lParam
)->clsid
, &clsid
);
58 memset(&tvi
, 0, sizeof(TVITEMW
));
59 tvi
.hItem
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
60 TVGN_PARENT
, (LPARAM
)hSelect
);
61 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
63 IUnknown_QueryInterface(((ITEM_INFO
*)tvi
.lParam
)->pU
, &clsid
, (void *)&unk
);
68 static INT_PTR CALLBACK
InterfaceViewerProc(HWND hDlgWnd
, UINT uMsg
,
69 WPARAM wParam
, LPARAM lParam
)
76 WCHAR wszSize
[MAX_LOAD_STRING
];
77 WCHAR wszBuf
[MAX_LOAD_STRING
];
78 WCHAR wszFormat
[] = { '%','d',' ','%','s','\0' };
83 di
= (DIALOG_INFO
*)lParam
;
84 hObject
= GetDlgItem(hDlgWnd
, IDC_LABEL
);
85 SetWindowTextW(hObject
, di
->wszLabel
);
86 hObject
= GetDlgItem(hDlgWnd
, IDC_IDENTIFIER
);
87 SetWindowTextW(hObject
, di
->wszIdentifier
);
90 switch(LOWORD(wParam
)) {
92 EndDialog(hDlgWnd
, IDCANCEL
);
94 case IDC_ISDIRTY_BUTTON
:
96 hRes
= IPersistStream_IsDirty((IPersistStream
*)unk
);
97 IUnknown_Release(unk
);
99 LoadStringW(globals
.hMainInst
, IDS_FALSE
, wszBuf
, ARRAY_SIZE(wszBuf
));
101 LoadStringW(globals
.hMainInst
, IDS_TRUE
, wszBuf
, ARRAY_SIZE(wszBuf
));
102 hObject
= GetDlgItem(hDlgWnd
, IDC_ISDIRTY
);
103 SetWindowTextW(hObject
, wszBuf
);
105 case IDC_GETSIZEMAX_BUTTON
:
106 unk
= GetInterface();
107 IPersistStream_GetSizeMax((IPersistStream
*)unk
, &size
);
108 IUnknown_Release(unk
);
109 LoadStringW(globals
.hMainInst
, IDS_BYTES
, wszBuf
, ARRAY_SIZE(wszBuf
));
110 wsprintfW(wszSize
, wszFormat
, U(size
).LowPart
, wszBuf
);
111 hObject
= GetDlgItem(hDlgWnd
, IDC_GETSIZEMAX
);
112 SetWindowTextW(hObject
, wszSize
);
119 static void IPersistStreamInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
122 WCHAR wszClassMoniker
[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
124 if(wszName
[0] == '{')
125 di
.wszLabel
= wszClassMoniker
;
126 else di
.wszLabel
= wszName
;
127 di
.wszIdentifier
= clsid
;
129 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_IPERSISTSTREAM_IV
),
130 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
133 static void IPersistInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
136 WCHAR wszClassMoniker
[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
138 if(wszName
[0] == '{')
139 di
.wszLabel
= wszClassMoniker
;
140 else di
.wszLabel
= wszName
;
141 di
.wszIdentifier
= clsid
;
143 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_IPERSIST_IV
),
144 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
147 static void DefaultInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
151 di
.wszLabel
= wszName
;
152 di
.wszIdentifier
= clsid
;
154 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_DEFAULT_IV
),
155 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
158 void InterfaceViewer(HTREEITEM item
)
162 WCHAR wszName
[MAX_LOAD_STRING
];
163 WCHAR wszParent
[MAX_LOAD_STRING
];
164 WCHAR wszIPersistStream
[] = { '{','0','0','0','0','0','1','0','9','-',
165 '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
166 '0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
167 WCHAR wszIPersist
[] = { '{','0','0','0','0','0','1','0','C','-',
168 '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
169 '0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
171 memset(&tvi
, 0, sizeof(TVITEMW
));
172 tvi
.mask
= TVIF_TEXT
;
174 tvi
.cchTextMax
= MAX_LOAD_STRING
;
175 tvi
.pszText
= wszName
;
177 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
178 clsid
= ((ITEM_INFO
*)tvi
.lParam
)->clsid
;
180 memset(&tvi
, 0, sizeof(TVITEMW
));
181 tvi
.mask
= TVIF_TEXT
;
182 tvi
.hItem
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
183 TVGN_PARENT
, (LPARAM
)item
);
184 tvi
.cchTextMax
= MAX_LOAD_STRING
;
185 tvi
.pszText
= wszParent
;
187 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
189 if(!memcmp(clsid
, wszIPersistStream
, sizeof(wszIPersistStream
)))
190 IPersistStreamInterfaceViewer(clsid
, wszParent
);
192 else if(!memcmp(clsid
, wszIPersist
, sizeof(wszIPersist
)))
193 IPersistInterfaceViewer(clsid
, wszParent
);
195 else DefaultInterfaceViewer(clsid
, wszName
);