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
,
100 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
101 else LoadStringW(globals
.hMainInst
, IDS_TRUE
, wszBuf
,
102 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
103 hObject
= GetDlgItem(hDlgWnd
, IDC_ISDIRTY
);
104 SetWindowTextW(hObject
, wszBuf
);
106 case IDC_GETSIZEMAX_BUTTON
:
107 unk
= GetInterface();
108 IPersistStream_GetSizeMax((IPersistStream
*)unk
, &size
);
109 IUnknown_Release(unk
);
110 LoadStringW(globals
.hMainInst
, IDS_BYTES
, wszBuf
,
111 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
112 wsprintfW(wszSize
, wszFormat
, U(size
).LowPart
, wszBuf
);
113 hObject
= GetDlgItem(hDlgWnd
, IDC_GETSIZEMAX
);
114 SetWindowTextW(hObject
, wszSize
);
121 static void IPersistStreamInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
124 WCHAR wszClassMoniker
[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
126 if(wszName
[0] == '{')
127 di
.wszLabel
= wszClassMoniker
;
128 else di
.wszLabel
= wszName
;
129 di
.wszIdentifier
= clsid
;
131 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_IPERSISTSTREAM_IV
),
132 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
135 static void IPersistInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
138 WCHAR wszClassMoniker
[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
140 if(wszName
[0] == '{')
141 di
.wszLabel
= wszClassMoniker
;
142 else di
.wszLabel
= wszName
;
143 di
.wszIdentifier
= clsid
;
145 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_IPERSIST_IV
),
146 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
149 static void DefaultInterfaceViewer(WCHAR
*clsid
, WCHAR
*wszName
)
153 di
.wszLabel
= wszName
;
154 di
.wszIdentifier
= clsid
;
156 DialogBoxParamW(0, MAKEINTRESOURCEW(DLG_DEFAULT_IV
),
157 globals
.hMainWnd
, InterfaceViewerProc
, (LPARAM
)&di
);
160 void InterfaceViewer(HTREEITEM item
)
164 WCHAR wszName
[MAX_LOAD_STRING
];
165 WCHAR wszParent
[MAX_LOAD_STRING
];
166 WCHAR wszIPersistStream
[] = { '{','0','0','0','0','0','1','0','9','-',
167 '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
168 '0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
169 WCHAR wszIPersist
[] = { '{','0','0','0','0','0','1','0','C','-',
170 '0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
171 '0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
173 memset(&tvi
, 0, sizeof(TVITEMW
));
174 tvi
.mask
= TVIF_TEXT
;
176 tvi
.cchTextMax
= MAX_LOAD_STRING
;
177 tvi
.pszText
= wszName
;
179 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
180 clsid
= ((ITEM_INFO
*)tvi
.lParam
)->clsid
;
182 memset(&tvi
, 0, sizeof(TVITEMW
));
183 tvi
.mask
= TVIF_TEXT
;
184 tvi
.hItem
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
185 TVGN_PARENT
, (LPARAM
)item
);
186 tvi
.cchTextMax
= MAX_LOAD_STRING
;
187 tvi
.pszText
= wszParent
;
189 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
191 if(!memcmp(clsid
, wszIPersistStream
, sizeof(wszIPersistStream
)))
192 IPersistStreamInterfaceViewer(clsid
, wszParent
);
194 else if(!memcmp(clsid
, wszIPersist
, sizeof(wszIPersist
)))
195 IPersistInterfaceViewer(clsid
, wszParent
);
197 else DefaultInterfaceViewer(clsid
, wszName
);