4 * Copyright 2006 Piotr Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 static const WCHAR wszTypeLib[] = { 'T','Y','P','E','L','I','B','\0' };
26 void PopulateTree(void)
34 memset(&tvi, 0, sizeof(TVITEM));
35 tvi.hItem = TreeView_GetSelection(globals.hTree);
37 U(tvis).item.mask = TVIF_TEXT|TVIF_CHILDREN;
38 U(tvis).item.cChildren = 1;
39 tvis.hInsertAfter = (HTREEITEM)TVI_LAST;
40 tvis.hParent = TVI_ROOT;
42 SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
43 if(FAILED(LoadTypeLib(((ITEM_INFO*)tvi.lParam)->path, &pTypeLib))) return;
45 count = ITypeLib_GetTypeInfoCount(pTypeLib);
47 for(i=-1; i<count; i++) {
48 ITypeLib_GetDocumentation(pTypeLib, i, &bstrName, NULL, NULL, NULL);
50 U(tvis).item.cchTextMax = SysStringLen(bstrName);
51 U(tvis).item.pszText = bstrName;
54 tvis.hParent = (HTREEITEM)SendMessage(typelib.hTree,
55 TVM_INSERTITEM, 0, (LPARAM)&tvis);
56 else SendMessage(typelib.hTree, TVM_INSERTITEM, 0, (LPARAM)&tvis);
58 SysFreeString(bstrName);
60 SendMessage(typelib.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)tvis.hParent);
62 ITypeLib_Release(pTypeLib);
65 void TypeLibResizeChild(void)
69 MoveWindow(typelib.hStatusBar, 0, 0, 0, 0, TRUE);
71 if(IsWindowVisible(typelib.hStatusBar))
72 GetClientRect(typelib.hStatusBar, &stat);
75 GetClientRect(globals.hTypeLibWnd, &client);
76 MoveWindow(typelib.hPaneWnd, 0, 0,
77 client.right, client.bottom-stat.bottom, TRUE);
80 void UpdateTypeLibStatusBar(int itemID)
82 WCHAR info[MAX_LOAD_STRING];
84 if(!LoadString(globals.hMainInst, itemID, info, sizeof(WCHAR[MAX_LOAD_STRING])))
85 LoadString(globals.hMainInst, IDS_READY, info, sizeof(WCHAR[MAX_LOAD_STRING]));
87 SendMessage(typelib.hStatusBar, SB_SETTEXT, 0, (LPARAM)info);
90 LRESULT CALLBACK TypeLibProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
96 if(!CreatePanedWindow(hWnd, &typelib.hPaneWnd, globals.hMainInst))
98 typelib.hTree = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
99 WS_CHILD|WS_VISIBLE|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT,
100 0, 0, 0, 0, typelib.hPaneWnd, NULL, globals.hMainInst, NULL);
101 typelib.hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL,
102 WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_READONLY|WS_HSCROLL|WS_VSCROLL,
103 0, 0, 0, 0, typelib.hPaneWnd, NULL, globals.hMainInst, NULL);
105 SetLeft(typelib.hPaneWnd, typelib.hTree);
106 SetRight(typelib.hPaneWnd, typelib.hEdit);
109 SetFocus(typelib.hTree);
113 UpdateTypeLibStatusBar(LOWORD(wParam));
116 SetFocus(typelib.hTree);
119 if(wParam == SIZE_MINIMIZED) break;
120 TypeLibResizeChild();
125 return DefWindowProc(hWnd, uMsg, wParam, lParam);
130 BOOL TypeLibRegisterClass(void)
134 memset(&wcc, 0, sizeof(WNDCLASS));
135 wcc.lpfnWndProc = TypeLibProc;
136 wcc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
137 wcc.lpszMenuName = MAKEINTRESOURCE(IDM_TYPELIB);
138 wcc.lpszClassName = wszTypeLib;
140 if(!RegisterClass(&wcc))
146 BOOL CreateTypeLibWindow(HINSTANCE hInst)
148 WCHAR wszTitle[MAX_LOAD_STRING];
149 LoadString(hInst, IDS_TYPELIBTITLE, wszTitle, sizeof(WCHAR[MAX_LOAD_STRING]));
151 globals.hTypeLibWnd = CreateWindow(wszTypeLib, wszTitle,
152 WS_OVERLAPPEDWINDOW|WS_VISIBLE,
153 CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInst, NULL);
154 if(!globals.hTypeLibWnd) return FALSE;
156 typelib.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD,
157 (LPWSTR)wszTitle, globals.hTypeLibWnd, 0);
159 TypeLibResizeChild();