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
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(oleview
);
30 static const WCHAR wszTypeLib
[] = { 'T','Y','P','E','L','I','B','\0' };
32 static const WCHAR wszFailed
[] = { '<','f','a','i','l','e','d','>','\0' };
33 static const WCHAR wszSpace
[] = { ' ','\0' };
34 static const WCHAR wszAsterix
[] = { '*','\0' };
35 static const WCHAR wszComa
[] = { ',','\0' };
36 static const WCHAR wszEquals
[] = { '=','\0' };
37 static const WCHAR wszSemicolon
[] = { ';','\0' };
38 static const WCHAR wszNewLine
[] = { '\n','\0' };
39 static const WCHAR wszOpenBrackets1
[] = { '[','\0' };
40 static const WCHAR wszCloseBrackets1
[] = { ']','\0' };
41 static const WCHAR wszOpenBrackets2
[] = { '(','\0' };
42 static const WCHAR wszCloseBrackets2
[] = { ')','\0' };
43 static const WCHAR wszOpenBrackets3
[] = { '{','\0' };
44 static const WCHAR wszCloseBrackets3
[] = { '}','\0' };
45 static const WCHAR wszInvertedComa
[] = { '"','\0' };
46 static const WCHAR wszColon
[] = { ':','\0' };
48 static const WCHAR wszUUID
[] = { 'u','u','i','d','\0' };
49 static const WCHAR wszOdl
[] = { 'o','d','l','\0' };
51 static const WCHAR wszVT_BOOL
[]
52 = { 'V','A','R','I','A','N','T','_','B','O','O','L','\0' };
53 static const WCHAR wszVT_UI1
[]
54 = { 'u','n','s','i','g','n','e','d',' ','c','h','a','r','\0' };
55 static const WCHAR wszVT_UI2
[]
56 = { 'u','n','s','i','g','n','e','d',' ','s','h','o','r','t','\0' };
57 static const WCHAR wszVT_UI4
[]
58 = { 'u','n','s','i','g','n','e','d',' ','l','o','n','g','\0' };
59 static const WCHAR wszVT_UI8
[] = { 'u','i','n','t','6','4','\0' };
60 static const WCHAR wszVT_UINT
[]
61 = { 'u','n','s','i','g','n','e','d',' ','i','n','t','\0' };
62 static const WCHAR wszVT_I1
[] = { 'c','h','a','r','\0' };
63 static const WCHAR wszVT_I2
[] = { 's','h','o','r','t','\0' };
64 static const WCHAR wszVT_I4
[] = { 'l','o','n','g','\0' };
65 static const WCHAR wszVT_I8
[] = { 'i','n','t','6','4','\0' };
66 static const WCHAR wszVT_R4
[] = { 's','i','n','g','l','e','\0' };
67 static const WCHAR wszVT_INT
[] = { 'i','n','t','\0' };
68 static const WCHAR wszVT_BSTR
[] = { 'B','S','T','R','\0' };
69 static const WCHAR wszVT_CY
[] = { 'C','U','R','R','E','N','C','Y','\0' };
70 static const WCHAR wszVT_VARIANT
[] = { 'V','A','R','I','A','N','T','\0' };
71 static const WCHAR wszVT_VOID
[] = { 'v','o','i','d','\0' };
72 static const WCHAR wszVT_ERROR
[] = { 'S','C','O','D','E','\0' };
73 static const WCHAR wszVT_LPSTR
[] = { 'L','P','S','T','R','\0' };
74 static const WCHAR wszVT_LPWSTR
[] = { 'L','P','W','S','T','R','\0' };
75 static const WCHAR wszVT_HRESULT
[] = { 'H','R','E','S','U','L','T','\0' };
76 static const WCHAR wszVT_UNKNOWN
[] = { 'I','U','n','k','n','o','w','n','\0' };
77 static const WCHAR wszVT_DISPATCH
[] = { 'I','D','i','s','p','a','t','c','h','\0' };
78 static const WCHAR wszVT_DATE
[] = { 'D','A','T','E','\0' };
79 static const WCHAR wszVT_R8
[] = { 'd','o','u','b','l','e','\0' };
80 static const WCHAR wszVT_SAFEARRAY
[] = { 'S','A','F','E','A','R','R','A','Y','\0' };
82 static const WCHAR wszFormat
[] = { '0','x','%','.','8','l','x','\0' };
83 static const WCHAR wszStdCall
[] = { '_','s','t','d','c','a','l','l','\0' };
84 static const WCHAR wszId
[] = { 'i','d','\0' };
85 static const WCHAR wszHelpstring
[] = { 'h','e','l','p','s','t','r','i','n','g','\0' };
86 static const WCHAR wszPropPut
[] = { 'p','r','o','p','p','u','t','\0' };
87 static const WCHAR wszPropGet
[] = { 'p','r','o','p','g','e','t','\0' };
88 static const WCHAR wszPropPutRef
[] = { 'p','r','o','p','p','u','t','r','e','f','\0' };
89 static const WCHAR wszPARAMFLAG_FIN
[] = { 'i','n','\0' };
90 static const WCHAR wszPARAMFLAG_FOUT
[] = { 'o','u','t','\0' };
91 static const WCHAR wszPARAMFLAG_FLCID
[] = { 'c','i','d','\0' };
92 static const WCHAR wszPARAMFLAG_FRETVAL
[] = { 'r','e','t','v','a','l','\0' };
93 static const WCHAR wszPARAMFLAG_FOPT
[] = { 'o','p','t','i','o','n','a','l','\0' };
94 static const WCHAR wszPARAMFLAG_FHASCUSTDATA
[]
95 = { 'h','a','s','c','u','s','t','d','a','t','a','\0' };
96 static const WCHAR wszDefaultValue
[]
97 = { 'd','e','f','a','u','l','t','v','a','l','u','e','\0' };
99 static const WCHAR wszReadOnly
[] = { 'r','e','a','d','o','n','l','y','\0' };
100 static const WCHAR wszConst
[] = { 'c','o','n','s','t','\0' };
102 static void ShowLastError(void)
104 DWORD error
= GetLastError();
106 WCHAR wszTitle
[MAX_LOAD_STRING
];
108 LoadStringW(globals
.hMainInst
, IDS_TYPELIBTITLE
, wszTitle
,
109 sizeof(wszTitle
)/sizeof(wszTitle
[0]));
110 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
111 NULL
, error
, 0, (LPWSTR
)&lpMsgBuf
, 0, NULL
);
112 MessageBoxW(NULL
, lpMsgBuf
, wszTitle
, MB_OK
| MB_ICONERROR
);
117 static void SaveIdl(WCHAR
*wszFileName
)
122 DWORD len
, dwNumWrite
;
126 hIDL
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
127 TVGN_CHILD
, (LPARAM
)TVI_ROOT
);
129 memset(&tvi
, 0, sizeof(TVITEMW
));
132 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
133 data
= (TYPELIB_DATA
*)tvi
.lParam
;
135 hFile
= CreateFileW(wszFileName
, GENERIC_WRITE
, FILE_SHARE_WRITE
,
136 NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
137 if(hFile
== INVALID_HANDLE_VALUE
)
143 len
= WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, NULL
, 0, NULL
, NULL
);
144 wszIdl
= HeapAlloc(GetProcessHeap(), 0, len
);
145 WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, wszIdl
, len
, NULL
, NULL
);
147 if(!WriteFile(hFile
, wszIdl
, len
, &dwNumWrite
, NULL
))
150 HeapFree(GetProcessHeap(), 0, wszIdl
);
154 static void GetSaveIdlAsPath(void)
156 OPENFILENAMEW saveidl
;
158 WCHAR wszPath
[MAX_LOAD_STRING
];
159 WCHAR wszDir
[MAX_LOAD_STRING
];
160 static const WCHAR wszDefaultExt
[] = { 'i','d','l',0 };
161 static const WCHAR wszIdlFiles
[] = { '*','.','i','d','l','\0','\0' };
163 memset(&saveidl
, 0, sizeof(saveidl
));
165 lstrcpyW(wszDir
, typelib
.wszFileName
);
166 pFileName
= wszDir
+ lstrlenW(wszDir
);
167 while(*pFileName
!= '.' && *pFileName
!= '\\' && *pFileName
!= '/'
168 && pFileName
> wszDir
) pFileName
-= 1;
169 if(*pFileName
== '.')
172 while(*pFileName
!= '\\' && *pFileName
!= '/' && pFileName
> wszDir
)
175 if(*pFileName
== '\\' || *pFileName
== '/') pFileName
+= 1;
176 lstrcpyW(wszPath
, pFileName
);
178 GetCurrentDirectoryW(MAX_LOAD_STRING
, wszDir
);
180 saveidl
.lStructSize
= sizeof(OPENFILENAMEW
);
181 saveidl
.hwndOwner
= globals
.hTypeLibWnd
;
182 saveidl
.hInstance
= globals
.hMainInst
;
183 saveidl
.lpstrFilter
= wszIdlFiles
;
184 saveidl
.lpstrFile
= wszPath
;
185 saveidl
.nMaxFile
= MAX_LOAD_STRING
;
186 saveidl
.lpstrInitialDir
= wszDir
;
187 saveidl
.Flags
= OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
| OFN_HIDEREADONLY
;
188 saveidl
.lpstrDefExt
= wszDefaultExt
;
190 if (GetSaveFileNameW(&saveidl
))
194 static void AddToStrW(WCHAR
*wszDest
, const WCHAR
*wszSource
)
196 lstrcpyW(&wszDest
[lstrlenW(wszDest
)], wszSource
);
199 static void AddToTLDataStrW(TYPELIB_DATA
*pTLData
, const WCHAR
*wszSource
)
201 int SourceLen
= lstrlenW(wszSource
);
203 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
204 sizeof(WCHAR
)*(pTLData
->idlLen
+SourceLen
+1));
206 memcpy(&pTLData
->idl
[pTLData
->idlLen
], wszSource
, sizeof(WCHAR
)*(SourceLen
+1));
207 pTLData
->idlLen
+= SourceLen
;
210 static void AddToTLDataStrWithTabsW(TYPELIB_DATA
*pTLData
, WCHAR
*wszSource
)
212 int lineLen
= lstrlenW(wszSource
);
214 WCHAR
*pSourcePos
= wszSource
;
220 if(*pSourcePos
== *wszNewLine
) newLinesNo
++;
223 if(*(pSourcePos
- 1) != *wszNewLine
) newLinesNo
++;
225 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
226 sizeof(WCHAR
)*(pTLData
->idlLen
+lineLen
+4*newLinesNo
+1));
228 pSourcePos
= wszSource
;
229 pSourceBeg
= wszSource
;
232 if(*pSourcePos
!= *wszNewLine
&& *pSourcePos
)
242 lineLen
= lstrlenW(pSourceBeg
)+1;
246 else lineLen
= lstrlenW(pSourceBeg
);
248 pTLData
->idl
[pTLData
->idlLen
] = *wszSpace
;
249 pTLData
->idl
[pTLData
->idlLen
+1] = *wszSpace
;
250 pTLData
->idl
[pTLData
->idlLen
+2] = *wszSpace
;
251 pTLData
->idl
[pTLData
->idlLen
+3] = *wszSpace
;
252 memcpy(&pTLData
->idl
[pTLData
->idlLen
+4], pSourceBeg
, sizeof(WCHAR
)*lineLen
);
253 pTLData
->idlLen
+= lineLen
+ 4;
254 pTLData
->idl
[pTLData
->idlLen
] = '\0';
256 pSourceBeg
= pSourcePos
;
260 static TYPELIB_DATA
*InitializeTLData(void)
262 TYPELIB_DATA
*pTLData
;
264 pTLData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TYPELIB_DATA
));
266 pTLData
->idl
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
));
267 pTLData
->idl
[0] = '\0';
272 static void AddSpaces(TYPELIB_DATA
*pTLData
, int tabSize
)
274 for(; tabSize
>0; tabSize
--)
275 AddToTLDataStrW(pTLData
, wszSpace
);
278 static void AddChildrenData(HTREEITEM hParent
, TYPELIB_DATA
*pData
)
283 memset(&tvi
, 0, sizeof(tvi
));
285 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
286 TVGN_CHILD
, (LPARAM
)hParent
);
292 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
293 if(tvi
.lParam
&& ((TYPELIB_DATA
*)(tvi
.lParam
))->idlLen
)
294 AddToTLDataStrWithTabsW(pData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
295 } while((hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
296 TVGN_NEXT
, (LPARAM
)hCur
)));
299 static void CreateTypeInfo(WCHAR
*wszAddTo
, WCHAR
*wszAddAfter
, TYPEDESC tdesc
, ITypeInfo
*pTypeInfo
)
304 ITypeInfo
*pRefTypeInfo
;
305 WCHAR wszBuf
[MAX_LOAD_STRING
];
306 WCHAR wszFormat
[] = { '[','%','l','u',']','\0' };
308 switch(tdesc
.vt
&VT_TYPEMASK
)
310 #define VTADDTOSTR(x) case x:\
311 AddToStrW(wszAddTo, wsz##x);\
327 VTADDTOSTR(VT_VARIANT
);
329 VTADDTOSTR(VT_ERROR
);
330 VTADDTOSTR(VT_LPSTR
);
331 VTADDTOSTR(VT_LPWSTR
);
332 VTADDTOSTR(VT_HRESULT
);
333 VTADDTOSTR(VT_UNKNOWN
);
334 VTADDTOSTR(VT_DISPATCH
);
338 for(i
=0; i
<U(tdesc
).lpadesc
->cDims
; i
++)
340 wsprintfW(wszBuf
, wszFormat
, U(tdesc
).lpadesc
->rgbounds
[i
].cElements
);
341 AddToStrW(wszAddAfter
, wszBuf
);
343 CreateTypeInfo(wszAddTo
, wszAddAfter
, U(tdesc
).lpadesc
->tdescElem
, pTypeInfo
);
346 AddToStrW(wszAddTo
, wszVT_SAFEARRAY
);
347 AddToStrW(wszAddTo
, wszOpenBrackets2
);
348 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
349 AddToStrW(wszAddTo
, wszCloseBrackets2
);
352 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
353 AddToStrW(wszAddTo
, wszAsterix
);
356 hRes
= ITypeInfo_GetRefTypeInfo(pTypeInfo
,
357 U(tdesc
).hreftype
, &pRefTypeInfo
);
360 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
,
361 &bstrData
, NULL
, NULL
, NULL
);
362 AddToStrW(wszAddTo
, bstrData
);
363 SysFreeString(bstrData
);
364 ITypeInfo_Release(pRefTypeInfo
);
366 else AddToStrW(wszAddTo
, wszFailed
);
369 WINE_FIXME("tdesc.vt&VT_TYPEMASK == %d not supported\n",
370 tdesc
.vt
&VT_TYPEMASK
);
374 static int EnumVars(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
377 TVINSERTSTRUCTW tvis
;
380 WCHAR wszText
[MAX_LOAD_STRING
];
381 WCHAR wszAfter
[MAX_LOAD_STRING
];
383 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
384 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
385 U(tvis
).item
.pszText
= wszText
;
386 tvis
.hInsertAfter
= TVI_LAST
;
387 tvis
.hParent
= hParent
;
389 for(i
=0; i
<cVars
; i
++)
393 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
394 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
395 NULL
, NULL
, NULL
))) continue;
397 tld
= InitializeTLData();
398 U(tvis
).item
.lParam
= (LPARAM
) tld
;
399 if(pVarDesc
->memid
< MIN_VAR_ID
)
402 AddToTLDataStrW(tld
, wszOpenBrackets1
);
403 AddToTLDataStrW(tld
, wszId
);
404 AddToTLDataStrW(tld
, wszOpenBrackets2
);
405 wsprintfW(wszText
, wszFormat
, pVarDesc
->memid
);
406 AddToTLDataStrW(tld
, wszText
);
407 memset(wszText
, 0, sizeof(wszText
));
408 AddToTLDataStrW(tld
, wszCloseBrackets2
);
410 if(pVarDesc
->wVarFlags
& VARFLAG_FREADONLY
)
412 AddToTLDataStrW(tld
, wszComa
);
413 AddToTLDataStrW(tld
, wszSpace
);
414 AddToTLDataStrW(tld
, wszReadOnly
);
416 AddToTLDataStrW(tld
, wszCloseBrackets1
);
417 AddToTLDataStrW(tld
, wszNewLine
);
420 memset(wszText
, 0, sizeof(wszText
));
421 memset(wszAfter
, 0, sizeof(wszAfter
));
422 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
423 AddToStrW(wszText
, wszSpace
);
424 if (bstrName
) AddToStrW(wszText
, bstrName
);
425 AddToStrW(wszText
, wszAfter
);
426 AddToTLDataStrW(tld
, wszText
);
427 AddToTLDataStrW(tld
, wszSemicolon
);
428 AddToTLDataStrW(tld
, wszNewLine
);
430 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
431 SysFreeString(bstrName
);
432 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
438 static int EnumEnums(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
441 TVINSERTSTRUCTW tvis
;
444 WCHAR wszText
[MAX_LOAD_STRING
];
445 WCHAR wszAfter
[MAX_LOAD_STRING
];
447 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
448 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
449 U(tvis
).item
.pszText
= wszText
;
450 tvis
.hInsertAfter
= TVI_LAST
;
451 tvis
.hParent
= hParent
;
453 for(i
=0; i
<cVars
; i
++)
457 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
458 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
459 NULL
, NULL
, NULL
))) continue;
461 tld
= InitializeTLData();
462 U(tvis
).item
.lParam
= (LPARAM
) tld
;
464 memset(wszText
, 0, sizeof(wszText
));
465 memset(wszAfter
, 0, sizeof(wszAfter
));
467 if (pVarDesc
->varkind
== VAR_CONST
)
471 if (VariantChangeType(&var
, U(*pVarDesc
).lpvarValue
, 0, VT_BSTR
) == S_OK
)
473 AddToStrW(wszText
, wszConst
);
474 AddToStrW(wszText
, wszSpace
);
475 AddToStrW(wszAfter
, wszSpace
);
476 AddToStrW(wszAfter
, wszEquals
);
477 AddToStrW(wszAfter
, wszSpace
);
478 AddToStrW(wszAfter
, V_BSTR(&var
));
482 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
483 AddToStrW(wszText
, wszSpace
);
484 AddToStrW(wszText
, bstrName
);
485 AddToStrW(wszText
, wszAfter
);
486 AddToTLDataStrW(tld
, bstrName
);
487 AddToTLDataStrW(tld
, wszAfter
);
489 AddToTLDataStrW(tld
, wszComa
);
490 AddToTLDataStrW(tld
, wszNewLine
);
492 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
493 SysFreeString(bstrName
);
494 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
500 static int EnumFuncs(ITypeInfo
*pTypeInfo
, TYPEATTR
*pTypeAttr
, HTREEITEM hParent
)
505 TVINSERTSTRUCTW tvis
;
507 BSTR bstrName
, bstrHelpString
, *bstrParamNames
;
508 WCHAR wszText
[MAX_LOAD_STRING
];
509 WCHAR wszAfter
[MAX_LOAD_STRING
];
510 WCHAR szRhs
[] = {'r','h','s',0}; /* Right-hand side of a propput */
513 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
514 tvis
.hInsertAfter
= TVI_LAST
;
515 tvis
.hParent
= hParent
;
517 cFuncs
= pTypeAttr
->cFuncs
;
520 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
) { /* skip 7 members of IDispatch */
529 if(FAILED(ITypeInfo_GetFuncDesc(pTypeInfo
, i
, &pFuncDesc
))) continue;
531 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pFuncDesc
->memid
, &bstrName
,
532 &bstrHelpString
, NULL
, NULL
))) continue;
534 memset(wszText
, 0, sizeof(wszText
));
535 memset(wszAfter
, 0, sizeof(wszAfter
));
536 tld
= InitializeTLData();
537 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
538 U(tvis
).item
.pszText
= bstrName
;
539 U(tvis
).item
.lParam
= (LPARAM
) tld
;
541 if(pFuncDesc
->memid
< MIN_FUNC_ID
|| pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
543 AddToTLDataStrW(tld
, wszOpenBrackets1
);
545 AddToTLDataStrW(tld
, wszId
);
546 AddToTLDataStrW(tld
, wszOpenBrackets2
);
547 wsprintfW(wszText
, wszFormat
, pFuncDesc
->memid
);
548 AddToTLDataStrW(tld
, wszText
);
549 AddToTLDataStrW(tld
, wszCloseBrackets2
);
550 memset(wszText
, 0, sizeof(wszText
));
553 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->elemdescFunc
.tdesc
, pTypeInfo
);
554 switch(pFuncDesc
->invkind
)
556 case INVOKE_PROPERTYGET
:
557 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
560 AddToTLDataStrW(tld
, wszComa
);
561 AddToTLDataStrW(tld
, wszSpace
);
564 AddToTLDataStrW(tld
, wszPropGet
);
566 case INVOKE_PROPERTYPUT
:
567 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
570 AddToTLDataStrW(tld
, wszComa
);
571 AddToTLDataStrW(tld
, wszSpace
);
574 AddToTLDataStrW(tld
, wszPropPut
);
576 case INVOKE_PROPERTYPUTREF
:
577 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
580 AddToTLDataStrW(tld
, wszComa
);
581 AddToTLDataStrW(tld
, wszSpace
);
584 AddToTLDataStrW(tld
, wszPropPutRef
);
588 if(SysStringLen(bstrHelpString
))
590 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
593 AddToTLDataStrW(tld
, wszComa
);
594 AddToTLDataStrW(tld
, wszSpace
);
597 AddToTLDataStrW(tld
, wszHelpstring
);
598 AddToTLDataStrW(tld
, wszOpenBrackets2
);
599 AddToTLDataStrW(tld
, wszInvertedComa
);
600 AddToTLDataStrW(tld
, bstrHelpString
);
601 AddToTLDataStrW(tld
, wszInvertedComa
);
602 AddToTLDataStrW(tld
, wszCloseBrackets2
);
606 AddToTLDataStrW(tld
, wszCloseBrackets1
);
607 AddToTLDataStrW(tld
, wszNewLine
);
610 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FOLEAUTOMATION
) {
611 AddToTLDataStrW(tld
, wszVT_HRESULT
);
612 if(strcmpW(wszText
, wszVT_VOID
)) pFuncDesc
->cParams
++;
615 AddToTLDataStrW(tld
, wszText
);
616 AddToTLDataStrW(tld
, wszAfter
);
619 bstrParamNames
= HeapAlloc(GetProcessHeap(), 0,
620 sizeof(BSTR
*)*(pFuncDesc
->cParams
+1));
621 if(FAILED(ITypeInfo_GetNames(pTypeInfo
, pFuncDesc
->memid
, bstrParamNames
,
622 pFuncDesc
->cParams
+1, &namesNo
)))
624 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
627 SysFreeString(bstrParamNames
[0]);
629 AddToTLDataStrW(tld
, wszSpace
);
630 if(pFuncDesc
->memid
>= MIN_FUNC_ID
)
632 AddToTLDataStrW(tld
, wszStdCall
);
633 AddToTLDataStrW(tld
, wszSpace
);
635 if (bstrName
) AddToTLDataStrW(tld
, bstrName
);
636 AddToTLDataStrW(tld
, wszOpenBrackets2
);
638 for(j
=0; j
<pFuncDesc
->cParams
; j
++)
640 if(j
!= 0) AddToTLDataStrW(tld
, wszComa
);
641 if(pFuncDesc
->cParams
!= 1)
643 AddToTLDataStrW(tld
, wszNewLine
);
644 AddSpaces(tld
, TAB_SIZE
);
647 #define ENUM_PARAM_FLAG(x)\
648 if(U(pFuncDesc->lprgelemdescParam[j]).paramdesc.wParamFlags & x) \
650 if(bFirst) AddToTLDataStrW(tld,\
654 AddToTLDataStrW(tld, wszComa);\
655 AddToTLDataStrW(tld, wszSpace);\
658 AddToTLDataStrW(tld, wsz##x);\
660 ENUM_PARAM_FLAG(PARAMFLAG_FIN
);
661 ENUM_PARAM_FLAG(PARAMFLAG_FOUT
);
662 ENUM_PARAM_FLAG(PARAMFLAG_FLCID
);
663 ENUM_PARAM_FLAG(PARAMFLAG_FRETVAL
);
664 ENUM_PARAM_FLAG(PARAMFLAG_FOPT
);
665 ENUM_PARAM_FLAG(PARAMFLAG_FHASCUSTDATA
);
667 if(U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
669 VARIANT var
, *param
=&U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.pparamdescex
->varDefaultValue
;
671 if(bFirst
) AddToTLDataStrW(tld
,
675 AddToTLDataStrW(tld
, wszComa
);
676 AddToTLDataStrW(tld
, wszSpace
);
679 AddToTLDataStrW(tld
, wszDefaultValue
);
680 AddToTLDataStrW(tld
, wszOpenBrackets2
);
681 if (V_VT(param
) == VT_BSTR
)
683 AddToTLDataStrW(tld
, wszInvertedComa
);
684 AddToTLDataStrW(tld
, V_BSTR(param
));
685 AddToTLDataStrW(tld
, wszInvertedComa
);
686 } else if (VariantChangeType(&var
, param
, 0, VT_BSTR
) == S_OK
)
687 AddToTLDataStrW(tld
, V_BSTR(&var
));
688 AddToTLDataStrW(tld
, wszCloseBrackets2
);
693 AddToTLDataStrW(tld
, wszCloseBrackets1
);
694 AddToTLDataStrW(tld
, wszSpace
);
697 memset(wszText
, 0, sizeof(wszText
));
698 memset(wszAfter
, 0, sizeof(wszAfter
));
699 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->lprgelemdescParam
[j
].tdesc
,
701 AddToTLDataStrW(tld
, wszText
);
702 AddToTLDataStrW(tld
, wszAfter
);
703 AddToTLDataStrW(tld
, wszSpace
);
705 if (bstrParamNames
[j
+1])
707 AddToTLDataStrW(tld
, bstrParamNames
[j
+1]);
708 SysFreeString(bstrParamNames
[j
+1]);
711 AddToTLDataStrW(tld
, szRhs
);
714 AddToTLDataStrW(tld
, wszCloseBrackets2
);
715 AddToTLDataStrW(tld
, wszSemicolon
);
716 AddToTLDataStrW(tld
, wszNewLine
);
718 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
719 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
720 SysFreeString(bstrName
);
721 SysFreeString(bstrHelpString
);
722 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, pFuncDesc
);
728 static int EnumImplTypes(ITypeInfo
*pTypeInfo
, int cImplTypes
, HTREEITEM hParent
)
731 TVINSERTSTRUCTW tvis
;
732 ITypeInfo
*pRefTypeInfo
;
736 WCHAR wszInheritedInterfaces
[MAX_LOAD_STRING
];
738 if(!cImplTypes
) return 0;
740 LoadStringW(globals
.hMainInst
, IDS_INHERITINTERFACES
, wszInheritedInterfaces
,
741 sizeof(wszInheritedInterfaces
)/sizeof(wszInheritedInterfaces
[0]));
743 U(tvis
).item
.mask
= TVIF_TEXT
;
744 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
745 U(tvis
).item
.pszText
= wszInheritedInterfaces
;
746 tvis
.hInsertAfter
= TVI_LAST
;
747 tvis
.hParent
= hParent
;
749 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
751 for(i
=0; i
<cImplTypes
; i
++)
753 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
754 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
756 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
759 ITypeInfo_Release(pRefTypeInfo
);
762 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
764 ITypeInfo_Release(pRefTypeInfo
);
768 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
769 U(tvis
).item
.pszText
= bstrName
;
771 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
772 EnumVars(pRefTypeInfo
, pTypeAttr
->cVars
, hParent
);
773 EnumFuncs(pRefTypeInfo
, pTypeAttr
, hParent
);
774 EnumImplTypes(pRefTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
776 SysFreeString(bstrName
);
777 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
778 ITypeInfo_Release(pRefTypeInfo
);
784 static void EnumCoclassImplTypes(ITypeInfo
*pTypeInfo
,
785 int cImplTypes
, TYPELIB_DATA
*pTLData
)
788 ITypeInfo
*pRefTypeInfo
;
794 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
795 const WCHAR wszTKIND_DISPATCH
[]
796 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
797 const WCHAR wszIMPLTYPEFLAG_FDEFAULT
[]
798 = { 'd','e','f','a','u','l','t','\0' };
799 const WCHAR wszIMPLTYPEFLAG_FSOURCE
[]
800 = { 's','o','u','r','c','e','\0' };
801 const WCHAR wszIMPLTYPEFLAG_FRESTRICTED
[]
802 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
804 for(i
=0; i
<cImplTypes
; i
++)
806 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
807 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
809 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
812 ITypeInfo_Release(pRefTypeInfo
);
815 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
817 ITypeInfo_Release(pRefTypeInfo
);
821 AddSpaces(pTLData
, TAB_SIZE
);
822 ITypeInfo_GetImplTypeFlags(pTypeInfo
, i
, &flags
);
824 #define ENUM_IMPLTYPEFLAG(x)\
827 if(bFirst) AddToTLDataStrW(pTLData,\
831 AddToTLDataStrW(pTLData, wszComa);\
832 AddToTLDataStrW(pTLData, wszSpace);\
835 AddToTLDataStrW(pTLData, wsz##x);\
837 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FDEFAULT
);
838 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FSOURCE
);
839 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FRESTRICTED
);
842 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
843 AddToTLDataStrW(pTLData
, wszSpace
);
846 if(pTypeAttr
->typekind
== TKIND_INTERFACE
||
847 (pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
))
848 AddToTLDataStrW(pTLData
, wszTKIND_INTERFACE
);
849 else if(pTypeAttr
->typekind
== TKIND_DISPATCH
)
850 AddToTLDataStrW(pTLData
, wszTKIND_DISPATCH
);
851 AddToTLDataStrW(pTLData
, wszSpace
);
853 AddToTLDataStrW(pTLData
, bstrName
);
854 AddToTLDataStrW(pTLData
, wszSemicolon
);
855 AddToTLDataStrW(pTLData
, wszNewLine
);
857 SysFreeString(bstrName
);
858 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
859 ITypeInfo_Release(pRefTypeInfo
);
863 static void AddIdlData(HTREEITEM hCur
, TYPELIB_DATA
*pTLData
)
867 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
868 TVGN_CHILD
, (LPARAM
)hCur
);
869 memset(&tvi
, 0, sizeof(TVITEMW
));
870 tvi
.mask
= TVIF_PARAM
;
875 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
876 if(!((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
) {
877 AddToTLDataStrW(pTLData
, wszNewLine
);
878 AddToTLDataStrWithTabsW(pTLData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
880 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
881 TVGN_NEXT
, (LPARAM
)hCur
);
885 static void AddPredefinitions(HTREEITEM hFirst
, TYPELIB_DATA
*pTLData
)
889 WCHAR wszText
[MAX_LOAD_STRING
];
890 WCHAR wszPredefinition
[] = { '/','/',' ','T','L','i','b',' ',':','\n',
891 '/','/',' ','F','o','r','w','a','r','d',' ','d','e','c','l','a','r','e',' ',
892 'a','l','l',' ','t','y','p','e','s',' ','d','e','f','i','n','e','d',' ',
893 'i','n',' ','t','h','i','s',' ','t','y','p','e','l','i','b','\0' };
895 hFirst
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
896 TVGN_CHILD
, (LPARAM
)hFirst
);
898 AddToTLDataStrWithTabsW(pTLData
, wszPredefinition
);
899 AddToTLDataStrW(pTLData
, wszNewLine
);
902 memset(&tvi
, 0, sizeof(TVITEMW
));
903 tvi
.mask
= TVIF_TEXT
|TVIF_PARAM
;
904 tvi
.cchTextMax
= MAX_LOAD_STRING
;
905 tvi
.pszText
= wszText
;
909 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
910 if(((TYPELIB_DATA
*)(tvi
.lParam
))->bPredefine
&&
911 !((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
)
913 AddToStrW(wszText
, wszSemicolon
);
914 AddToTLDataStrWithTabsW(pTLData
, wszText
);
915 AddToTLDataStrW(pTLData
, wszNewLine
);
917 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
918 TVGN_NEXT
, (LPARAM
)hCur
);
922 static void CreateInterfaceInfo(ITypeInfo
*pTypeInfo
, int cImplTypes
, WCHAR
*wszName
,
923 WCHAR
*wszHelpString
, ULONG ulHelpContext
, TYPEATTR
*pTypeAttr
,
924 TYPELIB_DATA
*pTLData
)
926 ITypeInfo
*pRefTypeInfo
;
929 WCHAR wszGuid
[MAX_LOAD_STRING
];
930 WCHAR wszHelpContext
[MAX_LOAD_STRING
];
932 const WCHAR wszInterface
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
933 const WCHAR wszDispinterface
[]
934 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
935 const WCHAR wszHelpcontext
[] = { 'h','e','l','p','c','o','n','t','e','x','t','\0' };
936 const WCHAR wszTYPEFLAG_FAPPOBJECT
[] = { 'a','p','p','o','b','j','e','c','t','\0' };
937 const WCHAR wszTYPEFLAG_FCANCREATE
[] = { 'c','a','n','c','r','e','a','t','e','\0' };
938 const WCHAR wszTYPEFLAG_FLICENSED
[] = { 'l','i','c','e','n','s','e','d','\0' };
939 const WCHAR wszTYPEFLAG_FPREDECLID
[] = { 'p','r','e','d','e','c','l','i','d','\0' };
940 const WCHAR wszTYPEFLAG_FHIDDEN
[] = { 'h','i','d','d','e','n','\0' };
941 const WCHAR wszTYPEFLAG_FCONTROL
[] = { 'c','o','n','t','r','o','l','\0' };
942 const WCHAR wszTYPEFLAG_FDUAL
[] = { 'd','u','a','l','\0' };
943 const WCHAR wszTYPEFLAG_FNONEXTENSIBLE
[]
944 = { 'n','o','n','e','x','t','e','n','s','i','b','l','e','\0' };
945 const WCHAR wszTYPEFLAG_FOLEAUTOMATION
[]
946 = { 'o','l','e','a','u','t','o','m','a','t','i','o','n','\0' };
947 const WCHAR wszTYPEFLAG_FRESTRICTED
[]
948 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
949 const WCHAR wszTYPEFLAG_FAGGREGATABLE
[]
950 = { 'a','g','g','r','e','g','a','t','a','b','l','e','\0' };
951 const WCHAR wszTYPEFLAG_FREPLACEABLE
[]
952 = { 'r','e','p','l','a','c','a','b','l','e','\0' };
953 const WCHAR wszTYPEFLAG_FREVERSEBIND
[]
954 = { 'r','e','v','e','r','s','e','b','i','n','d','\0' };
955 const WCHAR wszTYPEFLAG_FPROXY
[] = { 'p','r','o','x','y','\0' };
957 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
958 AddToTLDataStrW(pTLData
, wszNewLine
);
959 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
)
961 AddSpaces(pTLData
, TAB_SIZE
);
962 AddToTLDataStrW(pTLData
, wszOdl
);
963 AddToTLDataStrW(pTLData
, wszComa
);
964 AddToTLDataStrW(pTLData
, wszNewLine
);
966 AddSpaces(pTLData
, TAB_SIZE
);
967 AddToTLDataStrW(pTLData
, wszUUID
);
968 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
969 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
970 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
971 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
972 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
975 AddToTLDataStrW(pTLData
, wszComa
);
976 AddToTLDataStrW(pTLData
, wszNewLine
);
977 AddSpaces(pTLData
, TAB_SIZE
);
978 AddToTLDataStrW(pTLData
, wszHelpstring
);
979 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
980 AddToTLDataStrW(pTLData
, wszInvertedComa
);
981 AddToTLDataStrW(pTLData
, wszHelpString
);
982 AddToTLDataStrW(pTLData
, wszInvertedComa
);
983 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
987 AddToTLDataStrW(pTLData
, wszComa
);
988 AddToTLDataStrW(pTLData
, wszNewLine
);
989 AddSpaces(pTLData
, TAB_SIZE
);
990 AddToTLDataStrW(pTLData
, wszHelpcontext
);
991 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
992 wsprintfW(wszHelpContext
, wszFormat
, ulHelpContext
);
993 AddToTLDataStrW(pTLData
, wszHelpContext
);
994 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
996 if(pTypeAttr
->wTypeFlags
)
998 #define ENUM_FLAGS(x) if(pTypeAttr->wTypeFlags & x)\
1000 AddToTLDataStrW(pTLData, wszComa);\
1001 AddToTLDataStrW(pTLData, wszNewLine);\
1002 AddSpaces(pTLData, TAB_SIZE);\
1003 AddToTLDataStrW(pTLData, wsz##x);\
1005 ENUM_FLAGS(TYPEFLAG_FAPPOBJECT
);
1006 ENUM_FLAGS(TYPEFLAG_FCANCREATE
);
1007 ENUM_FLAGS(TYPEFLAG_FLICENSED
);
1008 ENUM_FLAGS(TYPEFLAG_FPREDECLID
);
1009 ENUM_FLAGS(TYPEFLAG_FHIDDEN
);
1010 ENUM_FLAGS(TYPEFLAG_FCONTROL
);
1011 ENUM_FLAGS(TYPEFLAG_FDUAL
);
1012 ENUM_FLAGS(TYPEFLAG_FNONEXTENSIBLE
);
1013 ENUM_FLAGS(TYPEFLAG_FOLEAUTOMATION
);
1014 ENUM_FLAGS(TYPEFLAG_FRESTRICTED
);
1015 ENUM_FLAGS(TYPEFLAG_FAGGREGATABLE
);
1016 ENUM_FLAGS(TYPEFLAG_FREPLACEABLE
);
1017 ENUM_FLAGS(TYPEFLAG_FREVERSEBIND
);
1018 ENUM_FLAGS(TYPEFLAG_FPROXY
);
1020 AddToTLDataStrW(pTLData
, wszNewLine
);
1021 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1022 AddToTLDataStrW(pTLData
, wszNewLine
);
1023 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
) AddToTLDataStrW(pTLData
, wszInterface
);
1024 else AddToTLDataStrW(pTLData
, wszDispinterface
);
1025 AddToTLDataStrW(pTLData
, wszName
);
1026 AddToTLDataStrW(pTLData
, wszSpace
);
1027 if(cImplTypes
&& pTypeAttr
->typekind
!= TKIND_DISPATCH
)
1029 AddToTLDataStrW(pTLData
, wszColon
);
1030 AddToTLDataStrW(pTLData
, wszSpace
);
1032 ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, 0, &hRefType
);
1033 if (SUCCEEDED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
1035 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1037 AddToTLDataStrW(pTLData
, bstrName
);
1038 AddToTLDataStrW(pTLData
, wszSpace
);
1040 SysFreeString(bstrName
);
1041 ITypeInfo_Release(pRefTypeInfo
);
1044 AddToTLDataStrW(pTLData
, wszFailed
);
1046 AddToTLDataStrW(pTLData
, wszOpenBrackets3
);
1047 AddToTLDataStrW(pTLData
, wszNewLine
);
1049 AddToStrW(pTLData
->wszInsertAfter
, wszCloseBrackets3
);
1050 AddToStrW(pTLData
->wszInsertAfter
, wszSemicolon
);
1051 AddToStrW(pTLData
->wszInsertAfter
, wszNewLine
);
1054 static void CreateTypedefHeader(ITypeInfo
*pTypeInfo
,
1055 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1058 WCHAR wszGuid
[MAX_LOAD_STRING
];
1059 const WCHAR wszTypedef
[] = { 't','y','p','e','d','e','f',' ','\0' };
1060 const WCHAR wszPublic
[] = { 'p','u','b','l','i','c','\0' };
1062 AddToTLDataStrW(pTLData
, wszTypedef
);
1063 if(memcmp(&pTypeAttr
->guid
, &GUID_NULL
, sizeof(GUID
)))
1065 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1067 AddToTLDataStrW(pTLData
, wszUUID
);
1068 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1069 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1070 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1071 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1072 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1074 if(pTypeAttr
->typekind
== TKIND_ALIAS
)
1076 if(bFirst
) AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1079 AddToTLDataStrW(pTLData
, wszComa
);
1080 AddToTLDataStrW(pTLData
, wszSpace
);
1083 AddToTLDataStrW(pTLData
, wszPublic
);
1087 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1088 AddToTLDataStrW(pTLData
, wszNewLine
);
1092 static void CreateCoclassHeader(ITypeInfo
*pTypeInfo
,
1093 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1095 WCHAR wszGuid
[MAX_LOAD_STRING
];
1096 BSTR bstrHelpString
;
1097 const WCHAR wszNoncreatable
[]
1098 = { 'n','o','n','c','r','e','a','t','a','b','l','e','\0' };
1100 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1101 AddToTLDataStrW(pTLData
, wszNewLine
);
1103 AddSpaces(pTLData
, TAB_SIZE
);
1104 AddToTLDataStrW(pTLData
, wszUUID
);
1105 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1106 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1107 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1108 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1109 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1111 if(SUCCEEDED(ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, NULL
,
1112 &bstrHelpString
, NULL
, NULL
)))
1114 if(SysStringLen(bstrHelpString
))
1116 AddToTLDataStrW(pTLData
, wszComa
);
1117 AddToTLDataStrW(pTLData
, wszNewLine
);
1118 AddSpaces(pTLData
, TAB_SIZE
);
1119 AddToTLDataStrW(pTLData
, wszHelpstring
);
1120 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1121 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1122 AddToTLDataStrW(pTLData
, bstrHelpString
);
1123 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1124 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1126 SysFreeString(bstrHelpString
);
1129 if(!(pTypeAttr
->wTypeFlags
& TYPEFLAG_FCANCREATE
))
1131 AddToTLDataStrW(pTLData
, wszComa
);
1132 AddToTLDataStrW(pTLData
, wszNewLine
);
1133 AddSpaces(pTLData
, TAB_SIZE
);
1134 AddToTLDataStrW(pTLData
, wszNoncreatable
);
1137 AddToTLDataStrW(pTLData
, wszNewLine
);
1138 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1139 AddToTLDataStrW(pTLData
, wszNewLine
);
1142 static int PopulateTree(void)
1144 TVINSERTSTRUCTW tvis
;
1147 TLIBATTR
*pTLibAttr
;
1148 ITypeInfo
*pTypeInfo
, *pRefTypeInfo
;
1150 TYPEATTR
*pTypeAttr
;
1152 ULONG ulHelpContext
;
1155 WCHAR wszText
[MAX_LOAD_STRING
];
1156 WCHAR wszAfter
[MAX_LOAD_STRING
];
1161 TYPELIB_DATA
*tldDispatch
;
1164 const WCHAR wszGeneratedInfo
[] = { '/','/',' ','G','e','n','e','r','a','t','e','d',
1165 ' ','.','I','D','L',' ','f','i','l','e',' ','(','b','y',' ','t','h','e',' ',
1166 'O','L','E','/','C','O','M',' ','O','b','j','e','c','t',' ',
1167 'V','i','e','w','e','r',')','\n','/','/','\n','/','/',' ',
1168 't','y','p','e','l','i','b',' ','f','i','l','e','n','a','m','e',':',' ','\0'};
1170 const WCHAR wszFormat
[] = { '%','s',' ','(','%','s',')','\0' };
1171 const WCHAR wszFormat2
[] = { 'v','e','r','s','i','o','n',
1172 '(','%','l','d','.','%','l','d',')','\0' };
1174 const WCHAR wszTKIND_ENUM
[] = { 't','y','p','e','d','e','f',' ','e','n','u','m',' ','\0' };
1175 const WCHAR wszTKIND_RECORD
[]
1176 = { 't','y','p','e','d','e','f',' ','s','t','r','u','c','t',' ','\0' };
1177 const WCHAR wszTKIND_MODULE
[] = { 'm','o','d','u','l','e',' ','\0' };
1178 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
1179 const WCHAR wszTKIND_DISPATCH
[]
1180 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
1181 const WCHAR wszTKIND_COCLASS
[] = { 'c','o','c','l','a','s','s',' ','\0' };
1182 const WCHAR wszTKIND_ALIAS
[] = { 't','y','p','e','d','e','f',' ','\0' };
1183 const WCHAR wszTKIND_UNION
[]
1184 = { 't','y','p','e','d','e','f',' ','u','n','i','o','n',' ','\0' };
1186 const WCHAR wszLibrary
[] = { 'l','i','b','r','a','r','y',' ','\0' };
1187 const WCHAR wszTag
[] = { 't','a','g','\0' };
1189 WCHAR wszProperties
[] = { 'p','r','o','p','e','r','t','i','e','s','\0' };
1190 WCHAR wszMethods
[] = { 'm','e','t','h','o','d','s','\0' };
1192 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
1193 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
1194 U(tvis
).item
.pszText
= wszText
;
1195 tvis
.hInsertAfter
= TVI_LAST
;
1196 tvis
.hParent
= TVI_ROOT
;
1198 if(FAILED((hRes
= LoadTypeLib(typelib
.wszFileName
, &pTypeLib
))))
1200 WCHAR wszMessage
[MAX_LOAD_STRING
];
1201 WCHAR wszError
[MAX_LOAD_STRING
];
1204 LoadStringW(globals
.hMainInst
, IDS_ERROR_LOADTYPELIB
,
1205 wszError
, sizeof(wszError
)/sizeof(wszError
[0]));
1206 args
[0] = (DWORD_PTR
)typelib
.wszFileName
;
1208 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1209 wszError
, 0, 0, wszMessage
, sizeof(wszMessage
)/sizeof(*wszMessage
), (__ms_va_list
*)args
);
1210 MessageBoxW(globals
.hMainWnd
, wszMessage
, NULL
, MB_OK
|MB_ICONEXCLAMATION
);
1213 count
= ITypeLib_GetTypeInfoCount(pTypeLib
);
1215 ITypeLib_GetDocumentation(pTypeLib
, -1, &bstrName
, &bstrData
, NULL
, NULL
);
1216 ITypeLib_GetLibAttr(pTypeLib
, &pTLibAttr
);
1218 tld
= InitializeTLData();
1219 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1220 AddToTLDataStrW(tld
, wszGeneratedInfo
);
1221 AddToTLDataStrW(tld
, typelib
.wszFileName
);
1222 AddToTLDataStrW(tld
, wszNewLine
);
1223 AddToTLDataStrW(tld
, wszNewLine
);
1224 AddToTLDataStrW(tld
, wszOpenBrackets1
);
1225 AddToTLDataStrW(tld
, wszNewLine
);
1226 AddSpaces(tld
, TAB_SIZE
);
1227 AddToTLDataStrW(tld
, wszUUID
);
1228 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1229 StringFromGUID2(&(pTLibAttr
->guid
), wszText
, MAX_LOAD_STRING
);
1230 wszText
[lstrlenW(wszText
)-1] = '\0';
1231 AddToTLDataStrW(tld
, &wszText
[1]);
1232 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1233 AddToTLDataStrW(tld
, wszComa
);
1234 AddToTLDataStrW(tld
, wszNewLine
);
1235 AddSpaces(tld
, TAB_SIZE
);
1236 wsprintfW(wszText
, wszFormat2
, pTLibAttr
->wMajorVerNum
, pTLibAttr
->wMinorVerNum
);
1237 AddToTLDataStrW(tld
, wszText
);
1241 /* helpstring is optional */
1242 AddToTLDataStrW(tld
, wszComa
);
1243 AddToTLDataStrW(tld
, wszNewLine
);
1244 AddSpaces(tld
, TAB_SIZE
);
1245 AddToTLDataStrW(tld
, wszHelpstring
);
1246 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1247 AddToTLDataStrW(tld
, wszInvertedComa
);
1248 AddToTLDataStrW(tld
, bstrData
);
1249 AddToTLDataStrW(tld
, wszInvertedComa
);
1250 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1253 AddToTLDataStrW(tld
, wszNewLine
);
1254 AddToTLDataStrW(tld
, wszCloseBrackets1
);
1255 AddToTLDataStrW(tld
, wszNewLine
);
1256 AddToTLDataStrW(tld
, wszLibrary
);
1257 if (bstrName
) AddToTLDataStrW(tld
, bstrName
);
1258 AddToTLDataStrW(tld
, wszNewLine
);
1259 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1260 AddToTLDataStrW(tld
, wszNewLine
);
1262 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1263 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1265 wsprintfW(wszText
, wszFormat
, bstrName
, bstrData
);
1266 SysFreeString(bstrName
);
1267 SysFreeString(bstrData
);
1268 tvis
.hParent
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1269 TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
1271 for(i
=0; i
<count
; i
++)
1274 ITypeLib_GetTypeInfo(pTypeLib
, i
, &pTypeInfo
);
1276 ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, &bstrName
, &bstrData
,
1277 &ulHelpContext
, NULL
);
1278 ITypeInfo_GetTypeAttr(pTypeInfo
, &pTypeAttr
);
1280 memset(wszText
, 0, sizeof(wszText
));
1281 memset(wszAfter
, 0, sizeof(wszAfter
));
1282 tld
= InitializeTLData();
1283 U(tvis
).item
.lParam
= (LPARAM
)tld
;
1284 switch(pTypeAttr
->typekind
)
1287 AddToStrW(wszText
, wszTKIND_ENUM
);
1288 AddToStrW(wszText
, bstrName
);
1290 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1291 AddToTLDataStrW(tld
, &wszTKIND_ENUM
[lstrlenW(wszTKIND_ALIAS
)]);
1292 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1293 AddToTLDataStrW(tld
,wszNewLine
);
1294 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1295 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1296 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1297 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1298 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1301 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1302 EnumEnums(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1303 AddChildrenData(hParent
, tld
);
1304 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1307 AddToTLDataStrW(tld
, wszTKIND_RECORD
);
1308 AddToTLDataStrW(tld
, wszTag
);
1309 AddToTLDataStrW(tld
, bstrName
);
1310 AddToTLDataStrW(tld
, wszSpace
);
1311 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1312 AddToTLDataStrW(tld
, wszNewLine
);
1314 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1315 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1316 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1317 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1318 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1320 AddToStrW(wszText
, wszTKIND_RECORD
);
1321 AddToStrW(wszText
, bstrName
);
1324 AddToStrW(wszText
, wszTKIND_MODULE
);
1325 AddToStrW(wszText
, bstrName
);
1327 case TKIND_INTERFACE
:
1328 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1329 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1330 tld
->bPredefine
= TRUE
;
1332 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1333 AddToStrW(wszText
, bstrName
);
1336 AddToStrW(wszText
, wszTKIND_COCLASS
);
1337 AddToStrW(wszText
, bstrName
);
1339 CreateCoclassHeader(pTypeInfo
, pTypeAttr
, tld
);
1340 AddToTLDataStrW(tld
, wszTKIND_COCLASS
);
1341 AddToTLDataStrW(tld
, bstrName
);
1342 AddToTLDataStrW(tld
, wszSpace
);
1343 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1344 AddToTLDataStrW(tld
, wszNewLine
);
1346 EnumCoclassImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, tld
);
1348 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1349 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1350 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1353 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1354 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1357 AddToStrW(wszText
, wszTKIND_UNION
);
1358 AddToStrW(wszText
, bstrName
);
1360 case TKIND_DISPATCH
:
1361 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1362 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1363 tld
->bPredefine
= TRUE
;
1364 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
1366 AddToStrW(wszText
, wszTKIND_DISPATCH
);
1367 AddToStrW(wszText
, bstrName
);
1369 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1370 hMain
= tvis
.hParent
;
1373 lstrcpyW(wszText
, wszProperties
);
1374 tvis
.hParent
= hParent
;
1375 tld
= InitializeTLData();
1376 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1377 AddToTLDataStrW(tld
, wszProperties
);
1378 AddToTLDataStrW(tld
, wszColon
);
1379 AddToTLDataStrW(tld
, wszNewLine
);
1380 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1381 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, tvis
.hParent
);
1382 AddChildrenData(tvis
.hParent
, tld
);
1384 lstrcpyW(wszText
, wszMethods
);
1385 tvis
.hParent
= hParent
;
1386 tld
= InitializeTLData();
1387 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1388 AddToTLDataStrW(tld
, wszMethods
);
1389 AddToTLDataStrW(tld
, wszColon
);
1390 AddToTLDataStrW(tld
, wszNewLine
);
1391 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1392 EnumFuncs(pTypeInfo
, pTypeAttr
, tvis
.hParent
);
1393 AddChildrenData(tvis
.hParent
, tld
);
1395 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1396 AddChildrenData(hParent
, tldDispatch
);
1397 AddToTLDataStrW(tldDispatch
, tldDispatch
->wszInsertAfter
);
1400 tvis
.hParent
= hMain
;
1402 if(SUCCEEDED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, -1, &hRefType
)))
1406 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1407 SysFreeString(bstrName
);
1408 SysFreeString(bstrData
);
1410 memset(wszText
, 0, sizeof(wszText
));
1411 tld
= InitializeTLData();
1412 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1414 ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
);
1415 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1416 &bstrData
, &ulHelpContext
, NULL
);
1417 ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
);
1419 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1420 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1421 tld
->bPredefine
= TRUE
;
1423 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1424 AddToStrW(wszText
, bstrName
);
1425 ITypeInfo_Release(pRefTypeInfo
);
1429 AddToStrW(wszText
, wszTKIND_ALIAS
);
1430 CreateTypeInfo(wszText
, wszAfter
, pTypeAttr
->tdescAlias
, pTypeInfo
);
1431 AddToStrW(wszText
, wszSpace
);
1432 AddToStrW(wszText
, bstrName
);
1433 AddToStrW(wszText
, wszAfter
);
1435 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1436 AddToTLDataStrW(tld
, &wszText
[lstrlenW(wszTKIND_ALIAS
)]);
1437 AddToTLDataStrW(tld
, wszSemicolon
);
1438 AddToTLDataStrW(tld
, wszNewLine
);
1441 lstrcpyW(wszText
, bstrName
);
1442 WINE_FIXME("pTypeAttr->typekind == %d not supported\n",
1443 pTypeAttr
->typekind
);
1448 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1450 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1451 EnumFuncs(pTypeInfo
, pTypeAttr
, hParent
);
1452 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1454 if(memcmp(bstrName
, wszVT_UNKNOWN
, sizeof(wszVT_UNKNOWN
)))
1455 AddChildrenData(hParent
, tld
);
1456 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1459 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1460 ITypeInfo_Release(pTypeInfo
);
1461 SysFreeString(bstrName
);
1462 SysFreeString(bstrData
);
1464 SendMessageW(typelib
.hTree
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
)tvis
.hParent
);
1466 memset(&tvi
, 0, sizeof(TVITEMW
));
1467 tvi
.mask
= TVIF_PARAM
;
1468 tvi
.hItem
= tvis
.hParent
;
1470 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1471 AddPredefinitions(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1472 AddIdlData(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1473 AddToTLDataStrW((TYPELIB_DATA
*)(tvi
.lParam
),
1474 ((TYPELIB_DATA
*)(tvi
.lParam
))->wszInsertAfter
);
1476 ITypeLib_Release(pTypeLib
);
1480 void UpdateData(HTREEITEM item
)
1484 memset(&tvi
, 0, sizeof(TVITEMW
));
1485 tvi
.mask
= TVIF_PARAM
;
1488 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1491 SetWindowTextW(typelib
.hEdit
, wszSpace
);
1495 SetWindowTextW(typelib
.hEdit
, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1498 static void TypeLibResizeChild(void)
1502 MoveWindow(typelib
.hStatusBar
, 0, 0, 0, 0, TRUE
);
1504 if(IsWindowVisible(typelib
.hStatusBar
))
1505 GetClientRect(typelib
.hStatusBar
, &stat
);
1506 else stat
.bottom
= 0;
1508 GetClientRect(globals
.hTypeLibWnd
, &client
);
1509 MoveWindow(typelib
.hPaneWnd
, 0, 0,
1510 client
.right
, client
.bottom
-stat
.bottom
, TRUE
);
1513 static void TypeLibMenuCommand(WPARAM wParam
, HWND hWnd
)
1523 vis
= IsWindowVisible(typelib
.hStatusBar
);
1524 ShowWindow(typelib
.hStatusBar
, vis
? SW_HIDE
: SW_SHOW
);
1525 CheckMenuItem(GetMenu(hWnd
), LOWORD(wParam
),
1526 vis
? MF_UNCHECKED
: MF_CHECKED
);
1527 TypeLibResizeChild();
1530 DestroyWindow(hWnd
);
1535 static void UpdateTypeLibStatusBar(int itemID
)
1537 WCHAR info
[MAX_LOAD_STRING
];
1539 if(!LoadStringW(globals
.hMainInst
, itemID
, info
, sizeof(info
)/sizeof(info
[0])))
1540 LoadStringW(globals
.hMainInst
, IDS_READY
, info
, sizeof(info
)/sizeof(info
[0]));
1542 SendMessageW(typelib
.hStatusBar
, SB_SETTEXTW
, 0, (LPARAM
)info
);
1545 static void EmptyTLTree(void)
1550 tvi
.mask
= TVIF_PARAM
;
1551 cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
1552 TVGN_CHILD
, (LPARAM
)TVI_ROOT
);
1557 cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
1558 TVGN_CHILD
, (LPARAM
)del
);
1560 if(!cur
) cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1561 TVM_GETNEXTITEM
, TVGN_NEXT
, (LPARAM
)del
);
1562 if(!cur
) cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1563 TVM_GETNEXTITEM
, TVGN_PARENT
, (LPARAM
)del
);
1566 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1569 HeapFree(GetProcessHeap(), 0, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1570 HeapFree(GetProcessHeap(), 0, (TYPELIB_DATA
*)tvi
.lParam
);
1573 SendMessageW(typelib
.hTree
, TVM_DELETEITEM
, 0, (LPARAM
)del
);
1579 static LRESULT CALLBACK
TypeLibProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1585 if(!CreatePanedWindow(hWnd
, &typelib
.hPaneWnd
, globals
.hMainInst
))
1586 DestroyWindow(hWnd
);
1587 typelib
.hTree
= CreateWindowExW(WS_EX_CLIENTEDGE
, WC_TREEVIEWW
, NULL
,
1588 WS_CHILD
|WS_VISIBLE
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_LINESATROOT
,
1589 0, 0, 0, 0, typelib
.hPaneWnd
, (HMENU
)TYPELIB_TREE
,
1590 globals
.hMainInst
, NULL
);
1591 typelib
.hEdit
= CreateWindowExW(WS_EX_CLIENTEDGE
, WC_EDITW
, NULL
,
1592 WS_CHILD
|WS_VISIBLE
|ES_MULTILINE
|ES_READONLY
|WS_HSCROLL
|WS_VSCROLL
,
1593 0, 0, 0, 0, typelib
.hPaneWnd
, NULL
, globals
.hMainInst
, NULL
);
1595 SetLeft(typelib
.hPaneWnd
, typelib
.hTree
);
1596 SetRight(typelib
.hPaneWnd
, typelib
.hEdit
);
1598 if(PopulateTree()) DestroyWindow(hWnd
);
1599 else SetFocus(typelib
.hTree
);
1603 TypeLibMenuCommand(LOWORD(wParam
), hWnd
);
1605 UpdateTypeLibStatusBar(LOWORD(wParam
));
1608 SetFocus(typelib
.hTree
);
1611 if(wParam
== SIZE_MINIMIZED
) break;
1612 TypeLibResizeChild();
1618 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
1623 BOOL
TypeLibRegisterClassW(void)
1627 memset(&wcc
, 0, sizeof(WNDCLASSW
));
1628 wcc
.lpfnWndProc
= TypeLibProc
;
1629 wcc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1630 wcc
.lpszMenuName
= MAKEINTRESOURCEW(IDM_TYPELIB
);
1631 wcc
.lpszClassName
= wszTypeLib
;
1633 if(!RegisterClassW(&wcc
))
1639 BOOL
CreateTypeLibWindow(HINSTANCE hInst
, WCHAR
*wszFileName
)
1641 WCHAR wszTitle
[MAX_LOAD_STRING
];
1642 LoadStringW(hInst
, IDS_TYPELIBTITLE
, wszTitle
, sizeof(wszTitle
)/sizeof(wszTitle
[0]));
1644 if(wszFileName
) lstrcpyW(typelib
.wszFileName
, wszFileName
);
1649 memset(&tvi
, 0, sizeof(TVITEMW
));
1650 tvi
.hItem
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
1653 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1654 lstrcpyW(typelib
.wszFileName
, ((ITEM_INFO
*)tvi
.lParam
)->path
);
1657 globals
.hTypeLibWnd
= CreateWindowW(wszTypeLib
, wszTitle
,
1658 WS_OVERLAPPEDWINDOW
|WS_VISIBLE
,
1659 CW_USEDEFAULT
, CW_USEDEFAULT
, 800, 600, NULL
, NULL
, hInst
, NULL
);
1660 if(!globals
.hTypeLibWnd
) return FALSE
;
1662 typelib
.hStatusBar
= CreateStatusWindowW(WS_VISIBLE
|WS_CHILD
,
1663 wszTitle
, globals
.hTypeLibWnd
, 0);
1665 TypeLibResizeChild();