tzres: Add Aleutian Time Zone.
[wine/zf.git] / programs / oleview / oleview.c
blob410cb053dd8037f7b925d74f2b8111e68c315102
1 /*
2 * OleView (oleview.c)
4 * Copyright 2006 Piotr Caban
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "main.h"
22 #include "commdlg.h"
23 #include "shellapi.h"
25 GLOBALS globals;
26 static const WCHAR wszRegEdit[] = { '\\','r','e','g','e','d','i','t','.','e','x','e','\0' };
27 static const WCHAR wszFormat[] = { '<','o','b','j','e','c','t','\n',' ',' ',' ',
28 'c','l','a','s','s','i','d','=','\"','c','l','s','i','d',':','%','s','\"','\n',
29 '>','\n','<','/','o','b','j','e','c','t','>','\0' };
31 static INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
33 HKEY hKey;
34 WCHAR buffer[MAX_LOAD_STRING];
35 DWORD bufSize;
37 WCHAR wszReg[] = { 'S','o','f','t','w','a','r','e','\\',
38 'M','i','c','r','o','s','o','f','t','\\','O','L','E','\\','\0' };
39 WCHAR wszEnableDCOM[] = { 'E','n','a','b','l','e','D','C','O','M','\0' };
40 WCHAR wszEnableRemote[] = { 'E','n','a','b','l','e',
41 'R','e','m','o','t','e','C','o','n','n','e','c','t','\0' };
42 WCHAR wszYes[] = { 'Y', '\0' };
43 WCHAR wszNo[] = { 'N', '\0' };
45 switch(uMsg)
47 case WM_INITDIALOG:
48 if(RegOpenKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey) != ERROR_SUCCESS)
49 RegCreateKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey);
51 bufSize = sizeof(buffer);
52 if(RegGetValueW(hKey, NULL, wszEnableDCOM, RRF_RT_REG_SZ,
53 NULL, buffer, &bufSize) != ERROR_SUCCESS)
55 bufSize = sizeof(wszYes);
56 RegSetValueExW(hKey, wszEnableDCOM, 0, REG_SZ, (BYTE*)wszYes, bufSize);
59 CheckDlgButton(hDlgWnd, IDC_ENABLEDCOM,
60 buffer[0]=='Y' ? BST_CHECKED : BST_UNCHECKED);
62 bufSize = sizeof(buffer);
63 if(RegGetValueW(hKey, NULL, wszEnableRemote, RRF_RT_REG_SZ,
64 NULL, buffer, &bufSize) != ERROR_SUCCESS)
66 bufSize = sizeof(wszYes);
67 RegSetValueExW(hKey, wszEnableRemote, 0, REG_SZ, (BYTE*)wszYes, bufSize);
70 CheckDlgButton(hDlgWnd, IDC_ENABLEREMOTE,
71 buffer[0]=='Y' ? BST_CHECKED : BST_UNCHECKED);
73 RegCloseKey(hKey);
74 return TRUE;
75 case WM_COMMAND:
76 switch(LOWORD(wParam)) {
77 case IDOK:
78 bufSize = sizeof(wszYes);
80 RegOpenKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey);
82 RegSetValueExW(hKey, wszEnableDCOM, 0, REG_SZ,
83 IsDlgButtonChecked(hDlgWnd, IDC_ENABLEDCOM) == BST_CHECKED ?
84 (BYTE*)wszYes : (BYTE*)wszNo, bufSize);
86 RegSetValueExW(hKey, wszEnableRemote, 0, REG_SZ,
87 IsDlgButtonChecked(hDlgWnd, IDC_ENABLEREMOTE) == BST_CHECKED ?
88 (BYTE*)wszYes : (BYTE*)wszNo, bufSize);
90 RegCloseKey(hKey);
92 EndDialog(hDlgWnd, IDOK);
93 return TRUE;
94 case IDCANCEL:
95 EndDialog(hDlgWnd, IDCANCEL);
96 return TRUE;
100 return FALSE;
103 static INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
105 HWND hEdit;
107 switch(uMsg)
109 case WM_COMMAND:
110 switch(LOWORD(wParam)) {
111 case IDOK:
112 memset(globals.wszMachineName, 0, sizeof(WCHAR[MAX_LOAD_STRING]));
113 hEdit = GetDlgItem(hDlgWnd, IDC_MACHINE);
115 if (GetWindowTextLengthW(hEdit)>0)
116 GetWindowTextW(hEdit, globals.wszMachineName, MAX_LOAD_STRING);
118 EndDialog(hDlgWnd, IDOK);
119 return TRUE;
120 case IDCANCEL:
121 EndDialog(hDlgWnd, IDCANCEL);
122 return TRUE;
126 return FALSE;
129 static void InitOpenFileName(HWND hWnd, OPENFILENAMEW *pofn, WCHAR *wszFilter,
130 WCHAR *wszTitle, WCHAR *wszFileName)
132 memset(pofn, 0, sizeof(OPENFILENAMEW));
133 pofn->lStructSize = sizeof(OPENFILENAMEW);
134 pofn->hwndOwner = hWnd;
135 pofn->hInstance = globals.hMainInst;
137 pofn->lpstrTitle = wszTitle;
138 pofn->lpstrFilter = wszFilter;
139 pofn->nFilterIndex = 0;
140 pofn->lpstrFile = wszFileName;
141 pofn->nMaxFile = MAX_LOAD_STRING;
142 pofn->Flags = OFN_HIDEREADONLY | OFN_ENABLESIZING;
145 static void CopyClsid(HTREEITEM item)
147 TVITEMW tvi;
149 memset(&tvi, 0, sizeof(TVITEMW));
150 tvi.hItem = item;
151 tvi.cchTextMax = MAX_LOAD_STRING;
152 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
154 if(OpenClipboard(globals.hMainWnd) && EmptyClipboard() && tvi.lParam)
156 HANDLE hClipData = GlobalAlloc(GHND, sizeof(WCHAR[MAX_LOAD_STRING]));
157 LPVOID pLoc = GlobalLock(hClipData);
159 lstrcpyW(pLoc, ((ITEM_INFO *)tvi.lParam)->clsid);
160 GlobalUnlock(hClipData);
161 SetClipboardData(CF_UNICODETEXT, hClipData);
162 CloseClipboard();
166 static void CopyHTMLTag(HTREEITEM item)
168 TVITEMW tvi;
170 memset(&tvi, 0, sizeof(TVITEMW));
171 tvi.hItem = item;
172 tvi.cchTextMax = MAX_LOAD_STRING;
173 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
175 if(OpenClipboard(globals.hMainWnd) && EmptyClipboard() && tvi.lParam)
177 HANDLE hClipData = GlobalAlloc(GHND, sizeof(WCHAR[MAX_LOAD_STRING]));
178 LPVOID pLoc = GlobalLock(hClipData);
179 int clsidLen = lstrlenW(((ITEM_INFO *)tvi.lParam)->clsid)-1;
181 ((ITEM_INFO *)tvi.lParam)->clsid[clsidLen] = '\0';
182 wsprintfW(pLoc, wszFormat, ((ITEM_INFO *)tvi.lParam)->clsid+1);
183 ((ITEM_INFO *)tvi.lParam)->clsid[clsidLen] = '}';
185 GlobalUnlock(hClipData);
186 SetClipboardData(CF_UNICODETEXT, hClipData);
187 CloseClipboard();
191 static void ResizeChild(void)
193 RECT client, stat, tool;
195 MoveWindow(globals.hStatusBar, 0, 0, 0, 0, TRUE);
196 MoveWindow(globals.hToolBar, 0, 0, 0, 0, TRUE);
198 if(IsWindowVisible(globals.hStatusBar))
199 GetClientRect(globals.hStatusBar, &stat);
200 else stat.bottom = 0;
202 if(IsWindowVisible(globals.hToolBar))
204 GetClientRect(globals.hToolBar, &tool);
205 tool.bottom += 2;
207 else tool.bottom = 0;
209 GetClientRect(globals.hMainWnd, &client);
210 MoveWindow(globals.hPaneWnd, 0, tool.bottom,
211 client.right, client.bottom-tool.bottom-stat.bottom, TRUE);
214 void RefreshMenu(HTREEITEM item)
216 TVITEMW tvi;
217 HTREEITEM parent;
218 HMENU hMenu = GetMenu(globals.hMainWnd);
220 memset(&tvi, 0, sizeof(TVITEMW));
221 tvi.hItem = item;
222 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
224 parent = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
225 TVGN_PARENT, (LPARAM)item);
227 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
228 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
229 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
231 if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag&SHOWALL)
233 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
234 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_ENABLED);
235 EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
237 if(!((ITEM_INFO *)tvi.lParam)->loaded)
239 EnableMenuItem(hMenu, IDM_CREATEINST, MF_ENABLED);
240 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_ENABLED);
241 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
242 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, TRUE);
244 else
246 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
247 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
248 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_ENABLED);
249 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, TRUE);
252 else if(tvi.lParam &&
253 (((ITEM_INFO *)tvi.lParam)->cFlag&INTERFACE || parent==tree.hTL))
255 EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
256 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
257 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
258 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
259 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
260 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
261 EnableMenuItem(hMenu, IDM_VIEW, MF_ENABLED);
262 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, TRUE);
264 else
266 EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
267 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
268 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
269 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
270 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_GRAYED);
271 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
272 EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
275 if(parent==tree.hAID || parent==tree.hGBCC)
276 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
279 static int MenuCommand(WPARAM wParam, HWND hWnd)
281 BOOL vis;
282 HTREEITEM hSelect;
283 WCHAR wszAbout[MAX_LOAD_STRING];
285 switch(wParam)
287 case IDM_ABOUT:
288 LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout, ARRAY_SIZE(wszAbout));
289 ShellAboutW(hWnd, wszAbout, NULL, NULL);
290 break;
291 case IDM_COPYCLSID:
292 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
293 TVM_GETNEXTITEM, TVGN_CARET, 0);
294 CopyClsid(hSelect);
295 break;
296 case IDM_HTMLTAG:
297 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
298 TVM_GETNEXTITEM, TVGN_CARET, 0);
299 CopyHTMLTag(hSelect);
300 break;
301 case IDM_CREATEINST:
302 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
303 TVM_GETNEXTITEM, TVGN_CARET, 0);
304 CreateInst(hSelect, NULL);
305 SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
306 break;
307 case IDM_CREATEINSTON:
308 if(DialogBoxW(0, MAKEINTRESOURCEW(DLG_CREATEINSTON),
309 hWnd, CreateInstOnProc) == IDCANCEL) break;
310 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
311 TVM_GETNEXTITEM, TVGN_CARET, 0);
312 CreateInst(hSelect, globals.wszMachineName);
313 SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
314 break;
315 case IDM_RELEASEINST:
316 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
317 TVM_GETNEXTITEM, TVGN_CARET, 0);
318 ReleaseInst(hSelect);
319 RefreshMenu(hSelect);
320 RefreshDetails(hSelect);
321 break;
322 case IDM_EXPERT:
323 globals.bExpert = !globals.bExpert;
324 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
325 globals.bExpert ? MF_CHECKED : MF_UNCHECKED);
326 EmptyTree();
327 if(globals.bExpert) AddTreeEx();
328 else AddTree();
329 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
330 TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
331 SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
332 RefreshMenu(hSelect);
333 break;
334 case IDM_FLAG_INSERV:
335 vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER;
336 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER);
337 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER);
338 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
339 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
340 vis ? MF_UNCHECKED : MF_CHECKED);
341 break;
342 case IDM_FLAG_INHANDL:
343 vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER;
344 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER);
345 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER);
346 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
347 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
348 vis ? MF_UNCHECKED : MF_CHECKED);
349 break;
350 case IDM_FLAG_LOCSERV:
351 vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER;
352 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER);
353 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER);
354 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
355 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
356 vis ? MF_UNCHECKED : MF_CHECKED);
357 break;
358 case IDM_FLAG_REMSERV:
359 vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER;
360 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER);
361 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER);
362 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
363 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
364 vis ? MF_UNCHECKED : MF_CHECKED);
365 break;
366 case IDM_REFRESH:
367 EmptyTree();
368 if(globals.bExpert) AddTreeEx();
369 else AddTree();
370 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
371 TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
372 SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
373 RefreshMenu(hSelect);
374 break;
375 case IDM_REGEDIT:
377 STARTUPINFOW si;
378 PROCESS_INFORMATION pi;
379 WCHAR app[MAX_PATH];
381 GetWindowsDirectoryW(app, MAX_PATH - ARRAY_SIZE(wszRegEdit));
382 lstrcatW( app, wszRegEdit );
383 memset(&si, 0, sizeof(si));
384 si.cb = sizeof(si);
385 if (CreateProcessW(app, app, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
387 CloseHandle(pi.hProcess);
388 CloseHandle(pi.hThread);
390 break;
392 case IDM_STATUSBAR:
393 vis = IsWindowVisible(globals.hStatusBar);
394 ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW);
395 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
396 vis ? MF_UNCHECKED : MF_CHECKED);
397 ResizeChild();
398 break;
399 case IDM_SYSCONF:
400 DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF), hWnd, SysConfProc);
401 break;
402 case IDM_TOOLBAR:
403 vis = IsWindowVisible(globals.hToolBar);
404 ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW);
405 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
406 vis ? MF_UNCHECKED : MF_CHECKED);
407 ResizeChild();
408 break;
409 case IDM_TYPELIB:
411 static const WCHAR filterW[] = {'%','s','%','c','*','.','t','l','b',';','*','.','o','l','b',';','*','.','d','l','l',';','*','.','o','c','x',';','*','.','e','x','e','%','c','%','s','%','c','*','.','*','%','c',0};
412 OPENFILENAMEW ofn;
413 static WCHAR wszTitle[MAX_LOAD_STRING];
414 static WCHAR wszName[MAX_LOAD_STRING];
415 WCHAR filter_typelib[MAX_LOAD_STRING], filter_all[MAX_LOAD_STRING], filter[MAX_PATH];
417 LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, ARRAY_SIZE(wszTitle));
418 LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, ARRAY_SIZE(filter_typelib));
419 LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, ARRAY_SIZE(filter_all));
420 wsprintfW( filter, filterW, filter_typelib, 0, 0, filter_all, 0, 0 );
421 InitOpenFileName(hWnd, &ofn, filter, wszTitle, wszName);
422 if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
423 break;
425 case IDM_VIEW:
426 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
427 TVM_GETNEXTITEM, TVGN_CARET, 0);
428 if(IsInterface(hSelect)) InterfaceViewer(hSelect);
429 else CreateTypeLibWindow(globals.hMainInst, NULL);
430 break;
431 case IDM_EXIT:
432 DestroyWindow(hWnd);
433 break;
435 return 0;
438 static void UpdateStatusBar(int itemID)
440 WCHAR info[MAX_LOAD_STRING];
442 if(!LoadStringW(globals.hMainInst, itemID, info, ARRAY_SIZE(info)))
443 LoadStringW(globals.hMainInst, IDS_READY, info, ARRAY_SIZE(info));
445 SendMessageW(globals.hStatusBar, SB_SETTEXTW, 0, (LPARAM)info);
448 static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
449 WPARAM wParam, LPARAM lParam)
451 switch(uMsg)
453 case WM_CREATE:
454 OleInitialize(NULL);
455 PaneRegisterClassW();
456 TypeLibRegisterClassW();
457 if(!CreatePanedWindow(hWnd, &globals.hPaneWnd, globals.hMainInst))
458 PostQuitMessage(0);
459 SetLeft(globals.hPaneWnd, CreateTreeWindow(globals.hMainInst));
460 SetRight(globals.hPaneWnd, CreateDetailsWindow(globals.hMainInst));
461 SetFocus(globals.hTree);
462 break;
463 case WM_COMMAND:
464 MenuCommand(LOWORD(wParam), hWnd);
465 break;
466 case WM_DESTROY:
467 EmptyTree();
468 OleUninitialize();
469 PostQuitMessage(0);
470 break;
471 case WM_MENUSELECT:
472 UpdateStatusBar(LOWORD(wParam));
473 break;
474 case WM_SETFOCUS:
475 SetFocus(globals.hTree);
476 break;
477 case WM_SIZE:
478 if(wParam == SIZE_MINIMIZED) break;
479 ResizeChild();
480 break;
481 default:
482 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
484 return 0;
487 static BOOL InitApplication(HINSTANCE hInst)
489 WNDCLASSW wc;
490 WCHAR wszAppName[MAX_LOAD_STRING];
492 LoadStringW(hInst, IDS_APPNAME, wszAppName, ARRAY_SIZE(wszAppName));
494 memset(&wc, 0, sizeof(WNDCLASSW));
495 wc.lpfnWndProc = WndProc;
496 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
497 wc.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
498 wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
499 wc.lpszClassName = wszAppName;
501 if(!RegisterClassW(&wc))
502 return FALSE;
504 return TRUE;
507 static BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
509 HWND hWnd;
510 WCHAR wszAppName[MAX_LOAD_STRING];
511 WCHAR wszTitle[MAX_LOAD_STRING];
512 TBBUTTON tB[] = {
513 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
514 {0, IDM_BIND, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
515 {1, IDM_TYPELIB, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
516 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
517 {2, IDM_REGEDIT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
518 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
519 {3, IDM_CREATEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
520 {4, IDM_RELEASEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
521 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
522 {5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
525 LoadStringW(hInst, IDS_APPNAME, wszAppName, ARRAY_SIZE(wszAppName));
526 LoadStringW(hInst, IDS_APPTITLE, wszTitle, ARRAY_SIZE(wszTitle));
528 hWnd = CreateWindowW(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW,
529 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
530 if(!hWnd) return FALSE;
532 globals.hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD,
533 wszTitle, hWnd, 0);
535 globals.hToolBar = CreateToolbarEx(hWnd, WS_CHILD|WS_VISIBLE, 0, 1, hInst,
536 IDB_TOOLBAR, tB, 10, 16, 16, 16, 16, sizeof(TBBUTTON));
537 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
538 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
539 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
541 globals.hMainWnd = hWnd;
542 globals.hMainInst = hInst;
543 globals.bExpert = TRUE;
544 globals.dwClsCtx = CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER;
546 ShowWindow(hWnd, nCmdShow);
547 UpdateWindow(hWnd);
549 return TRUE;
552 int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
554 MSG msg;
555 HANDLE hAccelTable;
557 if(!InitApplication(hInst))
558 return FALSE;
560 if(!InitInstance(hInst, nCmdShow))
561 return FALSE;
563 hAccelTable = LoadAcceleratorsW(hInst, MAKEINTRESOURCEW(IDA_OLEVIEW));
565 while(GetMessageW(&msg, NULL, 0, 0))
567 if(TranslateAcceleratorW(globals.hMainWnd, hAccelTable, &msg)) continue;
569 TranslateMessage(&msg);
570 DispatchMessageW(&msg);
573 return msg.wParam;