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(TVITEM
));
36 SendMessage(globals
.hTree
, TVM_GETITEM
, 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
= TreeView_GetSelection(globals
.hTree
);
52 memset(&tvi
, 0, sizeof(TVITEM
));
54 SendMessage(globals
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
55 CLSIDFromString(((ITEM_INFO
*)tvi
.lParam
)->clsid
, &clsid
);
57 memset(&tvi
, 0, sizeof(TVITEM
));
58 tvi
.hItem
= TreeView_GetParent(globals
.hTree
, hSelect
);
59 SendMessage(globals
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
61 IUnknown_QueryInterface(((ITEM_INFO
*)tvi
.lParam
)->pU
, &clsid
, (void *)&unk
);
66 static INT_PTR CALLBACK
InterfaceViewerProc(HWND hDlgWnd
, UINT uMsg
,
67 WPARAM wParam
, LPARAM lParam
)
74 WCHAR wszSize
[MAX_LOAD_STRING
];
75 WCHAR wszBuf
[MAX_LOAD_STRING
];
76 WCHAR wszFormat
[] = { '%','d',' ','%','s','\0' };
81 di
= (DIALOG_INFO
*)lParam
;
82 hObject
= GetDlgItem(hDlgWnd
, IDC_LABEL
);
83 SetWindowText(hObject
, di
->wszLabel
);
84 hObject
= GetDlgItem(hDlgWnd
, IDC_IDENTIFIER
);
85 SetWindowText(hObject
, di
->wszIdentifier
);
88 switch(LOWORD(wParam
)) {
90 EndDialog(hDlgWnd
, IDCANCEL
);
92 case IDC_ISDIRTY_BUTTON
:
94 hRes
= IPersistStream_IsDirty((IPersistStream
*)unk
);
95 IUnknown_Release(unk
);
97 LoadString(globals
.hMainInst
, IDS_FALSE
, wszBuf
,
98 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
99 else LoadString(globals
.hMainInst
, IDS_TRUE
, wszBuf
,
100 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
101 hObject
= GetDlgItem(hDlgWnd
, IDC_ISDIRTY
);
102 SetWindowText(hObject
, wszBuf
);
104 case IDC_GETSIZEMAX_BUTTON
:
105 unk
= GetInterface();
106 IPersistStream_GetSizeMax((IPersistStream
*)unk
, &size
);
107 IUnknown_Release(unk
);
108 LoadString(globals
.hMainInst
, IDS_BYTES
, wszBuf
,
109 sizeof(wszBuf
)/sizeof(wszBuf
[0]));
110 wsprintfW(wszSize
, wszFormat
, U(size
).LowPart
, wszBuf
);
111 hObject
= GetDlgItem(hDlgWnd
, IDC_GETSIZEMAX
);
112 SetWindowText(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 DialogBoxParam(0, MAKEINTRESOURCE(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 DialogBoxParam(0, MAKEINTRESOURCE(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 DialogBoxParam(0, MAKEINTRESOURCE(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(TVITEM
));
172 tvi
.mask
= TVIF_TEXT
;
174 tvi
.cchTextMax
= MAX_LOAD_STRING
;
175 tvi
.pszText
= wszName
;
177 SendMessage(globals
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
178 clsid
= ((ITEM_INFO
*)tvi
.lParam
)->clsid
;
180 memset(&tvi
, 0, sizeof(TVITEM
));
181 tvi
.mask
= TVIF_TEXT
;
182 tvi
.hItem
= TreeView_GetParent(globals
.hTree
, item
);
183 tvi
.cchTextMax
= MAX_LOAD_STRING
;
184 tvi
.pszText
= wszParent
;
186 SendMessage(globals
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
188 if(!memcmp(clsid
, wszIPersistStream
, sizeof(wszIPersistStream
)))
189 IPersistStreamInterfaceViewer(clsid
, wszParent
);
191 else if(!memcmp(clsid
, wszIPersist
, sizeof(wszIPersist
)))
192 IPersistInterfaceViewer(clsid
, wszParent
);
194 else DefaultInterfaceViewer(clsid
, wszName
);