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
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(oleview
);
28 static const WCHAR wszTypeLib
[] = { 'T','Y','P','E','L','I','B','\0' };
30 static const WCHAR wszFailed
[] = { '<','f','a','i','l','e','d','>','\0' };
31 static const WCHAR wszSpace
[] = { ' ','\0' };
32 static const WCHAR wszAsterix
[] = { '*','\0' };
33 static const WCHAR wszComa
[] = { ',','\0' };
34 static const WCHAR wszEquals
[] = { '=','\0' };
35 static const WCHAR wszSemicolon
[] = { ';','\0' };
36 static const WCHAR wszNewLine
[] = { '\n','\0' };
37 static const WCHAR wszOpenBrackets1
[] = { '[','\0' };
38 static const WCHAR wszCloseBrackets1
[] = { ']','\0' };
39 static const WCHAR wszOpenBrackets2
[] = { '(','\0' };
40 static const WCHAR wszCloseBrackets2
[] = { ')','\0' };
41 static const WCHAR wszOpenBrackets3
[] = { '{','\0' };
42 static const WCHAR wszCloseBrackets3
[] = { '}','\0' };
43 static const WCHAR wszInvertedComa
[] = { '"','\0' };
44 static const WCHAR wszColon
[] = { ':','\0' };
46 static const WCHAR wszUUID
[] = { 'u','u','i','d','\0' };
47 static const WCHAR wszOdl
[] = { 'o','d','l','\0' };
49 static const WCHAR wszVT_BOOL
[]
50 = { 'V','A','R','I','A','N','T','_','B','O','O','L','\0' };
51 static const WCHAR wszVT_UI1
[]
52 = { 'u','n','s','i','g','n','e','d',' ','c','h','a','r','\0' };
53 static const WCHAR wszVT_UI2
[]
54 = { 'u','n','s','i','g','n','e','d',' ','s','h','o','r','t','\0' };
55 static const WCHAR wszVT_UI4
[]
56 = { 'u','n','s','i','g','n','e','d',' ','l','o','n','g','\0' };
57 static const WCHAR wszVT_UI8
[] = { 'u','i','n','t','6','4','\0' };
58 static const WCHAR wszVT_UINT
[]
59 = { 'u','n','s','i','g','n','e','d',' ','i','n','t','\0' };
60 static const WCHAR wszVT_I1
[] = { 'c','h','a','r','\0' };
61 static const WCHAR wszVT_I2
[] = { 's','h','o','r','t','\0' };
62 static const WCHAR wszVT_I4
[] = { 'l','o','n','g','\0' };
63 static const WCHAR wszVT_I8
[] = { 'i','n','t','6','4','\0' };
64 static const WCHAR wszVT_R4
[] = { 's','i','n','g','l','e','\0' };
65 static const WCHAR wszVT_INT
[] = { 'i','n','t','\0' };
66 static const WCHAR wszVT_BSTR
[] = { 'B','S','T','R','\0' };
67 static const WCHAR wszVT_CY
[] = { 'C','U','R','R','E','N','C','Y','\0' };
68 static const WCHAR wszVT_VARIANT
[] = { 'V','A','R','I','A','N','T','\0' };
69 static const WCHAR wszVT_VOID
[] = { 'v','o','i','d','\0' };
70 static const WCHAR wszVT_ERROR
[] = { 'S','C','O','D','E','\0' };
71 static const WCHAR wszVT_LPSTR
[] = { 'L','P','S','T','R','\0' };
72 static const WCHAR wszVT_LPWSTR
[] = { 'L','P','W','S','T','R','\0' };
73 static const WCHAR wszVT_HRESULT
[] = { 'H','R','E','S','U','L','T','\0' };
74 static const WCHAR wszVT_UNKNOWN
[] = { 'I','U','n','k','n','o','w','n','\0' };
75 static const WCHAR wszVT_DISPATCH
[] = { 'I','D','i','s','p','a','t','c','h','\0' };
76 static const WCHAR wszVT_DATE
[] = { 'D','A','T','E','\0' };
77 static const WCHAR wszVT_R8
[] = { 'd','o','u','b','l','e','\0' };
78 static const WCHAR wszVT_SAFEARRAY
[] = { 'S','A','F','E','A','R','R','A','Y','\0' };
80 static const WCHAR wszFormat
[] = { '0','x','%','.','8','l','x','\0' };
81 static const WCHAR wszStdCall
[] = { '_','s','t','d','c','a','l','l','\0' };
82 static const WCHAR wszId
[] = { 'i','d','\0' };
83 static const WCHAR wszHelpstring
[] = { 'h','e','l','p','s','t','r','i','n','g','\0' };
84 static const WCHAR wszPropPut
[] = { 'p','r','o','p','p','u','t','\0' };
85 static const WCHAR wszPropGet
[] = { 'p','r','o','p','g','e','t','\0' };
86 static const WCHAR wszPropPutRef
[] = { 'p','r','o','p','p','u','t','r','e','f','\0' };
87 static const WCHAR wszPARAMFLAG_FIN
[] = { 'i','n','\0' };
88 static const WCHAR wszPARAMFLAG_FOUT
[] = { 'o','u','t','\0' };
89 static const WCHAR wszPARAMFLAG_FLCID
[] = { 'c','i','d','\0' };
90 static const WCHAR wszPARAMFLAG_FRETVAL
[] = { 'r','e','t','v','a','l','\0' };
91 static const WCHAR wszPARAMFLAG_FOPT
[] = { 'o','p','t','i','o','n','a','l','\0' };
92 static const WCHAR wszPARAMFLAG_FHASCUSTDATA
[]
93 = { 'h','a','s','c','u','s','t','d','a','t','a','\0' };
94 static const WCHAR wszDefaultValue
[]
95 = { 'd','e','f','a','u','l','t','v','a','l','u','e','\0' };
97 static const WCHAR wszReadOnly
[] = { 'r','e','a','d','o','n','l','y','\0' };
98 static const WCHAR wszConst
[] = { 'c','o','n','s','t','\0' };
100 static void ShowLastError(void)
102 DWORD error
= GetLastError();
104 WCHAR wszTitle
[MAX_LOAD_STRING
];
106 LoadStringW(globals
.hMainInst
, IDS_TYPELIBTITLE
, wszTitle
, ARRAY_SIZE(wszTitle
));
107 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
108 NULL
, error
, 0, (LPWSTR
)&lpMsgBuf
, 0, NULL
);
109 MessageBoxW(NULL
, lpMsgBuf
, wszTitle
, MB_OK
| MB_ICONERROR
);
114 static void SaveIdl(WCHAR
*wszFileName
)
119 DWORD len
, dwNumWrite
;
123 hIDL
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
124 TVGN_CHILD
, (LPARAM
)TVI_ROOT
);
126 memset(&tvi
, 0, sizeof(TVITEMW
));
129 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
130 data
= (TYPELIB_DATA
*)tvi
.lParam
;
132 hFile
= CreateFileW(wszFileName
, GENERIC_WRITE
, FILE_SHARE_WRITE
,
133 NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
134 if(hFile
== INVALID_HANDLE_VALUE
)
140 len
= WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, NULL
, 0, NULL
, NULL
);
141 wszIdl
= HeapAlloc(GetProcessHeap(), 0, len
);
142 WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, wszIdl
, len
, NULL
, NULL
);
144 if(!WriteFile(hFile
, wszIdl
, len
, &dwNumWrite
, NULL
))
147 HeapFree(GetProcessHeap(), 0, wszIdl
);
151 static void GetSaveIdlAsPath(void)
153 OPENFILENAMEW saveidl
;
155 WCHAR wszPath
[MAX_LOAD_STRING
];
156 WCHAR wszDir
[MAX_LOAD_STRING
];
157 static const WCHAR wszDefaultExt
[] = { 'i','d','l',0 };
158 static const WCHAR wszIdlFiles
[] = { '*','.','i','d','l','\0','\0' };
160 memset(&saveidl
, 0, sizeof(saveidl
));
162 lstrcpyW(wszDir
, typelib
.wszFileName
);
163 pFileName
= wszDir
+ lstrlenW(wszDir
);
164 while(*pFileName
!= '.' && *pFileName
!= '\\' && *pFileName
!= '/'
165 && pFileName
> wszDir
) pFileName
-= 1;
166 if(*pFileName
== '.')
169 while(*pFileName
!= '\\' && *pFileName
!= '/' && pFileName
> wszDir
)
172 if(*pFileName
== '\\' || *pFileName
== '/') pFileName
+= 1;
173 lstrcpyW(wszPath
, pFileName
);
175 GetCurrentDirectoryW(MAX_LOAD_STRING
, wszDir
);
177 saveidl
.lStructSize
= sizeof(OPENFILENAMEW
);
178 saveidl
.hwndOwner
= globals
.hTypeLibWnd
;
179 saveidl
.hInstance
= globals
.hMainInst
;
180 saveidl
.lpstrFilter
= wszIdlFiles
;
181 saveidl
.lpstrFile
= wszPath
;
182 saveidl
.nMaxFile
= MAX_LOAD_STRING
;
183 saveidl
.lpstrInitialDir
= wszDir
;
184 saveidl
.Flags
= OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
| OFN_HIDEREADONLY
;
185 saveidl
.lpstrDefExt
= wszDefaultExt
;
187 if (GetSaveFileNameW(&saveidl
))
191 static void AddToStrW(WCHAR
*wszDest
, const WCHAR
*wszSource
)
193 lstrcpyW(&wszDest
[lstrlenW(wszDest
)], wszSource
);
196 static void AddToTLDataStrW(TYPELIB_DATA
*pTLData
, const WCHAR
*wszSource
)
198 int SourceLen
= lstrlenW(wszSource
);
200 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
201 sizeof(WCHAR
)*(pTLData
->idlLen
+SourceLen
+1));
203 memcpy(&pTLData
->idl
[pTLData
->idlLen
], wszSource
, sizeof(WCHAR
)*(SourceLen
+1));
204 pTLData
->idlLen
+= SourceLen
;
207 static void AddToTLDataStrWithTabsW(TYPELIB_DATA
*pTLData
, WCHAR
*wszSource
)
209 int lineLen
= lstrlenW(wszSource
);
211 WCHAR
*pSourcePos
= wszSource
;
217 if(*pSourcePos
== *wszNewLine
) newLinesNo
++;
220 if(*(pSourcePos
- 1) != *wszNewLine
) newLinesNo
++;
222 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
223 sizeof(WCHAR
)*(pTLData
->idlLen
+lineLen
+4*newLinesNo
+1));
225 pSourcePos
= wszSource
;
226 pSourceBeg
= wszSource
;
229 if(*pSourcePos
!= *wszNewLine
&& *pSourcePos
)
239 lineLen
= lstrlenW(pSourceBeg
)+1;
243 else lineLen
= lstrlenW(pSourceBeg
);
245 pTLData
->idl
[pTLData
->idlLen
] = *wszSpace
;
246 pTLData
->idl
[pTLData
->idlLen
+1] = *wszSpace
;
247 pTLData
->idl
[pTLData
->idlLen
+2] = *wszSpace
;
248 pTLData
->idl
[pTLData
->idlLen
+3] = *wszSpace
;
249 memcpy(&pTLData
->idl
[pTLData
->idlLen
+4], pSourceBeg
, sizeof(WCHAR
)*lineLen
);
250 pTLData
->idlLen
+= lineLen
+ 4;
251 pTLData
->idl
[pTLData
->idlLen
] = '\0';
253 pSourceBeg
= pSourcePos
;
257 static TYPELIB_DATA
*InitializeTLData(void)
259 TYPELIB_DATA
*pTLData
;
261 pTLData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TYPELIB_DATA
));
263 pTLData
->idl
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
));
264 pTLData
->idl
[0] = '\0';
269 static void AddSpaces(TYPELIB_DATA
*pTLData
, int tabSize
)
271 for(; tabSize
>0; tabSize
--)
272 AddToTLDataStrW(pTLData
, wszSpace
);
275 static void AddChildrenData(HTREEITEM hParent
, TYPELIB_DATA
*pData
)
280 memset(&tvi
, 0, sizeof(tvi
));
282 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
283 TVGN_CHILD
, (LPARAM
)hParent
);
289 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
290 if(tvi
.lParam
&& ((TYPELIB_DATA
*)(tvi
.lParam
))->idlLen
)
291 AddToTLDataStrWithTabsW(pData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
292 } while((hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
293 TVGN_NEXT
, (LPARAM
)hCur
)));
296 static void CreateTypeInfo(WCHAR
*wszAddTo
, WCHAR
*wszAddAfter
, TYPEDESC tdesc
, ITypeInfo
*pTypeInfo
)
301 ITypeInfo
*pRefTypeInfo
;
302 WCHAR wszBuf
[MAX_LOAD_STRING
];
303 WCHAR wszFormat
[] = { '[','%','l','u',']','\0' };
305 switch(tdesc
.vt
&VT_TYPEMASK
)
307 #define VTADDTOSTR(x) case x:\
308 AddToStrW(wszAddTo, wsz##x);\
324 VTADDTOSTR(VT_VARIANT
);
326 VTADDTOSTR(VT_ERROR
);
327 VTADDTOSTR(VT_LPSTR
);
328 VTADDTOSTR(VT_LPWSTR
);
329 VTADDTOSTR(VT_HRESULT
);
330 VTADDTOSTR(VT_UNKNOWN
);
331 VTADDTOSTR(VT_DISPATCH
);
335 for(i
=0; i
<U(tdesc
).lpadesc
->cDims
; i
++)
337 wsprintfW(wszBuf
, wszFormat
, U(tdesc
).lpadesc
->rgbounds
[i
].cElements
);
338 AddToStrW(wszAddAfter
, wszBuf
);
340 CreateTypeInfo(wszAddTo
, wszAddAfter
, U(tdesc
).lpadesc
->tdescElem
, pTypeInfo
);
343 AddToStrW(wszAddTo
, wszVT_SAFEARRAY
);
344 AddToStrW(wszAddTo
, wszOpenBrackets2
);
345 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
346 AddToStrW(wszAddTo
, wszCloseBrackets2
);
349 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
350 AddToStrW(wszAddTo
, wszAsterix
);
353 hRes
= ITypeInfo_GetRefTypeInfo(pTypeInfo
,
354 U(tdesc
).hreftype
, &pRefTypeInfo
);
357 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
,
358 &bstrData
, NULL
, NULL
, NULL
);
359 AddToStrW(wszAddTo
, bstrData
);
360 SysFreeString(bstrData
);
361 ITypeInfo_Release(pRefTypeInfo
);
363 else AddToStrW(wszAddTo
, wszFailed
);
366 WINE_FIXME("tdesc.vt&VT_TYPEMASK == %d not supported\n",
367 tdesc
.vt
&VT_TYPEMASK
);
371 static int EnumVars(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
374 TVINSERTSTRUCTW tvis
;
377 WCHAR wszText
[MAX_LOAD_STRING
];
378 WCHAR wszAfter
[MAX_LOAD_STRING
];
380 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
381 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
382 U(tvis
).item
.pszText
= wszText
;
383 tvis
.hInsertAfter
= TVI_LAST
;
384 tvis
.hParent
= hParent
;
386 for(i
=0; i
<cVars
; i
++)
390 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
391 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
392 NULL
, NULL
, NULL
))) continue;
394 tld
= InitializeTLData();
395 U(tvis
).item
.lParam
= (LPARAM
) tld
;
396 if(pVarDesc
->memid
< MIN_VAR_ID
)
399 AddToTLDataStrW(tld
, wszOpenBrackets1
);
400 AddToTLDataStrW(tld
, wszId
);
401 AddToTLDataStrW(tld
, wszOpenBrackets2
);
402 wsprintfW(wszText
, wszFormat
, pVarDesc
->memid
);
403 AddToTLDataStrW(tld
, wszText
);
404 memset(wszText
, 0, sizeof(wszText
));
405 AddToTLDataStrW(tld
, wszCloseBrackets2
);
407 if(pVarDesc
->wVarFlags
& VARFLAG_FREADONLY
)
409 AddToTLDataStrW(tld
, wszComa
);
410 AddToTLDataStrW(tld
, wszSpace
);
411 AddToTLDataStrW(tld
, wszReadOnly
);
413 AddToTLDataStrW(tld
, wszCloseBrackets1
);
414 AddToTLDataStrW(tld
, wszNewLine
);
417 memset(wszText
, 0, sizeof(wszText
));
418 memset(wszAfter
, 0, sizeof(wszAfter
));
419 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
420 AddToStrW(wszText
, wszSpace
);
421 if (bstrName
) AddToStrW(wszText
, bstrName
);
422 AddToStrW(wszText
, wszAfter
);
423 AddToTLDataStrW(tld
, wszText
);
424 AddToTLDataStrW(tld
, wszSemicolon
);
425 AddToTLDataStrW(tld
, wszNewLine
);
427 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
428 SysFreeString(bstrName
);
429 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
435 static int EnumEnums(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
438 TVINSERTSTRUCTW tvis
;
441 WCHAR wszText
[MAX_LOAD_STRING
];
442 WCHAR wszAfter
[MAX_LOAD_STRING
];
444 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
445 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
446 U(tvis
).item
.pszText
= wszText
;
447 tvis
.hInsertAfter
= TVI_LAST
;
448 tvis
.hParent
= hParent
;
450 for(i
=0; i
<cVars
; i
++)
454 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
455 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
456 NULL
, NULL
, NULL
))) continue;
458 tld
= InitializeTLData();
459 U(tvis
).item
.lParam
= (LPARAM
) tld
;
461 memset(wszText
, 0, sizeof(wszText
));
462 memset(wszAfter
, 0, sizeof(wszAfter
));
464 if (pVarDesc
->varkind
== VAR_CONST
)
468 if (VariantChangeType(&var
, U(*pVarDesc
).lpvarValue
, 0, VT_BSTR
) == S_OK
)
470 AddToStrW(wszText
, wszConst
);
471 AddToStrW(wszText
, wszSpace
);
472 AddToStrW(wszAfter
, wszSpace
);
473 AddToStrW(wszAfter
, wszEquals
);
474 AddToStrW(wszAfter
, wszSpace
);
475 AddToStrW(wszAfter
, V_BSTR(&var
));
479 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
480 AddToStrW(wszText
, wszSpace
);
481 AddToStrW(wszText
, bstrName
);
482 AddToStrW(wszText
, wszAfter
);
483 AddToTLDataStrW(tld
, bstrName
);
484 AddToTLDataStrW(tld
, wszAfter
);
486 AddToTLDataStrW(tld
, wszComa
);
487 AddToTLDataStrW(tld
, wszNewLine
);
489 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
490 SysFreeString(bstrName
);
491 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
497 static int EnumFuncs(ITypeInfo
*pTypeInfo
, TYPEATTR
*pTypeAttr
, HTREEITEM hParent
)
502 TVINSERTSTRUCTW tvis
;
504 BSTR bstrName
, bstrHelpString
, *bstrParamNames
;
505 WCHAR wszText
[MAX_LOAD_STRING
];
506 WCHAR wszAfter
[MAX_LOAD_STRING
];
507 WCHAR szRhs
[] = {'r','h','s',0}; /* Right-hand side of a propput */
510 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
511 tvis
.hInsertAfter
= TVI_LAST
;
512 tvis
.hParent
= hParent
;
514 cFuncs
= pTypeAttr
->cFuncs
;
517 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
) { /* skip 7 members of IDispatch */
526 if(FAILED(ITypeInfo_GetFuncDesc(pTypeInfo
, i
, &pFuncDesc
))) continue;
528 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pFuncDesc
->memid
, &bstrName
,
529 &bstrHelpString
, NULL
, NULL
))) continue;
531 memset(wszText
, 0, sizeof(wszText
));
532 memset(wszAfter
, 0, sizeof(wszAfter
));
533 tld
= InitializeTLData();
534 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
535 U(tvis
).item
.pszText
= bstrName
;
536 U(tvis
).item
.lParam
= (LPARAM
) tld
;
538 if(pFuncDesc
->memid
< MIN_FUNC_ID
|| pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
540 AddToTLDataStrW(tld
, wszOpenBrackets1
);
542 AddToTLDataStrW(tld
, wszId
);
543 AddToTLDataStrW(tld
, wszOpenBrackets2
);
544 wsprintfW(wszText
, wszFormat
, pFuncDesc
->memid
);
545 AddToTLDataStrW(tld
, wszText
);
546 AddToTLDataStrW(tld
, wszCloseBrackets2
);
547 memset(wszText
, 0, sizeof(wszText
));
550 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->elemdescFunc
.tdesc
, pTypeInfo
);
551 switch(pFuncDesc
->invkind
)
553 case INVOKE_PROPERTYGET
:
554 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
557 AddToTLDataStrW(tld
, wszComa
);
558 AddToTLDataStrW(tld
, wszSpace
);
561 AddToTLDataStrW(tld
, wszPropGet
);
563 case INVOKE_PROPERTYPUT
:
564 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
567 AddToTLDataStrW(tld
, wszComa
);
568 AddToTLDataStrW(tld
, wszSpace
);
571 AddToTLDataStrW(tld
, wszPropPut
);
573 case INVOKE_PROPERTYPUTREF
:
574 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
577 AddToTLDataStrW(tld
, wszComa
);
578 AddToTLDataStrW(tld
, wszSpace
);
581 AddToTLDataStrW(tld
, wszPropPutRef
);
585 if(SysStringLen(bstrHelpString
))
587 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
590 AddToTLDataStrW(tld
, wszComa
);
591 AddToTLDataStrW(tld
, wszSpace
);
594 AddToTLDataStrW(tld
, wszHelpstring
);
595 AddToTLDataStrW(tld
, wszOpenBrackets2
);
596 AddToTLDataStrW(tld
, wszInvertedComa
);
597 AddToTLDataStrW(tld
, bstrHelpString
);
598 AddToTLDataStrW(tld
, wszInvertedComa
);
599 AddToTLDataStrW(tld
, wszCloseBrackets2
);
603 AddToTLDataStrW(tld
, wszCloseBrackets1
);
604 AddToTLDataStrW(tld
, wszNewLine
);
607 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FOLEAUTOMATION
) {
608 AddToTLDataStrW(tld
, wszVT_HRESULT
);
609 if(lstrcmpW(wszText
, wszVT_VOID
)) pFuncDesc
->cParams
++;
612 AddToTLDataStrW(tld
, wszText
);
613 AddToTLDataStrW(tld
, wszAfter
);
616 bstrParamNames
= HeapAlloc(GetProcessHeap(), 0,
617 sizeof(BSTR
)*(pFuncDesc
->cParams
+1));
618 if(FAILED(ITypeInfo_GetNames(pTypeInfo
, pFuncDesc
->memid
, bstrParamNames
,
619 pFuncDesc
->cParams
+1, &namesNo
)))
621 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
624 SysFreeString(bstrParamNames
[0]);
626 AddToTLDataStrW(tld
, wszSpace
);
627 if(pFuncDesc
->memid
>= MIN_FUNC_ID
)
629 AddToTLDataStrW(tld
, wszStdCall
);
630 AddToTLDataStrW(tld
, wszSpace
);
632 if (bstrName
) AddToTLDataStrW(tld
, bstrName
);
633 AddToTLDataStrW(tld
, wszOpenBrackets2
);
635 for(j
=0; j
<pFuncDesc
->cParams
; j
++)
637 if(j
!= 0) AddToTLDataStrW(tld
, wszComa
);
638 if(pFuncDesc
->cParams
!= 1)
640 AddToTLDataStrW(tld
, wszNewLine
);
641 AddSpaces(tld
, TAB_SIZE
);
644 #define ENUM_PARAM_FLAG(x)\
645 if(U(pFuncDesc->lprgelemdescParam[j]).paramdesc.wParamFlags & x) \
647 if(bFirst) AddToTLDataStrW(tld,\
651 AddToTLDataStrW(tld, wszComa);\
652 AddToTLDataStrW(tld, wszSpace);\
655 AddToTLDataStrW(tld, wsz##x);\
657 ENUM_PARAM_FLAG(PARAMFLAG_FIN
);
658 ENUM_PARAM_FLAG(PARAMFLAG_FOUT
);
659 ENUM_PARAM_FLAG(PARAMFLAG_FLCID
);
660 ENUM_PARAM_FLAG(PARAMFLAG_FRETVAL
);
661 ENUM_PARAM_FLAG(PARAMFLAG_FOPT
);
662 ENUM_PARAM_FLAG(PARAMFLAG_FHASCUSTDATA
);
664 if(U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
666 VARIANT var
, *param
=&U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.pparamdescex
->varDefaultValue
;
668 if(bFirst
) AddToTLDataStrW(tld
,
672 AddToTLDataStrW(tld
, wszComa
);
673 AddToTLDataStrW(tld
, wszSpace
);
676 AddToTLDataStrW(tld
, wszDefaultValue
);
677 AddToTLDataStrW(tld
, wszOpenBrackets2
);
678 if (V_VT(param
) == VT_BSTR
)
680 AddToTLDataStrW(tld
, wszInvertedComa
);
681 AddToTLDataStrW(tld
, V_BSTR(param
));
682 AddToTLDataStrW(tld
, wszInvertedComa
);
683 } else if (VariantChangeType(&var
, param
, 0, VT_BSTR
) == S_OK
)
684 AddToTLDataStrW(tld
, V_BSTR(&var
));
685 AddToTLDataStrW(tld
, wszCloseBrackets2
);
690 AddToTLDataStrW(tld
, wszCloseBrackets1
);
691 AddToTLDataStrW(tld
, wszSpace
);
694 memset(wszText
, 0, sizeof(wszText
));
695 memset(wszAfter
, 0, sizeof(wszAfter
));
696 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->lprgelemdescParam
[j
].tdesc
,
698 AddToTLDataStrW(tld
, wszText
);
699 AddToTLDataStrW(tld
, wszAfter
);
700 AddToTLDataStrW(tld
, wszSpace
);
702 if (bstrParamNames
[j
+1])
704 AddToTLDataStrW(tld
, bstrParamNames
[j
+1]);
705 SysFreeString(bstrParamNames
[j
+1]);
708 AddToTLDataStrW(tld
, szRhs
);
711 AddToTLDataStrW(tld
, wszCloseBrackets2
);
712 AddToTLDataStrW(tld
, wszSemicolon
);
713 AddToTLDataStrW(tld
, wszNewLine
);
715 SendMessageW(typelib
.hTree
, TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
716 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
717 SysFreeString(bstrName
);
718 SysFreeString(bstrHelpString
);
719 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, pFuncDesc
);
725 static int EnumImplTypes(ITypeInfo
*pTypeInfo
, int cImplTypes
, HTREEITEM hParent
)
728 TVINSERTSTRUCTW tvis
;
729 ITypeInfo
*pRefTypeInfo
;
733 WCHAR wszInheritedInterfaces
[MAX_LOAD_STRING
];
735 if(!cImplTypes
) return 0;
737 LoadStringW(globals
.hMainInst
, IDS_INHERITINTERFACES
, wszInheritedInterfaces
,
738 ARRAY_SIZE(wszInheritedInterfaces
));
740 U(tvis
).item
.mask
= TVIF_TEXT
;
741 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
742 U(tvis
).item
.pszText
= wszInheritedInterfaces
;
743 tvis
.hInsertAfter
= TVI_LAST
;
744 tvis
.hParent
= hParent
;
746 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
748 for(i
=0; i
<cImplTypes
; i
++)
750 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
751 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
753 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
756 ITypeInfo_Release(pRefTypeInfo
);
759 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
761 ITypeInfo_Release(pRefTypeInfo
);
765 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
766 U(tvis
).item
.pszText
= bstrName
;
768 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
769 EnumVars(pRefTypeInfo
, pTypeAttr
->cVars
, hParent
);
770 EnumFuncs(pRefTypeInfo
, pTypeAttr
, hParent
);
771 EnumImplTypes(pRefTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
773 SysFreeString(bstrName
);
774 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
775 ITypeInfo_Release(pRefTypeInfo
);
781 static void EnumCoclassImplTypes(ITypeInfo
*pTypeInfo
,
782 int cImplTypes
, TYPELIB_DATA
*pTLData
)
785 ITypeInfo
*pRefTypeInfo
;
791 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
792 const WCHAR wszTKIND_DISPATCH
[]
793 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
794 const WCHAR wszIMPLTYPEFLAG_FDEFAULT
[]
795 = { 'd','e','f','a','u','l','t','\0' };
796 const WCHAR wszIMPLTYPEFLAG_FSOURCE
[]
797 = { 's','o','u','r','c','e','\0' };
798 const WCHAR wszIMPLTYPEFLAG_FRESTRICTED
[]
799 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
801 for(i
=0; i
<cImplTypes
; i
++)
803 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
804 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
806 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
809 ITypeInfo_Release(pRefTypeInfo
);
812 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
814 ITypeInfo_Release(pRefTypeInfo
);
818 AddSpaces(pTLData
, TAB_SIZE
);
819 ITypeInfo_GetImplTypeFlags(pTypeInfo
, i
, &flags
);
821 #define ENUM_IMPLTYPEFLAG(x)\
824 if(bFirst) AddToTLDataStrW(pTLData,\
828 AddToTLDataStrW(pTLData, wszComa);\
829 AddToTLDataStrW(pTLData, wszSpace);\
832 AddToTLDataStrW(pTLData, wsz##x);\
834 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FDEFAULT
);
835 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FSOURCE
);
836 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FRESTRICTED
);
839 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
840 AddToTLDataStrW(pTLData
, wszSpace
);
843 if(pTypeAttr
->typekind
== TKIND_INTERFACE
||
844 (pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
))
845 AddToTLDataStrW(pTLData
, wszTKIND_INTERFACE
);
846 else if(pTypeAttr
->typekind
== TKIND_DISPATCH
)
847 AddToTLDataStrW(pTLData
, wszTKIND_DISPATCH
);
848 AddToTLDataStrW(pTLData
, wszSpace
);
850 AddToTLDataStrW(pTLData
, bstrName
);
851 AddToTLDataStrW(pTLData
, wszSemicolon
);
852 AddToTLDataStrW(pTLData
, wszNewLine
);
854 SysFreeString(bstrName
);
855 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
856 ITypeInfo_Release(pRefTypeInfo
);
860 static void AddIdlData(HTREEITEM hCur
, TYPELIB_DATA
*pTLData
)
864 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
865 TVGN_CHILD
, (LPARAM
)hCur
);
866 memset(&tvi
, 0, sizeof(TVITEMW
));
867 tvi
.mask
= TVIF_PARAM
;
872 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
873 if(!((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
) {
874 AddToTLDataStrW(pTLData
, wszNewLine
);
875 AddToTLDataStrWithTabsW(pTLData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
877 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
878 TVGN_NEXT
, (LPARAM
)hCur
);
882 static void AddPredefinitions(HTREEITEM hFirst
, TYPELIB_DATA
*pTLData
)
886 WCHAR wszText
[MAX_LOAD_STRING
];
887 WCHAR wszPredefinition
[] = { '/','/',' ','T','L','i','b',' ',':','\n',
888 '/','/',' ','F','o','r','w','a','r','d',' ','d','e','c','l','a','r','e',' ',
889 'a','l','l',' ','t','y','p','e','s',' ','d','e','f','i','n','e','d',' ',
890 'i','n',' ','t','h','i','s',' ','t','y','p','e','l','i','b','\0' };
892 hFirst
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
893 TVGN_CHILD
, (LPARAM
)hFirst
);
895 AddToTLDataStrWithTabsW(pTLData
, wszPredefinition
);
896 AddToTLDataStrW(pTLData
, wszNewLine
);
899 memset(&tvi
, 0, sizeof(TVITEMW
));
900 tvi
.mask
= TVIF_TEXT
|TVIF_PARAM
;
901 tvi
.cchTextMax
= MAX_LOAD_STRING
;
902 tvi
.pszText
= wszText
;
906 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
907 if(((TYPELIB_DATA
*)(tvi
.lParam
))->bPredefine
&&
908 !((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
)
910 AddToStrW(wszText
, wszSemicolon
);
911 AddToTLDataStrWithTabsW(pTLData
, wszText
);
912 AddToTLDataStrW(pTLData
, wszNewLine
);
914 hCur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
915 TVGN_NEXT
, (LPARAM
)hCur
);
919 static void CreateInterfaceInfo(ITypeInfo
*pTypeInfo
, int cImplTypes
, WCHAR
*wszName
,
920 WCHAR
*wszHelpString
, ULONG ulHelpContext
, TYPEATTR
*pTypeAttr
,
921 TYPELIB_DATA
*pTLData
)
923 ITypeInfo
*pRefTypeInfo
;
926 WCHAR wszGuid
[MAX_LOAD_STRING
];
927 WCHAR wszHelpContext
[MAX_LOAD_STRING
];
929 const WCHAR wszInterface
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
930 const WCHAR wszDispinterface
[]
931 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
932 const WCHAR wszHelpcontext
[] = { 'h','e','l','p','c','o','n','t','e','x','t','\0' };
933 const WCHAR wszTYPEFLAG_FAPPOBJECT
[] = { 'a','p','p','o','b','j','e','c','t','\0' };
934 const WCHAR wszTYPEFLAG_FCANCREATE
[] = { 'c','a','n','c','r','e','a','t','e','\0' };
935 const WCHAR wszTYPEFLAG_FLICENSED
[] = { 'l','i','c','e','n','s','e','d','\0' };
936 const WCHAR wszTYPEFLAG_FPREDECLID
[] = { 'p','r','e','d','e','c','l','i','d','\0' };
937 const WCHAR wszTYPEFLAG_FHIDDEN
[] = { 'h','i','d','d','e','n','\0' };
938 const WCHAR wszTYPEFLAG_FCONTROL
[] = { 'c','o','n','t','r','o','l','\0' };
939 const WCHAR wszTYPEFLAG_FDUAL
[] = { 'd','u','a','l','\0' };
940 const WCHAR wszTYPEFLAG_FNONEXTENSIBLE
[]
941 = { 'n','o','n','e','x','t','e','n','s','i','b','l','e','\0' };
942 const WCHAR wszTYPEFLAG_FOLEAUTOMATION
[]
943 = { 'o','l','e','a','u','t','o','m','a','t','i','o','n','\0' };
944 const WCHAR wszTYPEFLAG_FRESTRICTED
[]
945 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
946 const WCHAR wszTYPEFLAG_FAGGREGATABLE
[]
947 = { 'a','g','g','r','e','g','a','t','a','b','l','e','\0' };
948 const WCHAR wszTYPEFLAG_FREPLACEABLE
[]
949 = { 'r','e','p','l','a','c','a','b','l','e','\0' };
950 const WCHAR wszTYPEFLAG_FREVERSEBIND
[]
951 = { 'r','e','v','e','r','s','e','b','i','n','d','\0' };
952 const WCHAR wszTYPEFLAG_FPROXY
[] = { 'p','r','o','x','y','\0' };
954 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
955 AddToTLDataStrW(pTLData
, wszNewLine
);
956 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
)
958 AddSpaces(pTLData
, TAB_SIZE
);
959 AddToTLDataStrW(pTLData
, wszOdl
);
960 AddToTLDataStrW(pTLData
, wszComa
);
961 AddToTLDataStrW(pTLData
, wszNewLine
);
963 AddSpaces(pTLData
, TAB_SIZE
);
964 AddToTLDataStrW(pTLData
, wszUUID
);
965 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
966 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
967 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
968 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
969 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
972 AddToTLDataStrW(pTLData
, wszComa
);
973 AddToTLDataStrW(pTLData
, wszNewLine
);
974 AddSpaces(pTLData
, TAB_SIZE
);
975 AddToTLDataStrW(pTLData
, wszHelpstring
);
976 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
977 AddToTLDataStrW(pTLData
, wszInvertedComa
);
978 AddToTLDataStrW(pTLData
, wszHelpString
);
979 AddToTLDataStrW(pTLData
, wszInvertedComa
);
980 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
984 AddToTLDataStrW(pTLData
, wszComa
);
985 AddToTLDataStrW(pTLData
, wszNewLine
);
986 AddSpaces(pTLData
, TAB_SIZE
);
987 AddToTLDataStrW(pTLData
, wszHelpcontext
);
988 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
989 wsprintfW(wszHelpContext
, wszFormat
, ulHelpContext
);
990 AddToTLDataStrW(pTLData
, wszHelpContext
);
991 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
993 if(pTypeAttr
->wTypeFlags
)
995 #define ENUM_FLAGS(x) if(pTypeAttr->wTypeFlags & x)\
997 AddToTLDataStrW(pTLData, wszComa);\
998 AddToTLDataStrW(pTLData, wszNewLine);\
999 AddSpaces(pTLData, TAB_SIZE);\
1000 AddToTLDataStrW(pTLData, wsz##x);\
1002 ENUM_FLAGS(TYPEFLAG_FAPPOBJECT
);
1003 ENUM_FLAGS(TYPEFLAG_FCANCREATE
);
1004 ENUM_FLAGS(TYPEFLAG_FLICENSED
);
1005 ENUM_FLAGS(TYPEFLAG_FPREDECLID
);
1006 ENUM_FLAGS(TYPEFLAG_FHIDDEN
);
1007 ENUM_FLAGS(TYPEFLAG_FCONTROL
);
1008 ENUM_FLAGS(TYPEFLAG_FDUAL
);
1009 ENUM_FLAGS(TYPEFLAG_FNONEXTENSIBLE
);
1010 ENUM_FLAGS(TYPEFLAG_FOLEAUTOMATION
);
1011 ENUM_FLAGS(TYPEFLAG_FRESTRICTED
);
1012 ENUM_FLAGS(TYPEFLAG_FAGGREGATABLE
);
1013 ENUM_FLAGS(TYPEFLAG_FREPLACEABLE
);
1014 ENUM_FLAGS(TYPEFLAG_FREVERSEBIND
);
1015 ENUM_FLAGS(TYPEFLAG_FPROXY
);
1017 AddToTLDataStrW(pTLData
, wszNewLine
);
1018 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1019 AddToTLDataStrW(pTLData
, wszNewLine
);
1020 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
) AddToTLDataStrW(pTLData
, wszInterface
);
1021 else AddToTLDataStrW(pTLData
, wszDispinterface
);
1022 AddToTLDataStrW(pTLData
, wszName
);
1023 AddToTLDataStrW(pTLData
, wszSpace
);
1024 if(cImplTypes
&& pTypeAttr
->typekind
!= TKIND_DISPATCH
)
1026 AddToTLDataStrW(pTLData
, wszColon
);
1027 AddToTLDataStrW(pTLData
, wszSpace
);
1029 ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, 0, &hRefType
);
1030 if (SUCCEEDED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
1032 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1034 AddToTLDataStrW(pTLData
, bstrName
);
1035 AddToTLDataStrW(pTLData
, wszSpace
);
1037 SysFreeString(bstrName
);
1038 ITypeInfo_Release(pRefTypeInfo
);
1041 AddToTLDataStrW(pTLData
, wszFailed
);
1043 AddToTLDataStrW(pTLData
, wszOpenBrackets3
);
1044 AddToTLDataStrW(pTLData
, wszNewLine
);
1046 AddToStrW(pTLData
->wszInsertAfter
, wszCloseBrackets3
);
1047 AddToStrW(pTLData
->wszInsertAfter
, wszSemicolon
);
1048 AddToStrW(pTLData
->wszInsertAfter
, wszNewLine
);
1051 static void CreateTypedefHeader(ITypeInfo
*pTypeInfo
,
1052 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1055 WCHAR wszGuid
[MAX_LOAD_STRING
];
1056 const WCHAR wszTypedef
[] = { 't','y','p','e','d','e','f',' ','\0' };
1057 const WCHAR wszPublic
[] = { 'p','u','b','l','i','c','\0' };
1059 AddToTLDataStrW(pTLData
, wszTypedef
);
1060 if(memcmp(&pTypeAttr
->guid
, &GUID_NULL
, sizeof(GUID
)))
1062 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1064 AddToTLDataStrW(pTLData
, wszUUID
);
1065 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1066 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1067 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1068 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1069 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1071 if(pTypeAttr
->typekind
== TKIND_ALIAS
)
1073 if(bFirst
) AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1076 AddToTLDataStrW(pTLData
, wszComa
);
1077 AddToTLDataStrW(pTLData
, wszSpace
);
1080 AddToTLDataStrW(pTLData
, wszPublic
);
1084 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1085 AddToTLDataStrW(pTLData
, wszNewLine
);
1089 static void CreateCoclassHeader(ITypeInfo
*pTypeInfo
,
1090 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1092 WCHAR wszGuid
[MAX_LOAD_STRING
];
1093 BSTR bstrHelpString
;
1094 const WCHAR wszNoncreatable
[]
1095 = { 'n','o','n','c','r','e','a','t','a','b','l','e','\0' };
1097 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1098 AddToTLDataStrW(pTLData
, wszNewLine
);
1100 AddSpaces(pTLData
, TAB_SIZE
);
1101 AddToTLDataStrW(pTLData
, wszUUID
);
1102 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1103 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1104 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1105 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1106 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1108 if(SUCCEEDED(ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, NULL
,
1109 &bstrHelpString
, NULL
, NULL
)))
1111 if(SysStringLen(bstrHelpString
))
1113 AddToTLDataStrW(pTLData
, wszComa
);
1114 AddToTLDataStrW(pTLData
, wszNewLine
);
1115 AddSpaces(pTLData
, TAB_SIZE
);
1116 AddToTLDataStrW(pTLData
, wszHelpstring
);
1117 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1118 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1119 AddToTLDataStrW(pTLData
, bstrHelpString
);
1120 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1121 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1123 SysFreeString(bstrHelpString
);
1126 if(!(pTypeAttr
->wTypeFlags
& TYPEFLAG_FCANCREATE
))
1128 AddToTLDataStrW(pTLData
, wszComa
);
1129 AddToTLDataStrW(pTLData
, wszNewLine
);
1130 AddSpaces(pTLData
, TAB_SIZE
);
1131 AddToTLDataStrW(pTLData
, wszNoncreatable
);
1134 AddToTLDataStrW(pTLData
, wszNewLine
);
1135 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1136 AddToTLDataStrW(pTLData
, wszNewLine
);
1139 static int PopulateTree(void)
1141 TVINSERTSTRUCTW tvis
;
1144 TLIBATTR
*pTLibAttr
;
1145 ITypeInfo
*pTypeInfo
, *pRefTypeInfo
;
1147 TYPEATTR
*pTypeAttr
;
1149 ULONG ulHelpContext
;
1152 WCHAR wszText
[MAX_LOAD_STRING
];
1153 WCHAR wszAfter
[MAX_LOAD_STRING
];
1158 TYPELIB_DATA
*tldDispatch
;
1161 const WCHAR wszGeneratedInfo
[] = { '/','/',' ','G','e','n','e','r','a','t','e','d',
1162 ' ','.','I','D','L',' ','f','i','l','e',' ','(','b','y',' ','t','h','e',' ',
1163 'O','L','E','/','C','O','M',' ','O','b','j','e','c','t',' ',
1164 'V','i','e','w','e','r',')','\n','/','/','\n','/','/',' ',
1165 't','y','p','e','l','i','b',' ','f','i','l','e','n','a','m','e',':',' ','\0'};
1167 const WCHAR wszFormat
[] = { '%','s',' ','(','%','s',')','\0' };
1168 const WCHAR wszFormat2
[] = { 'v','e','r','s','i','o','n',
1169 '(','%','l','d','.','%','l','d',')','\0' };
1171 const WCHAR wszTKIND_ENUM
[] = { 't','y','p','e','d','e','f',' ','e','n','u','m',' ','\0' };
1172 const WCHAR wszTKIND_RECORD
[]
1173 = { 't','y','p','e','d','e','f',' ','s','t','r','u','c','t',' ','\0' };
1174 const WCHAR wszTKIND_MODULE
[] = { 'm','o','d','u','l','e',' ','\0' };
1175 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
1176 const WCHAR wszTKIND_DISPATCH
[]
1177 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
1178 const WCHAR wszTKIND_COCLASS
[] = { 'c','o','c','l','a','s','s',' ','\0' };
1179 const WCHAR wszTKIND_ALIAS
[] = { 't','y','p','e','d','e','f',' ','\0' };
1180 const WCHAR wszTKIND_UNION
[]
1181 = { 't','y','p','e','d','e','f',' ','u','n','i','o','n',' ','\0' };
1183 const WCHAR wszLibrary
[] = { 'l','i','b','r','a','r','y',' ','\0' };
1184 const WCHAR wszTag
[] = { 't','a','g','\0' };
1186 WCHAR wszProperties
[] = { 'p','r','o','p','e','r','t','i','e','s','\0' };
1187 WCHAR wszMethods
[] = { 'm','e','t','h','o','d','s','\0' };
1189 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
1190 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
1191 U(tvis
).item
.pszText
= wszText
;
1192 tvis
.hInsertAfter
= TVI_LAST
;
1193 tvis
.hParent
= TVI_ROOT
;
1195 if(FAILED((hRes
= LoadTypeLib(typelib
.wszFileName
, &pTypeLib
))))
1197 WCHAR wszMessage
[MAX_LOAD_STRING
];
1198 WCHAR wszError
[MAX_LOAD_STRING
];
1201 LoadStringW(globals
.hMainInst
, IDS_ERROR_LOADTYPELIB
, wszError
, ARRAY_SIZE(wszError
));
1202 args
[0] = (DWORD_PTR
)typelib
.wszFileName
;
1204 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1205 wszError
, 0, 0, wszMessage
, ARRAY_SIZE(wszMessage
), (__ms_va_list
*)args
);
1206 MessageBoxW(globals
.hMainWnd
, wszMessage
, NULL
, MB_OK
|MB_ICONEXCLAMATION
);
1209 count
= ITypeLib_GetTypeInfoCount(pTypeLib
);
1211 ITypeLib_GetDocumentation(pTypeLib
, -1, &bstrName
, &bstrData
, NULL
, NULL
);
1212 ITypeLib_GetLibAttr(pTypeLib
, &pTLibAttr
);
1214 tld
= InitializeTLData();
1215 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1216 AddToTLDataStrW(tld
, wszGeneratedInfo
);
1217 AddToTLDataStrW(tld
, typelib
.wszFileName
);
1218 AddToTLDataStrW(tld
, wszNewLine
);
1219 AddToTLDataStrW(tld
, wszNewLine
);
1220 AddToTLDataStrW(tld
, wszOpenBrackets1
);
1221 AddToTLDataStrW(tld
, wszNewLine
);
1222 AddSpaces(tld
, TAB_SIZE
);
1223 AddToTLDataStrW(tld
, wszUUID
);
1224 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1225 StringFromGUID2(&(pTLibAttr
->guid
), wszText
, MAX_LOAD_STRING
);
1226 wszText
[lstrlenW(wszText
)-1] = '\0';
1227 AddToTLDataStrW(tld
, &wszText
[1]);
1228 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1229 AddToTLDataStrW(tld
, wszComa
);
1230 AddToTLDataStrW(tld
, wszNewLine
);
1231 AddSpaces(tld
, TAB_SIZE
);
1232 wsprintfW(wszText
, wszFormat2
, pTLibAttr
->wMajorVerNum
, pTLibAttr
->wMinorVerNum
);
1233 AddToTLDataStrW(tld
, wszText
);
1237 /* helpstring is optional */
1238 AddToTLDataStrW(tld
, wszComa
);
1239 AddToTLDataStrW(tld
, wszNewLine
);
1240 AddSpaces(tld
, TAB_SIZE
);
1241 AddToTLDataStrW(tld
, wszHelpstring
);
1242 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1243 AddToTLDataStrW(tld
, wszInvertedComa
);
1244 AddToTLDataStrW(tld
, bstrData
);
1245 AddToTLDataStrW(tld
, wszInvertedComa
);
1246 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1249 AddToTLDataStrW(tld
, wszNewLine
);
1250 AddToTLDataStrW(tld
, wszCloseBrackets1
);
1251 AddToTLDataStrW(tld
, wszNewLine
);
1252 AddToTLDataStrW(tld
, wszLibrary
);
1253 if (bstrName
) AddToTLDataStrW(tld
, bstrName
);
1254 AddToTLDataStrW(tld
, wszNewLine
);
1255 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1256 AddToTLDataStrW(tld
, wszNewLine
);
1258 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1259 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1261 wsprintfW(wszText
, wszFormat
, bstrName
, bstrData
);
1262 SysFreeString(bstrName
);
1263 SysFreeString(bstrData
);
1264 tvis
.hParent
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1265 TVM_INSERTITEMW
, 0, (LPARAM
)&tvis
);
1267 for(i
=0; i
<count
; i
++)
1270 ITypeLib_GetTypeInfo(pTypeLib
, i
, &pTypeInfo
);
1272 ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, &bstrName
, &bstrData
,
1273 &ulHelpContext
, NULL
);
1274 ITypeInfo_GetTypeAttr(pTypeInfo
, &pTypeAttr
);
1276 memset(wszText
, 0, sizeof(wszText
));
1277 memset(wszAfter
, 0, sizeof(wszAfter
));
1278 tld
= InitializeTLData();
1279 U(tvis
).item
.lParam
= (LPARAM
)tld
;
1280 switch(pTypeAttr
->typekind
)
1283 AddToStrW(wszText
, wszTKIND_ENUM
);
1284 AddToStrW(wszText
, bstrName
);
1286 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1287 AddToTLDataStrW(tld
, &wszTKIND_ENUM
[lstrlenW(wszTKIND_ALIAS
)]);
1288 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1289 AddToTLDataStrW(tld
,wszNewLine
);
1290 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1291 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1292 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1293 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1294 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1297 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1298 EnumEnums(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1299 AddChildrenData(hParent
, tld
);
1300 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1303 AddToTLDataStrW(tld
, wszTKIND_RECORD
);
1304 AddToTLDataStrW(tld
, wszTag
);
1305 AddToTLDataStrW(tld
, bstrName
);
1306 AddToTLDataStrW(tld
, wszSpace
);
1307 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1308 AddToTLDataStrW(tld
, wszNewLine
);
1310 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1311 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1312 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1313 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1314 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1316 AddToStrW(wszText
, wszTKIND_RECORD
);
1317 AddToStrW(wszText
, bstrName
);
1320 AddToStrW(wszText
, wszTKIND_MODULE
);
1321 AddToStrW(wszText
, bstrName
);
1323 case TKIND_INTERFACE
:
1324 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1325 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1326 tld
->bPredefine
= TRUE
;
1328 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1329 AddToStrW(wszText
, bstrName
);
1332 AddToStrW(wszText
, wszTKIND_COCLASS
);
1333 AddToStrW(wszText
, bstrName
);
1335 CreateCoclassHeader(pTypeInfo
, pTypeAttr
, tld
);
1336 AddToTLDataStrW(tld
, wszTKIND_COCLASS
);
1337 AddToTLDataStrW(tld
, bstrName
);
1338 AddToTLDataStrW(tld
, wszSpace
);
1339 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1340 AddToTLDataStrW(tld
, wszNewLine
);
1342 EnumCoclassImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, tld
);
1344 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1345 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1346 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1349 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1350 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1353 AddToStrW(wszText
, wszTKIND_UNION
);
1354 AddToStrW(wszText
, bstrName
);
1356 case TKIND_DISPATCH
:
1357 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1358 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1359 tld
->bPredefine
= TRUE
;
1360 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
1362 AddToStrW(wszText
, wszTKIND_DISPATCH
);
1363 AddToStrW(wszText
, bstrName
);
1365 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1366 hMain
= tvis
.hParent
;
1369 lstrcpyW(wszText
, wszProperties
);
1370 tvis
.hParent
= hParent
;
1371 tld
= InitializeTLData();
1372 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1373 AddToTLDataStrW(tld
, wszProperties
);
1374 AddToTLDataStrW(tld
, wszColon
);
1375 AddToTLDataStrW(tld
, wszNewLine
);
1376 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1377 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, tvis
.hParent
);
1378 AddChildrenData(tvis
.hParent
, tld
);
1380 lstrcpyW(wszText
, wszMethods
);
1381 tvis
.hParent
= hParent
;
1382 tld
= InitializeTLData();
1383 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1384 AddToTLDataStrW(tld
, wszMethods
);
1385 AddToTLDataStrW(tld
, wszColon
);
1386 AddToTLDataStrW(tld
, wszNewLine
);
1387 tvis
.hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1388 EnumFuncs(pTypeInfo
, pTypeAttr
, tvis
.hParent
);
1389 AddChildrenData(tvis
.hParent
, tld
);
1391 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1392 AddChildrenData(hParent
, tldDispatch
);
1393 AddToTLDataStrW(tldDispatch
, tldDispatch
->wszInsertAfter
);
1396 tvis
.hParent
= hMain
;
1398 if(SUCCEEDED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, -1, &hRefType
)))
1402 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1403 SysFreeString(bstrName
);
1404 SysFreeString(bstrData
);
1406 memset(wszText
, 0, sizeof(wszText
));
1407 tld
= InitializeTLData();
1408 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1410 ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
);
1411 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1412 &bstrData
, &ulHelpContext
, NULL
);
1413 ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
);
1415 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1416 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1417 tld
->bPredefine
= TRUE
;
1419 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1420 AddToStrW(wszText
, bstrName
);
1421 ITypeInfo_Release(pRefTypeInfo
);
1425 AddToStrW(wszText
, wszTKIND_ALIAS
);
1426 CreateTypeInfo(wszText
, wszAfter
, pTypeAttr
->tdescAlias
, pTypeInfo
);
1427 AddToStrW(wszText
, wszSpace
);
1428 AddToStrW(wszText
, bstrName
);
1429 AddToStrW(wszText
, wszAfter
);
1431 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1432 AddToTLDataStrW(tld
, &wszText
[lstrlenW(wszTKIND_ALIAS
)]);
1433 AddToTLDataStrW(tld
, wszSemicolon
);
1434 AddToTLDataStrW(tld
, wszNewLine
);
1437 lstrcpyW(wszText
, bstrName
);
1438 WINE_FIXME("pTypeAttr->typekind == %d not supported\n",
1439 pTypeAttr
->typekind
);
1444 hParent
= TreeView_InsertItemW(typelib
.hTree
, &tvis
);
1446 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1447 EnumFuncs(pTypeInfo
, pTypeAttr
, hParent
);
1448 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1450 if(memcmp(bstrName
, wszVT_UNKNOWN
, sizeof(wszVT_UNKNOWN
)))
1451 AddChildrenData(hParent
, tld
);
1452 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1455 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1456 ITypeInfo_Release(pTypeInfo
);
1457 SysFreeString(bstrName
);
1458 SysFreeString(bstrData
);
1460 SendMessageW(typelib
.hTree
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
)tvis
.hParent
);
1462 memset(&tvi
, 0, sizeof(TVITEMW
));
1463 tvi
.mask
= TVIF_PARAM
;
1464 tvi
.hItem
= tvis
.hParent
;
1466 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1467 AddPredefinitions(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1468 AddIdlData(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1469 AddToTLDataStrW((TYPELIB_DATA
*)(tvi
.lParam
),
1470 ((TYPELIB_DATA
*)(tvi
.lParam
))->wszInsertAfter
);
1472 ITypeLib_Release(pTypeLib
);
1476 void UpdateData(HTREEITEM item
)
1480 memset(&tvi
, 0, sizeof(TVITEMW
));
1481 tvi
.mask
= TVIF_PARAM
;
1484 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1487 SetWindowTextW(typelib
.hEdit
, wszSpace
);
1491 SetWindowTextW(typelib
.hEdit
, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1494 static void TypeLibResizeChild(void)
1498 MoveWindow(typelib
.hStatusBar
, 0, 0, 0, 0, TRUE
);
1500 if(IsWindowVisible(typelib
.hStatusBar
))
1501 GetClientRect(typelib
.hStatusBar
, &stat
);
1502 else stat
.bottom
= 0;
1504 GetClientRect(globals
.hTypeLibWnd
, &client
);
1505 MoveWindow(typelib
.hPaneWnd
, 0, 0,
1506 client
.right
, client
.bottom
-stat
.bottom
, TRUE
);
1509 static void TypeLibMenuCommand(WPARAM wParam
, HWND hWnd
)
1519 vis
= IsWindowVisible(typelib
.hStatusBar
);
1520 ShowWindow(typelib
.hStatusBar
, vis
? SW_HIDE
: SW_SHOW
);
1521 CheckMenuItem(GetMenu(hWnd
), LOWORD(wParam
),
1522 vis
? MF_UNCHECKED
: MF_CHECKED
);
1523 TypeLibResizeChild();
1526 DestroyWindow(hWnd
);
1531 static void UpdateTypeLibStatusBar(int itemID
)
1533 WCHAR info
[MAX_LOAD_STRING
];
1535 if(!LoadStringW(globals
.hMainInst
, itemID
, info
, ARRAY_SIZE(info
)))
1536 LoadStringW(globals
.hMainInst
, IDS_READY
, info
, ARRAY_SIZE(info
));
1538 SendMessageW(typelib
.hStatusBar
, SB_SETTEXTW
, 0, (LPARAM
)info
);
1541 static void EmptyTLTree(void)
1546 tvi
.mask
= TVIF_PARAM
;
1547 cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
1548 TVGN_CHILD
, (LPARAM
)TVI_ROOT
);
1553 cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
, TVM_GETNEXTITEM
,
1554 TVGN_CHILD
, (LPARAM
)del
);
1556 if(!cur
) cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1557 TVM_GETNEXTITEM
, TVGN_NEXT
, (LPARAM
)del
);
1558 if(!cur
) cur
= (HTREEITEM
)SendMessageW(typelib
.hTree
,
1559 TVM_GETNEXTITEM
, TVGN_PARENT
, (LPARAM
)del
);
1562 SendMessageW(typelib
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1565 HeapFree(GetProcessHeap(), 0, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1566 HeapFree(GetProcessHeap(), 0, (TYPELIB_DATA
*)tvi
.lParam
);
1569 SendMessageW(typelib
.hTree
, TVM_DELETEITEM
, 0, (LPARAM
)del
);
1575 static LRESULT CALLBACK
TypeLibProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1581 if(!CreatePanedWindow(hWnd
, &typelib
.hPaneWnd
, globals
.hMainInst
))
1582 DestroyWindow(hWnd
);
1583 typelib
.hTree
= CreateWindowExW(WS_EX_CLIENTEDGE
, WC_TREEVIEWW
, NULL
,
1584 WS_CHILD
|WS_VISIBLE
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_LINESATROOT
,
1585 0, 0, 0, 0, typelib
.hPaneWnd
, (HMENU
)TYPELIB_TREE
,
1586 globals
.hMainInst
, NULL
);
1587 typelib
.hEdit
= CreateWindowExW(WS_EX_CLIENTEDGE
, WC_EDITW
, NULL
,
1588 WS_CHILD
|WS_VISIBLE
|ES_MULTILINE
|ES_READONLY
|WS_HSCROLL
|WS_VSCROLL
,
1589 0, 0, 0, 0, typelib
.hPaneWnd
, NULL
, globals
.hMainInst
, NULL
);
1591 SetLeft(typelib
.hPaneWnd
, typelib
.hTree
);
1592 SetRight(typelib
.hPaneWnd
, typelib
.hEdit
);
1594 if(PopulateTree()) DestroyWindow(hWnd
);
1595 else SetFocus(typelib
.hTree
);
1599 TypeLibMenuCommand(LOWORD(wParam
), hWnd
);
1602 UpdateTypeLibStatusBar(LOWORD(wParam
));
1605 SetFocus(typelib
.hTree
);
1608 if(wParam
== SIZE_MINIMIZED
) break;
1609 TypeLibResizeChild();
1615 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
1620 BOOL
TypeLibRegisterClassW(void)
1624 memset(&wcc
, 0, sizeof(WNDCLASSW
));
1625 wcc
.lpfnWndProc
= TypeLibProc
;
1626 wcc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1627 wcc
.hCursor
= LoadCursorW(0, (LPCWSTR
)IDC_ARROW
);
1628 wcc
.lpszMenuName
= MAKEINTRESOURCEW(IDM_TYPELIB
);
1629 wcc
.lpszClassName
= wszTypeLib
;
1631 if(!RegisterClassW(&wcc
))
1637 BOOL
CreateTypeLibWindow(HINSTANCE hInst
, WCHAR
*wszFileName
)
1639 WCHAR wszTitle
[MAX_LOAD_STRING
];
1640 LoadStringW(hInst
, IDS_TYPELIBTITLE
, wszTitle
, ARRAY_SIZE(wszTitle
));
1642 if(wszFileName
) lstrcpyW(typelib
.wszFileName
, wszFileName
);
1647 memset(&tvi
, 0, sizeof(TVITEMW
));
1648 tvi
.hItem
= (HTREEITEM
)SendMessageW(globals
.hTree
, TVM_GETNEXTITEM
,
1651 SendMessageW(globals
.hTree
, TVM_GETITEMW
, 0, (LPARAM
)&tvi
);
1652 lstrcpyW(typelib
.wszFileName
, ((ITEM_INFO
*)tvi
.lParam
)->path
);
1655 globals
.hTypeLibWnd
= CreateWindowW(wszTypeLib
, wszTitle
,
1656 WS_OVERLAPPEDWINDOW
|WS_VISIBLE
,
1657 CW_USEDEFAULT
, CW_USEDEFAULT
, 800, 600, NULL
, NULL
, hInst
, NULL
);
1658 if(!globals
.hTypeLibWnd
) return FALSE
;
1660 typelib
.hStatusBar
= CreateStatusWindowW(WS_VISIBLE
|WS_CHILD
,
1661 wszTitle
, globals
.hTypeLibWnd
, 0);
1663 TypeLibResizeChild();