winemenubuilder: Add a trailing '\n' to a FIXME() call.
[wine/testsucceed.git] / programs / oleview / oleview.c
blobb1fb7c9fe5b51ec4737e460ef192e9f8e95879d2
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"
23 GLOBALS globals;
24 static const WCHAR wszRegEdit[] = { '\\','r','e','g','e','d','i','t','.','e','x','e','\0' };
25 static WCHAR wszFormat[] = { '<','o','b','j','e','c','t','\n',' ',' ',' ',
26 'c','l','a','s','s','i','d','=','\"','c','l','s','i','d',':','%','s','\"','\n',
27 '>','\n','<','/','o','b','j','e','c','t','>','\0' };
29 static INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
31 HKEY hKey;
32 WCHAR buffer[MAX_LOAD_STRING];
33 DWORD bufSize;
35 WCHAR wszReg[] = { 'S','o','f','t','w','a','r','e','\\',
36 'M','i','c','r','o','s','o','f','t','\\','O','L','E','\\','\0' };
37 WCHAR wszEnableDCOM[] = { 'E','n','a','b','l','e','D','C','O','M','\0' };
38 WCHAR wszEnableRemote[] = { 'E','n','a','b','l','e',
39 'R','e','m','o','t','e','C','o','n','n','e','c','t','\0' };
40 WCHAR wszYes[] = { 'Y', '\0' };
41 WCHAR wszNo[] = { 'N', '\0' };
43 switch(uMsg)
45 case WM_INITDIALOG:
46 if(RegOpenKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey) != ERROR_SUCCESS)
47 RegCreateKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey);
49 bufSize = sizeof(buffer);
50 if(RegGetValueW(hKey, NULL, wszEnableDCOM, RRF_RT_REG_SZ,
51 NULL, buffer, &bufSize) != ERROR_SUCCESS)
53 bufSize = sizeof(wszYes);
54 RegSetValueExW(hKey, wszEnableDCOM, 0, REG_SZ, (BYTE*)wszYes, bufSize);
57 CheckDlgButton(hDlgWnd, IDC_ENABLEDCOM,
58 buffer[0]=='Y' ? BST_CHECKED : BST_UNCHECKED);
60 bufSize = sizeof(buffer);
61 if(RegGetValueW(hKey, NULL, wszEnableRemote, RRF_RT_REG_SZ,
62 NULL, buffer, &bufSize) != ERROR_SUCCESS)
64 bufSize = sizeof(wszYes);
65 RegSetValueExW(hKey, wszEnableRemote, 0, REG_SZ, (BYTE*)wszYes, bufSize);
68 CheckDlgButton(hDlgWnd, IDC_ENABLEREMOTE,
69 buffer[0]=='Y' ? BST_CHECKED : BST_UNCHECKED);
71 RegCloseKey(hKey);
72 return TRUE;
73 case WM_COMMAND:
74 switch(LOWORD(wParam)) {
75 case IDOK:
76 bufSize = sizeof(wszYes);
78 RegOpenKeyW(HKEY_LOCAL_MACHINE, wszReg, &hKey);
80 RegSetValueExW(hKey, wszEnableDCOM, 0, REG_SZ,
81 IsDlgButtonChecked(hDlgWnd, IDC_ENABLEDCOM) == BST_CHECKED ?
82 (BYTE*)wszYes : (BYTE*)wszNo, bufSize);
84 RegSetValueExW(hKey, wszEnableRemote, 0, REG_SZ,
85 IsDlgButtonChecked(hDlgWnd, IDC_ENABLEREMOTE) == BST_CHECKED ?
86 (BYTE*)wszYes : (BYTE*)wszNo, bufSize);
88 RegCloseKey(hKey);
90 EndDialog(hDlgWnd, IDOK);
91 return TRUE;
92 case IDCANCEL:
93 EndDialog(hDlgWnd, IDCANCEL);
94 return TRUE;
98 return FALSE;
101 static INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
103 HWND hEdit;
105 switch(uMsg)
107 case WM_COMMAND:
108 switch(LOWORD(wParam)) {
109 case IDOK:
110 memset(globals.wszMachineName, 0, sizeof(WCHAR[MAX_LOAD_STRING]));
111 hEdit = GetDlgItem(hDlgWnd, IDC_MACHINE);
113 if (GetWindowTextLengthW(hEdit)>0)
114 GetWindowTextW(hEdit, globals.wszMachineName, MAX_LOAD_STRING);
116 EndDialog(hDlgWnd, IDOK);
117 return TRUE;
118 case IDCANCEL:
119 EndDialog(hDlgWnd, IDCANCEL);
120 return TRUE;
124 return FALSE;
127 static void InitOpenFileName(HWND hWnd, OPENFILENAMEW *pofn, WCHAR *wszFilter,
128 WCHAR *wszTitle, WCHAR *wszFileName)
130 memset(pofn, 0, sizeof(OPENFILENAMEW));
131 pofn->lStructSize = sizeof(OPENFILENAMEW);
132 pofn->hwndOwner = hWnd;
133 pofn->hInstance = globals.hMainInst;
135 pofn->lpstrTitle = wszTitle;
136 pofn->lpstrFilter = wszFilter;
137 pofn->nFilterIndex = 0;
138 pofn->lpstrFile = wszFileName;
139 pofn->nMaxFile = MAX_LOAD_STRING;
140 pofn->Flags = OFN_HIDEREADONLY | OFN_ENABLESIZING;
143 static void CopyClsid(HTREEITEM item)
145 TVITEMW tvi;
147 memset(&tvi, 0, sizeof(TVITEMW));
148 tvi.hItem = item;
149 tvi.cchTextMax = MAX_LOAD_STRING;
150 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
152 if(OpenClipboard(globals.hMainWnd) && EmptyClipboard() && tvi.lParam)
154 HANDLE hClipData = GlobalAlloc(GHND, sizeof(WCHAR[MAX_LOAD_STRING]));
155 LPVOID pLoc = GlobalLock(hClipData);
157 lstrcpyW(pLoc, ((ITEM_INFO *)tvi.lParam)->clsid);
158 GlobalUnlock(hClipData);
159 hClipData = SetClipboardData(CF_UNICODETEXT, hClipData);
160 CloseClipboard();
164 static void CopyHTMLTag(HTREEITEM item)
166 TVITEMW tvi;
168 memset(&tvi, 0, sizeof(TVITEMW));
169 tvi.hItem = item;
170 tvi.cchTextMax = MAX_LOAD_STRING;
171 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
173 if(OpenClipboard(globals.hMainWnd) && EmptyClipboard() && tvi.lParam)
175 HANDLE hClipData = GlobalAlloc(GHND, sizeof(WCHAR[MAX_LOAD_STRING]));
176 LPVOID pLoc = GlobalLock(hClipData);
177 int clsidLen = lstrlenW(((ITEM_INFO *)tvi.lParam)->clsid)-1;
179 ((ITEM_INFO *)tvi.lParam)->clsid[clsidLen] = '\0';
180 wsprintfW(pLoc, wszFormat, ((ITEM_INFO *)tvi.lParam)->clsid+1);
181 ((ITEM_INFO *)tvi.lParam)->clsid[clsidLen] = '}';
183 GlobalUnlock(hClipData);
184 hClipData = SetClipboardData(CF_UNICODETEXT, hClipData);
185 CloseClipboard();
189 static void ResizeChild(void)
191 RECT client, stat, tool;
193 MoveWindow(globals.hStatusBar, 0, 0, 0, 0, TRUE);
194 MoveWindow(globals.hToolBar, 0, 0, 0, 0, TRUE);
196 if(IsWindowVisible(globals.hStatusBar))
197 GetClientRect(globals.hStatusBar, &stat);
198 else stat.bottom = 0;
200 if(IsWindowVisible(globals.hToolBar))
202 GetClientRect(globals.hToolBar, &tool);
203 tool.bottom += 2;
205 else tool.bottom = 0;
207 GetClientRect(globals.hMainWnd, &client);
208 MoveWindow(globals.hPaneWnd, 0, tool.bottom,
209 client.right, client.bottom-tool.bottom-stat.bottom, TRUE);
212 void RefreshMenu(HTREEITEM item)
214 TVITEMW tvi;
215 HTREEITEM parent;
216 HMENU hMenu = GetMenu(globals.hMainWnd);
218 memset(&tvi, 0, sizeof(TVITEMW));
219 tvi.hItem = item;
220 SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi);
222 parent = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
223 TVGN_PARENT, (LPARAM)item);
225 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
226 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
227 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
229 if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag&SHOWALL)
231 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
232 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_ENABLED);
233 EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
235 if(!((ITEM_INFO *)tvi.lParam)->loaded)
237 EnableMenuItem(hMenu, IDM_CREATEINST, MF_ENABLED);
238 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_ENABLED);
239 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
240 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, TRUE);
242 else
244 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
245 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
246 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_ENABLED);
247 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, TRUE);
250 else if(tvi.lParam &&
251 (((ITEM_INFO *)tvi.lParam)->cFlag&INTERFACE || parent==tree.hTL))
253 EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
254 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
255 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
256 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
257 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
258 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
259 EnableMenuItem(hMenu, IDM_VIEW, MF_ENABLED);
260 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, TRUE);
262 else
264 EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
265 EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
266 EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
267 EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
268 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_GRAYED);
269 EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
270 EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
273 if(parent==tree.hAID || parent==tree.hGBCC)
274 EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
277 static int MenuCommand(WPARAM wParam, HWND hWnd)
279 BOOL vis;
280 HTREEITEM hSelect;
281 WCHAR wszAbout[MAX_LOAD_STRING];
282 WCHAR wszAboutVer[MAX_LOAD_STRING];
284 switch(wParam)
286 case IDM_ABOUT:
287 LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout,
288 sizeof(wszAbout)/sizeof(wszAbout[0]));
289 LoadStringW(globals.hMainInst, IDS_ABOUTVER, wszAboutVer,
290 sizeof(wszAboutVer)/sizeof(wszAboutVer[0]));
291 ShellAboutW(hWnd, wszAbout, wszAboutVer, NULL);
292 break;
293 case IDM_COPYCLSID:
294 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
295 TVM_GETNEXTITEM, TVGN_CARET, 0);
296 CopyClsid(hSelect);
297 break;
298 case IDM_HTMLTAG:
299 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
300 TVM_GETNEXTITEM, TVGN_CARET, 0);
301 CopyHTMLTag(hSelect);
302 break;
303 case IDM_CREATEINST:
304 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
305 TVM_GETNEXTITEM, TVGN_CARET, 0);
306 CreateInst(hSelect, NULL);
307 SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
308 break;
309 case IDM_CREATEINSTON:
310 if(DialogBoxW(0, MAKEINTRESOURCEW(DLG_CREATEINSTON),
311 hWnd, CreateInstOnProc) == IDCANCEL) break;
312 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
313 TVM_GETNEXTITEM, TVGN_CARET, 0);
314 CreateInst(hSelect, globals.wszMachineName);
315 SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
316 break;
317 case IDM_RELEASEINST:
318 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
319 TVM_GETNEXTITEM, TVGN_CARET, 0);
320 ReleaseInst(hSelect);
321 RefreshMenu(hSelect);
322 RefreshDetails(hSelect);
323 break;
324 case IDM_EXPERT:
325 globals.bExpert = !globals.bExpert;
326 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
327 globals.bExpert ? MF_CHECKED : MF_UNCHECKED);
328 EmptyTree();
329 if(globals.bExpert) AddTreeEx();
330 else AddTree();
331 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
332 TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
333 SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
334 RefreshMenu(hSelect);
335 break;
336 case IDM_FLAG_INSERV:
337 vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER;
338 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER);
339 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER);
340 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
341 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
342 vis ? MF_UNCHECKED : MF_CHECKED);
343 break;
344 case IDM_FLAG_INHANDL:
345 vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER;
346 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER);
347 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER);
348 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
349 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
350 vis ? MF_UNCHECKED : MF_CHECKED);
351 break;
352 case IDM_FLAG_LOCSERV:
353 vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER;
354 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER);
355 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER);
356 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
357 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
358 vis ? MF_UNCHECKED : MF_CHECKED);
359 break;
360 case IDM_FLAG_REMSERV:
361 vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER;
362 globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER);
363 globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER);
364 if(!globals.dwClsCtx) globals.dwClsCtx = vis;
365 else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
366 vis ? MF_UNCHECKED : MF_CHECKED);
367 break;
368 case IDM_REFRESH:
369 EmptyTree();
370 if(globals.bExpert) AddTreeEx();
371 else AddTree();
372 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
373 TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
374 SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
375 RefreshMenu(hSelect);
376 break;
377 case IDM_REGEDIT:
379 STARTUPINFOW si;
380 PROCESS_INFORMATION pi;
381 WCHAR app[MAX_PATH];
383 GetWindowsDirectoryW( app, MAX_PATH - sizeof(wszRegEdit)/sizeof(WCHAR) );
384 lstrcatW( app, wszRegEdit );
385 memset(&si, 0, sizeof(si));
386 si.cb = sizeof(si);
387 if (CreateProcessW(app, app, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
389 CloseHandle(pi.hProcess);
390 CloseHandle(pi.hThread);
392 break;
394 case IDM_STATUSBAR:
395 vis = IsWindowVisible(globals.hStatusBar);
396 ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW);
397 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
398 vis ? MF_UNCHECKED : MF_CHECKED);
399 ResizeChild();
400 break;
401 case IDM_SYSCONF:
402 DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF), hWnd, SysConfProc);
403 break;
404 case IDM_TOOLBAR:
405 vis = IsWindowVisible(globals.hToolBar);
406 ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW);
407 CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
408 vis ? MF_UNCHECKED : MF_CHECKED);
409 ResizeChild();
410 break;
411 case IDM_TYPELIB:
413 OPENFILENAMEW ofn;
414 static WCHAR wszTitle[MAX_LOAD_STRING];
415 static WCHAR wszName[MAX_LOAD_STRING];
416 static WCHAR wszFilter[MAX_LOAD_STRING];
418 LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
419 LoadStringW(globals.hMainInst, IDS_OPEN_TYPELIB_FILTER, wszFilter, sizeof(wszFilter)/sizeof(wszFilter[0]));
420 InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName);
421 if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
422 break;
424 case IDM_VIEW:
425 hSelect = (HTREEITEM)SendMessageW(globals.hTree,
426 TVM_GETNEXTITEM, TVGN_CARET, 0);
427 if(IsInterface(hSelect)) InterfaceViewer(hSelect);
428 else CreateTypeLibWindow(globals.hMainInst, NULL);
429 break;
430 case IDM_EXIT:
431 DestroyWindow(hWnd);
432 break;
434 return 0;
437 static void UpdateStatusBar(int itemID)
439 WCHAR info[MAX_LOAD_STRING];
441 if(!LoadStringW(globals.hMainInst, itemID, info, sizeof(info)/sizeof(info[0])))
442 LoadStringW(globals.hMainInst, IDS_READY, info, sizeof(info)/sizeof(info[0]));
444 SendMessageW(globals.hStatusBar, SB_SETTEXTW, 0, (LPARAM)info);
447 static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
448 WPARAM wParam, LPARAM lParam)
450 switch(uMsg)
452 case WM_CREATE:
453 OleInitialize(NULL);
454 PaneRegisterClassW();
455 TypeLibRegisterClassW();
456 if(!CreatePanedWindow(hWnd, &globals.hPaneWnd, globals.hMainInst))
457 PostQuitMessage(0);
458 SetLeft(globals.hPaneWnd, CreateTreeWindow(globals.hMainInst));
459 SetRight(globals.hPaneWnd, CreateDetailsWindow(globals.hMainInst));
460 SetFocus(globals.hTree);
461 break;
462 case WM_COMMAND:
463 MenuCommand(LOWORD(wParam), hWnd);
464 break;
465 case WM_DESTROY:
466 OleUninitialize();
467 EmptyTree();
468 PostQuitMessage(0);
469 break;
470 case WM_MENUSELECT:
471 UpdateStatusBar(LOWORD(wParam));
472 break;
473 case WM_SETFOCUS:
474 SetFocus(globals.hTree);
475 break;
476 case WM_SIZE:
477 if(wParam == SIZE_MINIMIZED) break;
478 ResizeChild();
479 break;
480 default:
481 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
483 return 0;
486 static BOOL InitApplication(HINSTANCE hInst)
488 WNDCLASSW wc;
489 WCHAR wszAppName[MAX_LOAD_STRING];
491 LoadStringW(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
493 memset(&wc, 0, sizeof(WNDCLASSW));
494 wc.lpfnWndProc = WndProc;
495 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
496 wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
497 wc.lpszClassName = wszAppName;
499 if(!RegisterClassW(&wc))
500 return FALSE;
502 return TRUE;
505 static BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
507 HWND hWnd;
508 WCHAR wszAppName[MAX_LOAD_STRING];
509 WCHAR wszTitle[MAX_LOAD_STRING];
510 TBBUTTON tB[] = {
511 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
512 {0, IDM_BIND, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
513 {1, IDM_TYPELIB, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
514 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
515 {2, IDM_REGEDIT, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
516 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
517 {3, IDM_CREATEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
518 {4, IDM_RELEASEINST, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0},
519 {0, 0, 0, BTNS_SEP, {0, 0}, 0, 0},
520 {5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
523 LoadStringW(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
524 LoadStringW(hInst, IDS_APPTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
526 hWnd = CreateWindowW(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW,
527 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
528 if(!hWnd) return FALSE;
530 globals.hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD,
531 wszTitle, hWnd, 0);
533 globals.hToolBar = CreateToolbarEx(hWnd, WS_CHILD|WS_VISIBLE, 0, 1, hInst,
534 IDB_TOOLBAR, tB, 10, 16, 16, 16, 16, sizeof(TBBUTTON));
535 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
536 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
537 SendMessageW(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
539 globals.hMainWnd = hWnd;
540 globals.hMainInst = hInst;
541 globals.bExpert = TRUE;
542 globals.dwClsCtx = CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER;
544 ShowWindow(hWnd, nCmdShow);
545 UpdateWindow(hWnd);
547 return TRUE;
550 int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
552 MSG msg;
553 HANDLE hAccelTable;
555 if(!hPrevInst)
557 if(!InitApplication(hInst))
558 return FALSE;
561 if(!InitInstance(hInst, nCmdShow))
562 return FALSE;
564 hAccelTable = LoadAcceleratorsW(hInst, MAKEINTRESOURCEW(IDA_OLEVIEW));
566 while(GetMessageW(&msg, NULL, 0, 0))
568 if(TranslateAcceleratorW(globals.hMainWnd, hAccelTable, &msg)) continue;
570 TranslateMessage(&msg);
571 DispatchMessageW(&msg);
574 return msg.wParam;