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"
24 #include "wine/unicode.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(oleview
);
29 static const WCHAR wszTypeLib
[] = { 'T','Y','P','E','L','I','B','\0' };
31 static const WCHAR wszFailed
[] = { '<','f','a','i','l','e','d','>','\0' };
32 static const WCHAR wszSpace
[] = { ' ','\0' };
33 static const WCHAR wszAsterix
[] = { '*','\0' };
34 static const WCHAR wszComa
[] = { ',','\0' };
35 static const WCHAR wszEquals
[] = { '=','\0' };
36 static const WCHAR wszSemicolon
[] = { ';','\0' };
37 static const WCHAR wszNewLine
[] = { '\n','\0' };
38 static const WCHAR wszOpenBrackets1
[] = { '[','\0' };
39 static const WCHAR wszCloseBrackets1
[] = { ']','\0' };
40 static const WCHAR wszOpenBrackets2
[] = { '(','\0' };
41 static const WCHAR wszCloseBrackets2
[] = { ')','\0' };
42 static const WCHAR wszOpenBrackets3
[] = { '{','\0' };
43 static const WCHAR wszCloseBrackets3
[] = { '}','\0' };
44 static const WCHAR wszInvertedComa
[] = { '"','\0' };
45 static const WCHAR wszColon
[] = { ':','\0' };
47 static const WCHAR wszUUID
[] = { 'u','u','i','d','\0' };
48 static const WCHAR wszOdl
[] = { 'o','d','l','\0' };
50 static const WCHAR wszVT_BOOL
[]
51 = { 'V','A','R','I','A','N','T','_','B','O','O','L','\0' };
52 static const WCHAR wszVT_UI1
[]
53 = { 'u','n','s','i','g','n','e','d',' ','c','h','a','r','\0' };
54 static const WCHAR wszVT_UI2
[]
55 = { 'u','n','s','i','g','n','e','d',' ','s','h','o','r','t','\0' };
56 static const WCHAR wszVT_UI4
[]
57 = { 'u','n','s','i','g','n','e','d',' ','l','o','n','g','\0' };
58 static const WCHAR wszVT_UI8
[] = { 'u','i','n','t','6','4','\0' };
59 static const WCHAR wszVT_UINT
[]
60 = { 'u','n','s','i','g','n','e','d',' ','i','n','t','\0' };
61 static const WCHAR wszVT_I1
[] = { 'c','h','a','r','\0' };
62 static const WCHAR wszVT_I2
[] = { 's','h','o','r','t','\0' };
63 static const WCHAR wszVT_I4
[] = { 'l','o','n','g','\0' };
64 static const WCHAR wszVT_I8
[] = { 'i','n','t','6','4','\0' };
65 static const WCHAR wszVT_R4
[] = { 's','i','n','g','l','e','\0' };
66 static const WCHAR wszVT_INT
[] = { 'i','n','t','\0' };
67 static const WCHAR wszVT_BSTR
[] = { 'B','S','T','R','\0' };
68 static const WCHAR wszVT_CY
[] = { 'C','U','R','R','E','N','C','Y','\0' };
69 static const WCHAR wszVT_VARIANT
[] = { 'V','A','R','I','A','N','T','\0' };
70 static const WCHAR wszVT_VOID
[] = { 'v','o','i','d','\0' };
71 static const WCHAR wszVT_ERROR
[] = { 'S','C','O','D','E','\0' };
72 static const WCHAR wszVT_LPSTR
[] = { 'L','P','S','T','R','\0' };
73 static const WCHAR wszVT_LPWSTR
[] = { 'L','P','W','S','T','R','\0' };
74 static const WCHAR wszVT_HRESULT
[] = { 'H','R','E','S','U','L','T','\0' };
75 static const WCHAR wszVT_UNKNOWN
[] = { 'I','U','n','k','n','o','w','n','\0' };
76 static const WCHAR wszVT_DISPATCH
[] = { 'I','D','i','s','p','a','t','c','h','\0' };
77 static const WCHAR wszVT_DATE
[] = { 'D','A','T','E','\0' };
78 static const WCHAR wszVT_R8
[] = { 'd','o','u','b','l','e','\0' };
79 static const WCHAR wszVT_SAFEARRAY
[] = { 'S','A','F','E','A','R','R','A','Y','\0' };
81 static const WCHAR wszFormat
[] = { '0','x','%','.','8','l','x','\0' };
82 static const WCHAR wszStdCall
[] = { '_','s','t','d','c','a','l','l','\0' };
83 static const WCHAR wszId
[] = { 'i','d','\0' };
84 static const WCHAR wszHelpstring
[] = { 'h','e','l','p','s','t','r','i','n','g','\0' };
85 static const WCHAR wszPropPut
[] = { 'p','r','o','p','p','u','t','\0' };
86 static const WCHAR wszPropGet
[] = { 'p','r','o','p','g','e','t','\0' };
87 static const WCHAR wszPropPutRef
[] = { 'p','r','o','p','p','u','t','r','e','f','\0' };
88 static const WCHAR wszPARAMFLAG_FIN
[] = { 'i','n','\0' };
89 static const WCHAR wszPARAMFLAG_FOUT
[] = { 'o','u','t','\0' };
90 static const WCHAR wszPARAMFLAG_FLCID
[] = { 'c','i','d','\0' };
91 static const WCHAR wszPARAMFLAG_FRETVAL
[] = { 'r','e','t','v','a','l','\0' };
92 static const WCHAR wszPARAMFLAG_FOPT
[] = { 'o','p','t','i','o','n','a','l','\0' };
93 static const WCHAR wszPARAMFLAG_FHASCUSTDATA
[]
94 = { 'h','a','s','c','u','s','t','d','a','t','a','\0' };
95 static const WCHAR wszDefaultValue
[]
96 = { 'd','e','f','a','u','l','t','v','a','l','u','e','\0' };
98 static const WCHAR wszReadOnly
[] = { 'r','e','a','d','o','n','l','y','\0' };
99 static const WCHAR wszConst
[] = { 'c','o','n','s','t','\0' };
101 static void ShowLastError(void)
103 DWORD error
= GetLastError();
105 WCHAR wszTitle
[MAX_LOAD_STRING
];
107 LoadString(globals
.hMainInst
, IDS_TYPELIBTITLE
, wszTitle
,
108 sizeof(wszTitle
)/sizeof(wszTitle
[0]));
109 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
110 NULL
, error
, 0, (LPTSTR
) &lpMsgBuf
, 0, NULL
);
111 MessageBox(NULL
, lpMsgBuf
, wszTitle
, MB_OK
| MB_ICONERROR
);
116 static void SaveIdl(WCHAR
*wszFileName
)
121 DWORD len
, dwNumWrite
;
125 hIDL
= TreeView_GetChild(typelib
.hTree
, TVI_ROOT
);
127 memset(&tvi
, 0, sizeof(TVITEM
));
130 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
131 data
= (TYPELIB_DATA
*)tvi
.lParam
;
133 hFile
= CreateFile(wszFileName
, GENERIC_WRITE
, FILE_SHARE_WRITE
,
134 NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
135 if(hFile
== INVALID_HANDLE_VALUE
)
141 len
= WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, NULL
, 0, NULL
, NULL
);
142 wszIdl
= HeapAlloc(GetProcessHeap(), 0, len
);
143 WideCharToMultiByte( CP_UTF8
, 0, data
->idl
, data
->idlLen
, wszIdl
, len
, NULL
, NULL
);
145 if(!WriteFile(hFile
, wszIdl
, len
, &dwNumWrite
, NULL
))
148 HeapFree(GetProcessHeap(), 0, wszIdl
);
152 static void GetSaveIdlAsPath(void)
154 OPENFILENAME saveidl
;
156 WCHAR wszPath
[MAX_LOAD_STRING
];
157 WCHAR wszDir
[MAX_LOAD_STRING
];
158 static const WCHAR wszDefaultExt
[] = { 'i','d','l',0 };
159 static const WCHAR wszIdlFiles
[] = { '*','.','i','d','l','\0','\0' };
161 memset(&saveidl
, 0, sizeof(saveidl
));
163 lstrcpyW(wszDir
, typelib
.wszFileName
);
164 pFileName
= wszDir
+ lstrlenW(wszDir
);
165 while(*pFileName
!= '.' && *pFileName
!= '\\' && *pFileName
!= '/'
166 && pFileName
> wszDir
) pFileName
-= 1;
167 if(*pFileName
== '.')
170 while(*pFileName
!= '\\' && *pFileName
!= '/' && pFileName
> wszDir
)
173 if(*pFileName
== '\\' || *pFileName
== '/') pFileName
+= 1;
174 lstrcpyW(wszPath
, pFileName
);
176 GetCurrentDirectory(MAX_LOAD_STRING
, wszDir
);
178 saveidl
.lStructSize
= sizeof(OPENFILENAME
);
179 saveidl
.hwndOwner
= globals
.hTypeLibWnd
;
180 saveidl
.hInstance
= globals
.hMainInst
;
181 saveidl
.lpstrFilter
= wszIdlFiles
;
182 saveidl
.lpstrFile
= wszPath
;
183 saveidl
.nMaxFile
= MAX_LOAD_STRING
;
184 saveidl
.lpstrInitialDir
= wszDir
;
185 saveidl
.Flags
= OFN_PATHMUSTEXIST
| OFN_OVERWRITEPROMPT
| OFN_HIDEREADONLY
;
186 saveidl
.lpstrDefExt
= wszDefaultExt
;
188 if (GetSaveFileName(&saveidl
))
192 static void AddToStrW(WCHAR
*wszDest
, const WCHAR
*wszSource
)
194 lstrcpyW(&wszDest
[lstrlenW(wszDest
)], wszSource
);
197 static void AddToTLDataStrW(TYPELIB_DATA
*pTLData
, const WCHAR
*wszSource
)
199 int SourceLen
= lstrlenW(wszSource
);
201 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
202 sizeof(WCHAR
)*(pTLData
->idlLen
+SourceLen
+1));
204 memcpy(&pTLData
->idl
[pTLData
->idlLen
], wszSource
, sizeof(WCHAR
)*(SourceLen
+1));
205 pTLData
->idlLen
+= SourceLen
;
208 static void AddToTLDataStrWithTabsW(TYPELIB_DATA
*pTLData
, WCHAR
*wszSource
)
210 int lineLen
= lstrlenW(wszSource
);
212 WCHAR
*pSourcePos
= wszSource
;
218 if(*pSourcePos
== *wszNewLine
) newLinesNo
++;
221 if(*(pSourcePos
- 1) != *wszNewLine
) newLinesNo
++;
223 pTLData
->idl
= HeapReAlloc(GetProcessHeap(), 0, pTLData
->idl
,
224 sizeof(WCHAR
)*(pTLData
->idlLen
+lineLen
+4*newLinesNo
+1));
226 pSourcePos
= wszSource
;
227 pSourceBeg
= wszSource
;
230 if(*pSourcePos
!= *wszNewLine
&& *pSourcePos
)
240 lineLen
= lstrlenW(pSourceBeg
)+1;
244 else lineLen
= lstrlenW(pSourceBeg
);
246 pTLData
->idl
[pTLData
->idlLen
] = *wszSpace
;
247 pTLData
->idl
[pTLData
->idlLen
+1] = *wszSpace
;
248 pTLData
->idl
[pTLData
->idlLen
+2] = *wszSpace
;
249 pTLData
->idl
[pTLData
->idlLen
+3] = *wszSpace
;
250 memcpy(&pTLData
->idl
[pTLData
->idlLen
+4], pSourceBeg
, sizeof(WCHAR
)*lineLen
);
251 pTLData
->idlLen
+= lineLen
+ 4;
252 pTLData
->idl
[pTLData
->idlLen
] = '\0';
254 pSourceBeg
= pSourcePos
;
258 static TYPELIB_DATA
*InitializeTLData(void)
260 TYPELIB_DATA
*pTLData
;
262 pTLData
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(TYPELIB_DATA
));
264 pTLData
->idl
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
));
265 pTLData
->idl
[0] = '\0';
270 static void AddSpaces(TYPELIB_DATA
*pTLData
, int tabSize
)
272 for(; tabSize
>0; tabSize
--)
273 AddToTLDataStrW(pTLData
, wszSpace
);
276 static void AddChildrenData(HTREEITEM hParent
, TYPELIB_DATA
*pData
)
281 memset(&tvi
, 0, sizeof(tvi
));
283 hCur
= TreeView_GetChild(typelib
.hTree
, hParent
);
289 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
290 if(tvi
.lParam
&& ((TYPELIB_DATA
*)(tvi
.lParam
))->idlLen
)
291 AddToTLDataStrWithTabsW(pData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
292 }while((hCur
= TreeView_GetNextSibling(typelib
.hTree
, hCur
)));
295 static void CreateTypeInfo(WCHAR
*wszAddTo
, WCHAR
*wszAddAfter
, TYPEDESC tdesc
, ITypeInfo
*pTypeInfo
)
300 ITypeInfo
*pRefTypeInfo
;
301 WCHAR wszBuf
[MAX_LOAD_STRING
];
302 WCHAR wszFormat
[] = { '[','%','l','u',']','\0' };
304 switch(tdesc
.vt
&VT_TYPEMASK
)
306 #define VTADDTOSTR(x) case x:\
307 AddToStrW(wszAddTo, wsz##x);\
323 VTADDTOSTR(VT_VARIANT
);
325 VTADDTOSTR(VT_ERROR
);
326 VTADDTOSTR(VT_LPSTR
);
327 VTADDTOSTR(VT_LPWSTR
);
328 VTADDTOSTR(VT_HRESULT
);
329 VTADDTOSTR(VT_UNKNOWN
);
330 VTADDTOSTR(VT_DISPATCH
);
334 for(i
=0; i
<U(tdesc
).lpadesc
->cDims
; i
++)
336 wsprintfW(wszBuf
, wszFormat
, U(tdesc
).lpadesc
->rgbounds
[i
].cElements
);
337 AddToStrW(wszAddAfter
, wszBuf
);
339 CreateTypeInfo(wszAddTo
, wszAddAfter
, U(tdesc
).lpadesc
->tdescElem
, pTypeInfo
);
342 AddToStrW(wszAddTo
, wszVT_SAFEARRAY
);
343 AddToStrW(wszAddTo
, wszOpenBrackets2
);
344 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
345 AddToStrW(wszAddTo
, wszCloseBrackets2
);
348 CreateTypeInfo(wszAddTo
, wszAddAfter
, *U(tdesc
).lptdesc
, pTypeInfo
);
349 AddToStrW(wszAddTo
, wszAsterix
);
352 hRes
= ITypeInfo_GetRefTypeInfo(pTypeInfo
,
353 U(tdesc
).hreftype
, &pRefTypeInfo
);
356 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
,
357 &bstrData
, NULL
, NULL
, NULL
);
358 AddToStrW(wszAddTo
, bstrData
);
359 SysFreeString(bstrData
);
360 ITypeInfo_Release(pRefTypeInfo
);
362 else AddToStrW(wszAddTo
, wszFailed
);
365 WINE_FIXME("tdesc.vt&VT_TYPEMASK == %d not supported\n",
366 tdesc
.vt
&VT_TYPEMASK
);
370 static int EnumVars(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
376 WCHAR wszText
[MAX_LOAD_STRING
];
377 WCHAR wszAfter
[MAX_LOAD_STRING
];
379 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
380 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
381 U(tvis
).item
.pszText
= wszText
;
382 tvis
.hInsertAfter
= TVI_LAST
;
383 tvis
.hParent
= hParent
;
385 for(i
=0; i
<cVars
; i
++)
389 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
390 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
391 NULL
, NULL
, NULL
))) continue;
393 tld
= InitializeTLData();
394 U(tvis
).item
.lParam
= (LPARAM
) tld
;
395 if(pVarDesc
->memid
< MIN_VAR_ID
)
398 AddToTLDataStrW(tld
, wszOpenBrackets1
);
399 AddToTLDataStrW(tld
, wszId
);
400 AddToTLDataStrW(tld
, wszOpenBrackets2
);
401 wsprintfW(wszText
, wszFormat
, pVarDesc
->memid
);
402 AddToTLDataStrW(tld
, wszText
);
403 memset(wszText
, 0, sizeof(wszText
));
404 AddToTLDataStrW(tld
, wszCloseBrackets2
);
406 if(pVarDesc
->wVarFlags
& VARFLAG_FREADONLY
)
408 AddToTLDataStrW(tld
, wszComa
);
409 AddToTLDataStrW(tld
, wszSpace
);
410 AddToTLDataStrW(tld
, wszReadOnly
);
412 AddToTLDataStrW(tld
, wszCloseBrackets1
);
413 AddToTLDataStrW(tld
, wszNewLine
);
416 memset(wszText
, 0, sizeof(wszText
));
417 memset(wszAfter
, 0, sizeof(wszAfter
));
418 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
419 AddToStrW(wszText
, wszSpace
);
420 AddToStrW(wszText
, bstrName
);
421 AddToStrW(wszText
, wszAfter
);
422 AddToTLDataStrW(tld
, wszText
);
423 AddToTLDataStrW(tld
, wszSemicolon
);
424 AddToTLDataStrW(tld
, wszNewLine
);
426 SendMessage(typelib
.hTree
, TVM_INSERTITEM
, 0, (LPARAM
)&tvis
);
427 SysFreeString(bstrName
);
428 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
434 static int EnumEnums(ITypeInfo
*pTypeInfo
, int cVars
, HTREEITEM hParent
)
440 WCHAR wszText
[MAX_LOAD_STRING
];
441 WCHAR wszAfter
[MAX_LOAD_STRING
];
443 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
444 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
445 U(tvis
).item
.pszText
= wszText
;
446 tvis
.hInsertAfter
= TVI_LAST
;
447 tvis
.hParent
= hParent
;
449 for(i
=0; i
<cVars
; i
++)
453 if(FAILED(ITypeInfo_GetVarDesc(pTypeInfo
, i
, &pVarDesc
))) continue;
454 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pVarDesc
->memid
, &bstrName
,
455 NULL
, NULL
, NULL
))) continue;
457 tld
= InitializeTLData();
458 U(tvis
).item
.lParam
= (LPARAM
) tld
;
460 memset(wszText
, 0, sizeof(wszText
));
461 memset(wszAfter
, 0, sizeof(wszAfter
));
463 if (pVarDesc
->varkind
== VAR_CONST
)
467 if (VariantChangeType(&var
, U(*pVarDesc
).lpvarValue
, 0, VT_BSTR
) == S_OK
)
469 AddToStrW(wszText
, wszConst
);
470 AddToStrW(wszText
, wszSpace
);
471 AddToStrW(wszAfter
, wszSpace
);
472 AddToStrW(wszAfter
, wszEquals
);
473 AddToStrW(wszAfter
, wszSpace
);
474 AddToStrW(wszAfter
, V_BSTR(&var
));
478 CreateTypeInfo(wszText
, wszAfter
, pVarDesc
->elemdescVar
.tdesc
, pTypeInfo
);
479 AddToStrW(wszText
, wszSpace
);
480 AddToStrW(wszText
, bstrName
);
481 AddToStrW(wszText
, wszAfter
);
482 AddToTLDataStrW(tld
, bstrName
);
483 AddToTLDataStrW(tld
, wszAfter
);
485 AddToTLDataStrW(tld
, wszComa
);
486 AddToTLDataStrW(tld
, wszNewLine
);
488 SendMessage(typelib
.hTree
, TVM_INSERTITEM
, 0, (LPARAM
)&tvis
);
489 SysFreeString(bstrName
);
490 ITypeInfo_ReleaseVarDesc(pTypeInfo
, pVarDesc
);
496 static int EnumFuncs(ITypeInfo
*pTypeInfo
, TYPEATTR
*pTypeAttr
, HTREEITEM hParent
)
503 BSTR bstrName
, bstrHelpString
, *bstrParamNames
;
504 WCHAR wszText
[MAX_LOAD_STRING
];
505 WCHAR wszAfter
[MAX_LOAD_STRING
];
506 WCHAR szRhs
[] = {'r','h','s',0}; /* Right-hand side of a propput */
509 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
510 tvis
.hInsertAfter
= TVI_LAST
;
511 tvis
.hParent
= hParent
;
513 cFuncs
= pTypeAttr
->cFuncs
;
516 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
) { /* skip 7 members of IDispatch */
525 if(FAILED(ITypeInfo_GetFuncDesc(pTypeInfo
, i
, &pFuncDesc
))) continue;
527 if(FAILED(ITypeInfo_GetDocumentation(pTypeInfo
, pFuncDesc
->memid
, &bstrName
,
528 &bstrHelpString
, NULL
, NULL
))) continue;
530 memset(wszText
, 0, sizeof(wszText
));
531 memset(wszAfter
, 0, sizeof(wszAfter
));
532 tld
= InitializeTLData();
533 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
534 U(tvis
).item
.pszText
= bstrName
;
535 U(tvis
).item
.lParam
= (LPARAM
) tld
;
537 if(pFuncDesc
->memid
< MIN_FUNC_ID
|| pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
539 AddToTLDataStrW(tld
, wszOpenBrackets1
);
541 AddToTLDataStrW(tld
, wszId
);
542 AddToTLDataStrW(tld
, wszOpenBrackets2
);
543 wsprintfW(wszText
, wszFormat
, pFuncDesc
->memid
);
544 AddToTLDataStrW(tld
, wszText
);
545 AddToTLDataStrW(tld
, wszCloseBrackets2
);
546 memset(wszText
, 0, sizeof(wszText
));
549 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->elemdescFunc
.tdesc
, pTypeInfo
);
550 switch(pFuncDesc
->invkind
)
552 case INVOKE_PROPERTYGET
:
553 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
556 AddToTLDataStrW(tld
, wszComa
);
557 AddToTLDataStrW(tld
, wszSpace
);
560 AddToTLDataStrW(tld
, wszPropGet
);
562 case INVOKE_PROPERTYPUT
:
563 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
566 AddToTLDataStrW(tld
, wszComa
);
567 AddToTLDataStrW(tld
, wszSpace
);
570 AddToTLDataStrW(tld
, wszPropPut
);
572 case INVOKE_PROPERTYPUTREF
:
573 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
576 AddToTLDataStrW(tld
, wszComa
);
577 AddToTLDataStrW(tld
, wszSpace
);
580 AddToTLDataStrW(tld
, wszPropPutRef
);
584 if(SysStringLen(bstrHelpString
))
586 if(bFirst
) AddToTLDataStrW(tld
, wszOpenBrackets1
);
589 AddToTLDataStrW(tld
, wszComa
);
590 AddToTLDataStrW(tld
, wszSpace
);
593 AddToTLDataStrW(tld
, wszHelpstring
);
594 AddToTLDataStrW(tld
, wszOpenBrackets2
);
595 AddToTLDataStrW(tld
, wszInvertedComa
);
596 AddToTLDataStrW(tld
, bstrHelpString
);
597 AddToTLDataStrW(tld
, wszInvertedComa
);
598 AddToTLDataStrW(tld
, wszCloseBrackets2
);
602 AddToTLDataStrW(tld
, wszCloseBrackets1
);
603 AddToTLDataStrW(tld
, wszNewLine
);
606 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FOLEAUTOMATION
) {
607 AddToTLDataStrW(tld
, wszVT_HRESULT
);
608 if(strcmpW(wszText
, wszVT_VOID
)) pFuncDesc
->cParams
++;
611 AddToTLDataStrW(tld
, wszText
);
612 AddToTLDataStrW(tld
, wszAfter
);
615 bstrParamNames
= HeapAlloc(GetProcessHeap(), 0,
616 sizeof(BSTR
*)*(pFuncDesc
->cParams
+1));
617 if(FAILED(ITypeInfo_GetNames(pTypeInfo
, pFuncDesc
->memid
, bstrParamNames
,
618 pFuncDesc
->cParams
+1, &namesNo
)))
620 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
623 SysFreeString(bstrParamNames
[0]);
625 AddToTLDataStrW(tld
, wszSpace
);
626 if(pFuncDesc
->memid
>= MIN_FUNC_ID
)
628 AddToTLDataStrW(tld
, wszStdCall
);
629 AddToTLDataStrW(tld
, wszSpace
);
631 AddToTLDataStrW(tld
, bstrName
);
632 AddToTLDataStrW(tld
, wszOpenBrackets2
);
634 for(j
=0; j
<pFuncDesc
->cParams
; j
++)
636 if(j
!= 0) AddToTLDataStrW(tld
, wszComa
);
637 if(pFuncDesc
->cParams
!= 1)
639 AddToTLDataStrW(tld
, wszNewLine
);
640 AddSpaces(tld
, TAB_SIZE
);
643 #define ENUM_PARAM_FLAG(x)\
644 if(U(pFuncDesc->lprgelemdescParam[j]).paramdesc.wParamFlags & x) \
646 if(bFirst) AddToTLDataStrW(tld,\
650 AddToTLDataStrW(tld, wszComa);\
651 AddToTLDataStrW(tld, wszSpace);\
654 AddToTLDataStrW(tld, wsz##x);\
656 ENUM_PARAM_FLAG(PARAMFLAG_FIN
);
657 ENUM_PARAM_FLAG(PARAMFLAG_FOUT
);
658 ENUM_PARAM_FLAG(PARAMFLAG_FLCID
);
659 ENUM_PARAM_FLAG(PARAMFLAG_FRETVAL
);
660 ENUM_PARAM_FLAG(PARAMFLAG_FOPT
);
661 ENUM_PARAM_FLAG(PARAMFLAG_FHASCUSTDATA
);
663 if(U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
665 VARIANT var
, *param
=&U(pFuncDesc
->lprgelemdescParam
[j
]).paramdesc
.pparamdescex
->varDefaultValue
;
667 if(bFirst
) AddToTLDataStrW(tld
,
671 AddToTLDataStrW(tld
, wszComa
);
672 AddToTLDataStrW(tld
, wszSpace
);
675 AddToTLDataStrW(tld
, wszDefaultValue
);
676 AddToTLDataStrW(tld
, wszOpenBrackets2
);
677 if (V_VT(param
) == VT_BSTR
)
679 AddToTLDataStrW(tld
, wszInvertedComa
);
680 AddToTLDataStrW(tld
, V_BSTR(param
));
681 AddToTLDataStrW(tld
, wszInvertedComa
);
682 } else if (VariantChangeType(&var
, param
, 0, VT_BSTR
) == S_OK
)
683 AddToTLDataStrW(tld
, V_BSTR(&var
));
684 AddToTLDataStrW(tld
, wszCloseBrackets2
);
689 AddToTLDataStrW(tld
, wszCloseBrackets1
);
690 AddToTLDataStrW(tld
, wszSpace
);
693 memset(wszText
, 0, sizeof(wszText
));
694 memset(wszAfter
, 0, sizeof(wszAfter
));
695 CreateTypeInfo(wszText
, wszAfter
, pFuncDesc
->lprgelemdescParam
[j
].tdesc
,
697 AddToTLDataStrW(tld
, wszText
);
698 AddToTLDataStrW(tld
, wszAfter
);
699 AddToTLDataStrW(tld
, wszSpace
);
701 AddToTLDataStrW(tld
, bstrParamNames
[j
+1]);
702 SysFreeString(bstrParamNames
[j
+1]);
704 AddToTLDataStrW(tld
, szRhs
);
707 AddToTLDataStrW(tld
, wszCloseBrackets2
);
708 AddToTLDataStrW(tld
, wszSemicolon
);
709 AddToTLDataStrW(tld
, wszNewLine
);
711 SendMessage(typelib
.hTree
, TVM_INSERTITEM
, 0, (LPARAM
)&tvis
);
712 HeapFree(GetProcessHeap(), 0, bstrParamNames
);
713 SysFreeString(bstrName
);
714 SysFreeString(bstrHelpString
);
715 ITypeInfo_ReleaseFuncDesc(pTypeInfo
, pFuncDesc
);
721 static int EnumImplTypes(ITypeInfo
*pTypeInfo
, int cImplTypes
, HTREEITEM hParent
)
725 ITypeInfo
*pRefTypeInfo
;
729 WCHAR wszInheritedInterfaces
[MAX_LOAD_STRING
];
731 if(!cImplTypes
) return 0;
733 LoadString(globals
.hMainInst
, IDS_INHERITINTERFACES
, wszInheritedInterfaces
,
734 sizeof(wszInheritedInterfaces
)/sizeof(wszInheritedInterfaces
[0]));
736 U(tvis
).item
.mask
= TVIF_TEXT
;
737 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
738 U(tvis
).item
.pszText
= wszInheritedInterfaces
;
739 tvis
.hInsertAfter
= TVI_LAST
;
740 tvis
.hParent
= hParent
;
742 tvis
.hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
744 for(i
=0; i
<cImplTypes
; i
++)
746 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
747 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
749 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
752 ITypeInfo_Release(pRefTypeInfo
);
755 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
757 ITypeInfo_Release(pRefTypeInfo
);
761 U(tvis
).item
.cchTextMax
= SysStringLen(bstrName
);
762 U(tvis
).item
.pszText
= bstrName
;
764 hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
765 EnumVars(pRefTypeInfo
, pTypeAttr
->cVars
, hParent
);
766 EnumFuncs(pRefTypeInfo
, pTypeAttr
, hParent
);
767 EnumImplTypes(pRefTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
769 SysFreeString(bstrName
);
770 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
771 ITypeInfo_Release(pRefTypeInfo
);
777 static void EnumCoclassImplTypes(ITypeInfo
*pTypeInfo
,
778 int cImplTypes
, TYPELIB_DATA
*pTLData
)
781 ITypeInfo
*pRefTypeInfo
;
787 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
788 const WCHAR wszTKIND_DISPATCH
[]
789 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
790 const WCHAR wszIMPLTYPEFLAG_FDEFAULT
[]
791 = { 'd','e','f','a','u','l','t','\0' };
792 const WCHAR wszIMPLTYPEFLAG_FSOURCE
[]
793 = { 's','o','u','r','c','e','\0' };
794 const WCHAR wszIMPLTYPEFLAG_FRESTRICTED
[]
795 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
797 for(i
=0; i
<cImplTypes
; i
++)
799 if(FAILED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, i
, &hRefType
))) continue;
800 if(FAILED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
802 if(FAILED(ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
805 ITypeInfo_Release(pRefTypeInfo
);
808 if(FAILED(ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
)))
810 ITypeInfo_Release(pRefTypeInfo
);
814 AddSpaces(pTLData
, TAB_SIZE
);
815 ITypeInfo_GetImplTypeFlags(pTypeInfo
, i
, &flags
);
817 #define ENUM_IMPLTYPEFLAG(x)\
820 if(bFirst) AddToTLDataStrW(pTLData,\
824 AddToTLDataStrW(pTLData, wszComa);\
825 AddToTLDataStrW(pTLData, wszSpace);\
828 AddToTLDataStrW(pTLData, wsz##x);\
830 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FDEFAULT
);
831 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FSOURCE
);
832 ENUM_IMPLTYPEFLAG(IMPLTYPEFLAG_FRESTRICTED
);
835 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
836 AddToTLDataStrW(pTLData
, wszSpace
);
839 if(pTypeAttr
->typekind
== TKIND_INTERFACE
||
840 (pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
))
841 AddToTLDataStrW(pTLData
, wszTKIND_INTERFACE
);
842 else if(pTypeAttr
->typekind
== TKIND_DISPATCH
)
843 AddToTLDataStrW(pTLData
, wszTKIND_DISPATCH
);
844 AddToTLDataStrW(pTLData
, wszSpace
);
846 AddToTLDataStrW(pTLData
, bstrName
);
847 AddToTLDataStrW(pTLData
, wszSemicolon
);
848 AddToTLDataStrW(pTLData
, wszNewLine
);
850 SysFreeString(bstrName
);
851 ITypeInfo_ReleaseTypeAttr(pRefTypeInfo
, pTypeAttr
);
852 ITypeInfo_Release(pRefTypeInfo
);
856 static void AddIdlData(HTREEITEM hCur
, TYPELIB_DATA
*pTLData
)
860 hCur
= TreeView_GetChild(typelib
.hTree
, hCur
);
861 memset(&tvi
, 0, sizeof(TVITEM
));
862 tvi
.mask
= TVIF_PARAM
;
867 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
868 if(!((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
) {
869 AddToTLDataStrW(pTLData
, wszNewLine
);
870 AddToTLDataStrWithTabsW(pTLData
, ((TYPELIB_DATA
*)(tvi
.lParam
))->idl
);
872 hCur
= TreeView_GetNextSibling(typelib
.hTree
, hCur
);
876 static void AddPredefinitions(HTREEITEM hFirst
, TYPELIB_DATA
*pTLData
)
880 WCHAR wszText
[MAX_LOAD_STRING
];
881 WCHAR wszPredefinition
[] = { '/','/',' ','T','L','i','b',' ',':','\n',
882 '/','/',' ','F','o','r','w','a','r','d',' ','d','e','c','l','a','r','e',' ',
883 'a','l','l',' ','t','y','p','e','s',' ','d','e','f','i','n','e','d',' ',
884 'i','n',' ','t','h','i','s',' ','t','y','p','e','l','i','b','\0' };
886 hFirst
= TreeView_GetChild(typelib
.hTree
, hFirst
);
888 AddToTLDataStrWithTabsW(pTLData
, wszPredefinition
);
889 AddToTLDataStrW(pTLData
, wszNewLine
);
892 memset(&tvi
, 0, sizeof(TVITEM
));
893 tvi
.mask
= TVIF_TEXT
|TVIF_PARAM
;
894 tvi
.cchTextMax
= MAX_LOAD_STRING
;
895 tvi
.pszText
= wszText
;
899 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
900 if(((TYPELIB_DATA
*)(tvi
.lParam
))->bPredefine
&&
901 !((TYPELIB_DATA
*)(tvi
.lParam
))->bHide
)
903 AddToStrW(wszText
, wszSemicolon
);
904 AddToTLDataStrWithTabsW(pTLData
, wszText
);
905 AddToTLDataStrW(pTLData
, wszNewLine
);
907 hCur
= TreeView_GetNextSibling(typelib
.hTree
, hCur
);
911 static void CreateInterfaceInfo(ITypeInfo
*pTypeInfo
, int cImplTypes
, WCHAR
*wszName
,
912 WCHAR
*wszHelpString
, unsigned long ulHelpContext
, TYPEATTR
*pTypeAttr
,
913 TYPELIB_DATA
*pTLData
)
915 ITypeInfo
*pRefTypeInfo
;
918 WCHAR wszGuid
[MAX_LOAD_STRING
];
919 WCHAR wszHelpContext
[MAX_LOAD_STRING
];
921 const WCHAR wszInterface
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
922 const WCHAR wszDispinterface
[]
923 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
924 const WCHAR wszHelpcontext
[] = { 'h','e','l','p','c','o','n','t','e','x','t','\0' };
925 const WCHAR wszTYPEFLAG_FAPPOBJECT
[] = { 'a','p','p','o','b','j','e','c','t','\0' };
926 const WCHAR wszTYPEFLAG_FCANCREATE
[] = { 'c','a','n','c','r','e','a','t','e','\0' };
927 const WCHAR wszTYPEFLAG_FLICENSED
[] = { 'l','i','c','e','n','s','e','d','\0' };
928 const WCHAR wszTYPEFLAG_FPREDECLID
[] = { 'p','r','e','d','e','c','l','i','d','\0' };
929 const WCHAR wszTYPEFLAG_FHIDDEN
[] = { 'h','i','d','d','e','n','\0' };
930 const WCHAR wszTYPEFLAG_FCONTROL
[] = { 'c','o','n','t','r','o','l','\0' };
931 const WCHAR wszTYPEFLAG_FDUAL
[] = { 'd','u','a','l','\0' };
932 const WCHAR wszTYPEFLAG_FNONEXTENSIBLE
[]
933 = { 'n','o','n','e','x','t','e','n','s','i','b','l','e','\0' };
934 const WCHAR wszTYPEFLAG_FOLEAUTOMATION
[]
935 = { 'o','l','e','a','u','t','o','m','a','t','i','o','n','\0' };
936 const WCHAR wszTYPEFLAG_FRESTRICTED
[]
937 = { 'r','e','s','t','r','i','c','t','e','d','\0' };
938 const WCHAR wszTYPEFLAG_FAGGREGATABLE
[]
939 = { 'a','g','g','r','e','g','a','t','a','b','l','e','\0' };
940 const WCHAR wszTYPEFLAG_FREPLACEABLE
[]
941 = { 'r','e','p','l','a','c','a','b','l','e','\0' };
942 const WCHAR wszTYPEFLAG_FREVERSEBIND
[]
943 = { 'r','e','v','e','r','s','e','b','i','n','d','\0' };
944 const WCHAR wszTYPEFLAG_FPROXY
[] = { 'p','r','o','x','y','\0' };
946 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
947 AddToTLDataStrW(pTLData
, wszNewLine
);
948 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
)
950 AddSpaces(pTLData
, TAB_SIZE
);
951 AddToTLDataStrW(pTLData
, wszOdl
);
952 AddToTLDataStrW(pTLData
, wszComa
);
953 AddToTLDataStrW(pTLData
, wszNewLine
);
955 AddSpaces(pTLData
, TAB_SIZE
);
956 AddToTLDataStrW(pTLData
, wszUUID
);
957 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
958 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
959 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
960 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
961 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
964 AddToTLDataStrW(pTLData
, wszComa
);
965 AddToTLDataStrW(pTLData
, wszNewLine
);
966 AddSpaces(pTLData
, TAB_SIZE
);
967 AddToTLDataStrW(pTLData
, wszHelpstring
);
968 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
969 AddToTLDataStrW(pTLData
, wszInvertedComa
);
970 AddToTLDataStrW(pTLData
, wszHelpString
);
971 AddToTLDataStrW(pTLData
, wszInvertedComa
);
972 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
976 AddToTLDataStrW(pTLData
, wszComa
);
977 AddToTLDataStrW(pTLData
, wszNewLine
);
978 AddSpaces(pTLData
, TAB_SIZE
);
979 AddToTLDataStrW(pTLData
, wszHelpcontext
);
980 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
981 wsprintfW(wszHelpContext
, wszFormat
, ulHelpContext
);
982 AddToTLDataStrW(pTLData
, wszHelpContext
);
983 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
985 if(pTypeAttr
->wTypeFlags
)
987 #define ENUM_FLAGS(x) if(pTypeAttr->wTypeFlags & x)\
989 AddToTLDataStrW(pTLData, wszComa);\
990 AddToTLDataStrW(pTLData, wszNewLine);\
991 AddSpaces(pTLData, TAB_SIZE);\
992 AddToTLDataStrW(pTLData, wsz##x);\
994 ENUM_FLAGS(TYPEFLAG_FAPPOBJECT
);
995 ENUM_FLAGS(TYPEFLAG_FCANCREATE
);
996 ENUM_FLAGS(TYPEFLAG_FLICENSED
);
997 ENUM_FLAGS(TYPEFLAG_FPREDECLID
);
998 ENUM_FLAGS(TYPEFLAG_FHIDDEN
);
999 ENUM_FLAGS(TYPEFLAG_FCONTROL
);
1000 ENUM_FLAGS(TYPEFLAG_FDUAL
);
1001 ENUM_FLAGS(TYPEFLAG_FNONEXTENSIBLE
);
1002 ENUM_FLAGS(TYPEFLAG_FOLEAUTOMATION
);
1003 ENUM_FLAGS(TYPEFLAG_FRESTRICTED
);
1004 ENUM_FLAGS(TYPEFLAG_FAGGREGATABLE
);
1005 ENUM_FLAGS(TYPEFLAG_FREPLACEABLE
);
1006 ENUM_FLAGS(TYPEFLAG_FREVERSEBIND
);
1007 ENUM_FLAGS(TYPEFLAG_FPROXY
);
1009 AddToTLDataStrW(pTLData
, wszNewLine
);
1010 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1011 AddToTLDataStrW(pTLData
, wszNewLine
);
1012 if(pTypeAttr
->typekind
!= TKIND_DISPATCH
) AddToTLDataStrW(pTLData
, wszInterface
);
1013 else AddToTLDataStrW(pTLData
, wszDispinterface
);
1014 AddToTLDataStrW(pTLData
, wszName
);
1015 AddToTLDataStrW(pTLData
, wszSpace
);
1016 if(cImplTypes
&& pTypeAttr
->typekind
!= TKIND_DISPATCH
)
1018 AddToTLDataStrW(pTLData
, wszColon
);
1019 AddToTLDataStrW(pTLData
, wszSpace
);
1021 ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, 0, &hRefType
);
1022 if (SUCCEEDED(ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
)))
1024 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1026 AddToTLDataStrW(pTLData
, bstrName
);
1027 AddToTLDataStrW(pTLData
, wszSpace
);
1029 SysFreeString(bstrName
);
1030 ITypeInfo_Release(pRefTypeInfo
);
1033 AddToTLDataStrW(pTLData
, wszFailed
);
1035 AddToTLDataStrW(pTLData
, wszOpenBrackets3
);
1036 AddToTLDataStrW(pTLData
, wszNewLine
);
1038 AddToStrW(pTLData
->wszInsertAfter
, wszCloseBrackets3
);
1039 AddToStrW(pTLData
->wszInsertAfter
, wszSemicolon
);
1040 AddToStrW(pTLData
->wszInsertAfter
, wszNewLine
);
1043 static void CreateTypedefHeader(ITypeInfo
*pTypeInfo
,
1044 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1047 WCHAR wszGuid
[MAX_LOAD_STRING
];
1048 const WCHAR wszTypedef
[] = { 't','y','p','e','d','e','f',' ','\0' };
1049 const WCHAR wszPublic
[] = { 'p','u','b','l','i','c','\0' };
1051 AddToTLDataStrW(pTLData
, wszTypedef
);
1052 if(memcmp(&pTypeAttr
->guid
, &GUID_NULL
, sizeof(GUID
)))
1054 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1056 AddToTLDataStrW(pTLData
, wszUUID
);
1057 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1058 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1059 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1060 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1061 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1063 if(pTypeAttr
->typekind
== TKIND_ALIAS
)
1065 if(bFirst
) AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1068 AddToTLDataStrW(pTLData
, wszComa
);
1069 AddToTLDataStrW(pTLData
, wszSpace
);
1072 AddToTLDataStrW(pTLData
, wszPublic
);
1076 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1077 AddToTLDataStrW(pTLData
, wszNewLine
);
1081 static void CreateCoclassHeader(ITypeInfo
*pTypeInfo
,
1082 TYPEATTR
*pTypeAttr
, TYPELIB_DATA
*pTLData
)
1084 WCHAR wszGuid
[MAX_LOAD_STRING
];
1085 BSTR bstrHelpString
;
1086 const WCHAR wszNoncreatable
[]
1087 = { 'n','o','n','c','r','e','a','t','a','b','l','e','\0' };
1089 AddToTLDataStrW(pTLData
, wszOpenBrackets1
);
1090 AddToTLDataStrW(pTLData
, wszNewLine
);
1092 AddSpaces(pTLData
, TAB_SIZE
);
1093 AddToTLDataStrW(pTLData
, wszUUID
);
1094 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1095 StringFromGUID2(&(pTypeAttr
->guid
), wszGuid
, MAX_LOAD_STRING
);
1096 wszGuid
[lstrlenW(wszGuid
)-1] = '\0';
1097 AddToTLDataStrW(pTLData
, &wszGuid
[1]);
1098 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1100 if(SUCCEEDED(ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, NULL
,
1101 &bstrHelpString
, NULL
, NULL
)))
1103 if(SysStringLen(bstrHelpString
))
1105 AddToTLDataStrW(pTLData
, wszComa
);
1106 AddToTLDataStrW(pTLData
, wszNewLine
);
1107 AddSpaces(pTLData
, TAB_SIZE
);
1108 AddToTLDataStrW(pTLData
, wszHelpstring
);
1109 AddToTLDataStrW(pTLData
, wszOpenBrackets2
);
1110 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1111 AddToTLDataStrW(pTLData
, bstrHelpString
);
1112 AddToTLDataStrW(pTLData
, wszInvertedComa
);
1113 AddToTLDataStrW(pTLData
, wszCloseBrackets2
);
1115 SysFreeString(bstrHelpString
);
1118 if(!(pTypeAttr
->wTypeFlags
& TYPEFLAG_FCANCREATE
))
1120 AddToTLDataStrW(pTLData
, wszComa
);
1121 AddToTLDataStrW(pTLData
, wszNewLine
);
1122 AddSpaces(pTLData
, TAB_SIZE
);
1123 AddToTLDataStrW(pTLData
, wszNoncreatable
);
1126 AddToTLDataStrW(pTLData
, wszNewLine
);
1127 AddToTLDataStrW(pTLData
, wszCloseBrackets1
);
1128 AddToTLDataStrW(pTLData
, wszNewLine
);
1131 static int PopulateTree(void)
1133 TVINSERTSTRUCT tvis
;
1136 TLIBATTR
*pTLibAttr
;
1137 ITypeInfo
*pTypeInfo
, *pRefTypeInfo
;
1139 TYPEATTR
*pTypeAttr
;
1141 ULONG ulHelpContext
;
1144 WCHAR wszText
[MAX_LOAD_STRING
];
1145 WCHAR wszAfter
[MAX_LOAD_STRING
];
1150 TYPELIB_DATA
*tldDispatch
;
1153 const WCHAR wszGeneratedInfo
[] = { '/','/',' ','G','e','n','e','r','a','t','e','d',
1154 ' ','.','I','D','L',' ','f','i','l','e',' ','(','b','y',' ','t','h','e',' ',
1155 'O','L','E','/','C','O','M',' ','O','b','j','e','c','t',' ',
1156 'V','i','e','w','e','r',')','\n','/','/','\n','/','/',' ',
1157 't','y','p','e','l','i','b',' ','f','i','l','e','n','a','m','e',':',' ','\0'};
1159 const WCHAR wszFormat
[] = { '%','s',' ','(','%','s',')','\0' };
1160 const WCHAR wszFormat2
[] = { 'v','e','r','s','i','o','n',
1161 '(','%','l','d','.','%','l','d',')','\0' };
1163 const WCHAR wszTKIND_ENUM
[] = { 't','y','p','e','d','e','f',' ','e','n','u','m',' ','\0' };
1164 const WCHAR wszTKIND_RECORD
[]
1165 = { 't','y','p','e','d','e','f',' ','s','t','r','u','c','t',' ','\0' };
1166 const WCHAR wszTKIND_MODULE
[] = { 'm','o','d','u','l','e',' ','\0' };
1167 const WCHAR wszTKIND_INTERFACE
[] = { 'i','n','t','e','r','f','a','c','e',' ','\0' };
1168 const WCHAR wszTKIND_DISPATCH
[]
1169 = { 'd','i','s','p','i','n','t','e','r','f','a','c','e',' ','\0' };
1170 const WCHAR wszTKIND_COCLASS
[] = { 'c','o','c','l','a','s','s',' ','\0' };
1171 const WCHAR wszTKIND_ALIAS
[] = { 't','y','p','e','d','e','f',' ','\0' };
1172 const WCHAR wszTKIND_UNION
[]
1173 = { 't','y','p','e','d','e','f',' ','u','n','i','o','n',' ','\0' };
1175 const WCHAR wszLibrary
[] = { 'l','i','b','r','a','r','y',' ','\0' };
1176 const WCHAR wszTag
[] = { 't','a','g','\0' };
1178 WCHAR wszProperties
[] = { 'p','r','o','p','e','r','t','i','e','s','\0' };
1179 WCHAR wszMethods
[] = { 'm','e','t','h','o','d','s','\0' };
1181 U(tvis
).item
.mask
= TVIF_TEXT
|TVIF_PARAM
;
1182 U(tvis
).item
.cchTextMax
= MAX_LOAD_STRING
;
1183 U(tvis
).item
.pszText
= wszText
;
1184 tvis
.hInsertAfter
= TVI_LAST
;
1185 tvis
.hParent
= TVI_ROOT
;
1187 if(FAILED((hRes
= LoadTypeLib(typelib
.wszFileName
, &pTypeLib
))))
1189 WCHAR wszMessage
[MAX_LOAD_STRING
];
1190 WCHAR wszError
[MAX_LOAD_STRING
];
1192 LoadString(globals
.hMainInst
, IDS_ERROR_LOADTYPELIB
,
1193 wszError
, sizeof(wszError
)/sizeof(wszError
[0]));
1194 wsprintfW(wszMessage
, wszError
, typelib
.wszFileName
, hRes
);
1195 MessageBox(globals
.hMainWnd
, wszMessage
, NULL
, MB_OK
|MB_ICONEXCLAMATION
);
1198 count
= ITypeLib_GetTypeInfoCount(pTypeLib
);
1200 ITypeLib_GetDocumentation(pTypeLib
, -1, &bstrName
, &bstrData
, NULL
, NULL
);
1201 ITypeLib_GetLibAttr(pTypeLib
, &pTLibAttr
);
1203 tld
= InitializeTLData();
1204 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1205 AddToTLDataStrW(tld
, wszGeneratedInfo
);
1206 AddToTLDataStrW(tld
, typelib
.wszFileName
);
1207 AddToTLDataStrW(tld
, wszNewLine
);
1208 AddToTLDataStrW(tld
, wszNewLine
);
1209 AddToTLDataStrW(tld
, wszOpenBrackets1
);
1210 AddToTLDataStrW(tld
, wszNewLine
);
1211 AddSpaces(tld
, TAB_SIZE
);
1212 AddToTLDataStrW(tld
, wszUUID
);
1213 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1214 StringFromGUID2(&(pTLibAttr
->guid
), wszText
, MAX_LOAD_STRING
);
1215 wszText
[lstrlenW(wszText
)-1] = '\0';
1216 AddToTLDataStrW(tld
, &wszText
[1]);
1217 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1218 AddToTLDataStrW(tld
, wszComa
);
1219 AddToTLDataStrW(tld
, wszNewLine
);
1220 AddSpaces(tld
, TAB_SIZE
);
1221 wsprintfW(wszText
, wszFormat2
, pTLibAttr
->wMajorVerNum
, pTLibAttr
->wMinorVerNum
);
1222 AddToTLDataStrW(tld
, wszText
);
1223 AddToTLDataStrW(tld
, wszComa
);
1224 AddToTLDataStrW(tld
, wszNewLine
);
1225 AddSpaces(tld
, TAB_SIZE
);
1226 AddToTLDataStrW(tld
, wszHelpstring
);
1227 AddToTLDataStrW(tld
, wszOpenBrackets2
);
1228 AddToTLDataStrW(tld
, wszInvertedComa
);
1229 AddToTLDataStrW(tld
, bstrData
);
1230 AddToTLDataStrW(tld
, wszInvertedComa
);
1231 AddToTLDataStrW(tld
, wszCloseBrackets2
);
1232 AddToTLDataStrW(tld
, wszNewLine
);
1233 AddToTLDataStrW(tld
, wszCloseBrackets1
);
1234 AddToTLDataStrW(tld
, wszNewLine
);
1235 AddToTLDataStrW(tld
, wszLibrary
);
1236 AddToTLDataStrW(tld
, bstrName
);
1237 AddToTLDataStrW(tld
, wszNewLine
);
1238 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1239 AddToTLDataStrW(tld
, wszNewLine
);
1241 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1242 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1244 wsprintfW(wszText
, wszFormat
, bstrName
, bstrData
);
1245 SysFreeString(bstrName
);
1246 SysFreeString(bstrData
);
1247 tvis
.hParent
= (HTREEITEM
)SendMessage(typelib
.hTree
,
1248 TVM_INSERTITEM
, 0, (LPARAM
)&tvis
);
1250 for(i
=0; i
<count
; i
++)
1253 ITypeLib_GetTypeInfo(pTypeLib
, i
, &pTypeInfo
);
1255 ITypeInfo_GetDocumentation(pTypeInfo
, MEMBERID_NIL
, &bstrName
, &bstrData
,
1256 &ulHelpContext
, NULL
);
1257 ITypeInfo_GetTypeAttr(pTypeInfo
, &pTypeAttr
);
1259 memset(wszText
, 0, sizeof(wszText
));
1260 memset(wszAfter
, 0, sizeof(wszAfter
));
1261 tld
= InitializeTLData();
1262 U(tvis
).item
.lParam
= (LPARAM
)tld
;
1263 switch(pTypeAttr
->typekind
)
1266 AddToStrW(wszText
, wszTKIND_ENUM
);
1267 AddToStrW(wszText
, bstrName
);
1269 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1270 AddToTLDataStrW(tld
, &wszTKIND_ENUM
[lstrlenW(wszTKIND_ALIAS
)]);
1271 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1272 AddToTLDataStrW(tld
,wszNewLine
);
1273 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1274 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1275 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1276 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1277 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1280 hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1281 EnumEnums(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1282 AddChildrenData(hParent
, tld
);
1283 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1286 AddToTLDataStrW(tld
, wszTKIND_RECORD
);
1287 AddToTLDataStrW(tld
, wszTag
);
1288 AddToTLDataStrW(tld
, bstrName
);
1289 AddToTLDataStrW(tld
, wszSpace
);
1290 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1291 AddToTLDataStrW(tld
, wszNewLine
);
1293 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1294 AddToStrW(tld
->wszInsertAfter
, wszSpace
);
1295 AddToStrW(tld
->wszInsertAfter
, bstrName
);
1296 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1297 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1299 AddToStrW(wszText
, wszTKIND_RECORD
);
1300 AddToStrW(wszText
, bstrName
);
1303 AddToStrW(wszText
, wszTKIND_MODULE
);
1304 AddToStrW(wszText
, bstrName
);
1306 case TKIND_INTERFACE
:
1307 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1308 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1309 tld
->bPredefine
= TRUE
;
1311 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1312 AddToStrW(wszText
, bstrName
);
1315 AddToStrW(wszText
, wszTKIND_COCLASS
);
1316 AddToStrW(wszText
, bstrName
);
1318 CreateCoclassHeader(pTypeInfo
, pTypeAttr
, tld
);
1319 AddToTLDataStrW(tld
, wszTKIND_COCLASS
);
1320 AddToTLDataStrW(tld
, bstrName
);
1321 AddToTLDataStrW(tld
, wszSpace
);
1322 AddToTLDataStrW(tld
, wszOpenBrackets3
);
1323 AddToTLDataStrW(tld
, wszNewLine
);
1325 EnumCoclassImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, tld
);
1327 AddToStrW(tld
->wszInsertAfter
, wszCloseBrackets3
);
1328 AddToStrW(tld
->wszInsertAfter
, wszSemicolon
);
1329 AddToStrW(tld
->wszInsertAfter
, wszNewLine
);
1332 hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1333 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1336 AddToStrW(wszText
, wszTKIND_UNION
);
1337 AddToStrW(wszText
, bstrName
);
1339 case TKIND_DISPATCH
:
1340 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1341 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1342 tld
->bPredefine
= TRUE
;
1343 if(pTypeAttr
->wTypeFlags
& TYPEFLAG_FDUAL
)
1345 AddToStrW(wszText
, wszTKIND_DISPATCH
);
1346 AddToStrW(wszText
, bstrName
);
1348 hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1349 hMain
= tvis
.hParent
;
1352 lstrcpyW(wszText
, wszProperties
);
1353 tvis
.hParent
= hParent
;
1354 tld
= InitializeTLData();
1355 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1356 AddToTLDataStrW(tld
, wszProperties
);
1357 AddToTLDataStrW(tld
, wszColon
);
1358 AddToTLDataStrW(tld
, wszNewLine
);
1359 tvis
.hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1360 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, tvis
.hParent
);
1361 AddChildrenData(tvis
.hParent
, tld
);
1363 lstrcpyW(wszText
, wszMethods
);
1364 tvis
.hParent
= hParent
;
1365 tld
= InitializeTLData();
1366 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1367 AddToTLDataStrW(tld
, wszMethods
);
1368 AddToTLDataStrW(tld
, wszColon
);
1369 AddToTLDataStrW(tld
, wszNewLine
);
1370 tvis
.hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1371 EnumFuncs(pTypeInfo
, pTypeAttr
, tvis
.hParent
);
1372 AddChildrenData(tvis
.hParent
, tld
);
1374 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1375 AddChildrenData(hParent
, tldDispatch
);
1376 AddToTLDataStrW(tldDispatch
, tldDispatch
->wszInsertAfter
);
1379 tvis
.hParent
= hMain
;
1381 if(SUCCEEDED(ITypeInfo_GetRefTypeOfImplType(pTypeInfo
, -1, &hRefType
)))
1385 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1386 SysFreeString(bstrName
);
1387 SysFreeString(bstrData
);
1389 memset(wszText
, 0, sizeof(wszText
));
1390 tld
= InitializeTLData();
1391 U(tvis
).item
.lParam
= (LPARAM
) tld
;
1393 ITypeInfo_GetRefTypeInfo(pTypeInfo
, hRefType
, &pRefTypeInfo
);
1394 ITypeInfo_GetDocumentation(pRefTypeInfo
, MEMBERID_NIL
, &bstrName
,
1395 &bstrData
, &ulHelpContext
, NULL
);
1396 ITypeInfo_GetTypeAttr(pRefTypeInfo
, &pTypeAttr
);
1398 CreateInterfaceInfo(pTypeInfo
, pTypeAttr
->cImplTypes
, bstrName
,
1399 bstrData
, ulHelpContext
, pTypeAttr
, tld
);
1400 tld
->bPredefine
= TRUE
;
1402 AddToStrW(wszText
, wszTKIND_INTERFACE
);
1403 AddToStrW(wszText
, bstrName
);
1404 ITypeInfo_Release(pRefTypeInfo
);
1408 AddToStrW(wszText
, wszTKIND_ALIAS
);
1409 CreateTypeInfo(wszText
, wszAfter
, pTypeAttr
->tdescAlias
, pTypeInfo
);
1410 AddToStrW(wszText
, wszSpace
);
1411 AddToStrW(wszText
, bstrName
);
1412 AddToStrW(wszText
, wszAfter
);
1414 CreateTypedefHeader(pTypeInfo
, pTypeAttr
, tld
);
1415 AddToTLDataStrW(tld
, &wszText
[lstrlenW(wszTKIND_ALIAS
)]);
1416 AddToTLDataStrW(tld
, wszSemicolon
);
1417 AddToTLDataStrW(tld
, wszNewLine
);
1420 lstrcpyW(wszText
, bstrName
);
1421 WINE_FIXME("pTypeAttr->typekind == %d not supported\n",
1422 pTypeAttr
->typekind
);
1427 hParent
= TreeView_InsertItem(typelib
.hTree
, &tvis
);
1429 EnumVars(pTypeInfo
, pTypeAttr
->cVars
, hParent
);
1430 EnumFuncs(pTypeInfo
, pTypeAttr
, hParent
);
1431 EnumImplTypes(pTypeInfo
, pTypeAttr
->cImplTypes
, hParent
);
1433 if(memcmp(bstrName
, wszVT_UNKNOWN
, sizeof(wszVT_UNKNOWN
)))
1434 AddChildrenData(hParent
, tld
);
1435 AddToTLDataStrW(tld
, tld
->wszInsertAfter
);
1438 ITypeInfo_ReleaseTypeAttr(pTypeInfo
, pTypeAttr
);
1439 ITypeInfo_Release(pTypeInfo
);
1440 SysFreeString(bstrName
);
1441 SysFreeString(bstrData
);
1443 SendMessage(typelib
.hTree
, TVM_EXPAND
, TVE_EXPAND
, (LPARAM
)tvis
.hParent
);
1445 memset(&tvi
, 0, sizeof(TVITEM
));
1446 tvi
.mask
= TVIF_PARAM
;
1447 tvi
.hItem
= tvis
.hParent
;
1449 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
1450 AddPredefinitions(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1451 AddIdlData(tvi
.hItem
, (TYPELIB_DATA
*)(tvi
.lParam
));
1452 AddToTLDataStrW((TYPELIB_DATA
*)(tvi
.lParam
),
1453 ((TYPELIB_DATA
*)(tvi
.lParam
))->wszInsertAfter
);
1455 ITypeLib_Release(pTypeLib
);
1459 void UpdateData(HTREEITEM item
)
1463 memset(&tvi
, 0, sizeof(TVITEM
));
1464 tvi
.mask
= TVIF_PARAM
;
1467 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
1470 SetWindowText(typelib
.hEdit
, wszSpace
);
1474 SetWindowText(typelib
.hEdit
, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1477 static void TypeLibResizeChild(void)
1481 MoveWindow(typelib
.hStatusBar
, 0, 0, 0, 0, TRUE
);
1483 if(IsWindowVisible(typelib
.hStatusBar
))
1484 GetClientRect(typelib
.hStatusBar
, &stat
);
1485 else stat
.bottom
= 0;
1487 GetClientRect(globals
.hTypeLibWnd
, &client
);
1488 MoveWindow(typelib
.hPaneWnd
, 0, 0,
1489 client
.right
, client
.bottom
-stat
.bottom
, TRUE
);
1492 static void TypeLibMenuCommand(WPARAM wParam
, HWND hWnd
)
1502 vis
= IsWindowVisible(typelib
.hStatusBar
);
1503 ShowWindow(typelib
.hStatusBar
, vis
? SW_HIDE
: SW_SHOW
);
1504 CheckMenuItem(GetMenu(hWnd
), LOWORD(wParam
),
1505 vis
? MF_UNCHECKED
: MF_CHECKED
);
1506 TypeLibResizeChild();
1509 DestroyWindow(hWnd
);
1514 static void UpdateTypeLibStatusBar(int itemID
)
1516 WCHAR info
[MAX_LOAD_STRING
];
1518 if(!LoadString(globals
.hMainInst
, itemID
, info
, sizeof(info
)/sizeof(info
[0])))
1519 LoadString(globals
.hMainInst
, IDS_READY
, info
, sizeof(info
)/sizeof(info
[0]));
1521 SendMessage(typelib
.hStatusBar
, SB_SETTEXT
, 0, (LPARAM
)info
);
1524 static void EmptyTLTree(void)
1529 tvi
.mask
= TVIF_PARAM
;
1530 cur
= TreeView_GetChild(typelib
.hTree
, TVI_ROOT
);
1535 cur
= TreeView_GetChild(typelib
.hTree
, del
);
1537 if(!cur
) cur
= TreeView_GetNextSibling(typelib
.hTree
, del
);
1538 if(!cur
) cur
= TreeView_GetParent(typelib
.hTree
, del
);
1541 SendMessage(typelib
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
1544 HeapFree(GetProcessHeap(), 0, ((TYPELIB_DATA
*)tvi
.lParam
)->idl
);
1545 HeapFree(GetProcessHeap(), 0, (TYPELIB_DATA
*)tvi
.lParam
);
1548 SendMessage(typelib
.hTree
, TVM_DELETEITEM
, 0, (LPARAM
)del
);
1554 static LRESULT CALLBACK
TypeLibProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1560 if(!CreatePanedWindow(hWnd
, &typelib
.hPaneWnd
, globals
.hMainInst
))
1561 DestroyWindow(hWnd
);
1562 typelib
.hTree
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
1563 WS_CHILD
|WS_VISIBLE
|TVS_HASLINES
|TVS_HASBUTTONS
|TVS_LINESATROOT
,
1564 0, 0, 0, 0, typelib
.hPaneWnd
, (HMENU
)TYPELIB_TREE
,
1565 globals
.hMainInst
, NULL
);
1566 typelib
.hEdit
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_EDIT
, NULL
,
1567 WS_CHILD
|WS_VISIBLE
|ES_MULTILINE
|ES_READONLY
|WS_HSCROLL
|WS_VSCROLL
,
1568 0, 0, 0, 0, typelib
.hPaneWnd
, NULL
, globals
.hMainInst
, NULL
);
1570 SetLeft(typelib
.hPaneWnd
, typelib
.hTree
);
1571 SetRight(typelib
.hPaneWnd
, typelib
.hEdit
);
1573 if(PopulateTree()) DestroyWindow(hWnd
);
1574 else SetFocus(typelib
.hTree
);
1578 TypeLibMenuCommand(LOWORD(wParam
), hWnd
);
1580 UpdateTypeLibStatusBar(LOWORD(wParam
));
1583 SetFocus(typelib
.hTree
);
1586 if(wParam
== SIZE_MINIMIZED
) break;
1587 TypeLibResizeChild();
1593 return DefWindowProc(hWnd
, uMsg
, wParam
, lParam
);
1598 BOOL
TypeLibRegisterClass(void)
1602 memset(&wcc
, 0, sizeof(WNDCLASS
));
1603 wcc
.lpfnWndProc
= TypeLibProc
;
1604 wcc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1605 wcc
.lpszMenuName
= MAKEINTRESOURCE(IDM_TYPELIB
);
1606 wcc
.lpszClassName
= wszTypeLib
;
1608 if(!RegisterClass(&wcc
))
1614 BOOL
CreateTypeLibWindow(HINSTANCE hInst
, WCHAR
*wszFileName
)
1616 WCHAR wszTitle
[MAX_LOAD_STRING
];
1617 LoadString(hInst
, IDS_TYPELIBTITLE
, wszTitle
, sizeof(wszTitle
)/sizeof(wszTitle
[0]));
1619 if(wszFileName
) lstrcpyW(typelib
.wszFileName
, wszFileName
);
1624 memset(&tvi
, 0, sizeof(TVITEM
));
1625 tvi
.hItem
= TreeView_GetSelection(globals
.hTree
);
1627 SendMessage(globals
.hTree
, TVM_GETITEM
, 0, (LPARAM
)&tvi
);
1628 lstrcpyW(typelib
.wszFileName
, ((ITEM_INFO
*)tvi
.lParam
)->path
);
1631 globals
.hTypeLibWnd
= CreateWindow(wszTypeLib
, wszTitle
,
1632 WS_OVERLAPPEDWINDOW
|WS_VISIBLE
,
1633 CW_USEDEFAULT
, CW_USEDEFAULT
, 800, 600, NULL
, NULL
, hInst
, NULL
);
1634 if(!globals
.hTypeLibWnd
) return FALSE
;
1636 typelib
.hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
,
1637 wszTitle
, globals
.hTypeLibWnd
, 0);
1639 TypeLibResizeChild();