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
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
)
34 WCHAR buffer
[MAX_LOAD_STRING
];
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' };
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
);
76 switch(LOWORD(wParam
)) {
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
);
92 EndDialog(hDlgWnd
, IDOK
);
95 EndDialog(hDlgWnd
, IDCANCEL
);
103 static INT_PTR CALLBACK
CreateInstOnProc(HWND hDlgWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
110 switch(LOWORD(wParam
)) {
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
);
121 EndDialog(hDlgWnd
, IDCANCEL
);
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
)
149 memset(&tvi
, 0, sizeof(TVITEMW
));
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
);
166 static void CopyHTMLTag(HTREEITEM item
)
170 memset(&tvi
, 0, sizeof(TVITEMW
));
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
);
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
);
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
)
218 HMENU hMenu
= GetMenu(globals
.hMainWnd
);
220 memset(&tvi
, 0, sizeof(TVITEMW
));
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
);
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
);
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
)
283 WCHAR wszAbout
[MAX_LOAD_STRING
];
288 LoadStringW(globals
.hMainInst
, IDS_ABOUT
, wszAbout
, ARRAY_SIZE(wszAbout
));
289 ShellAboutW(hWnd
, wszAbout
, NULL
, NULL
);
292 hSelect
= (HTREEITEM
)SendMessageW(globals
.hTree
,
293 TVM_GETNEXTITEM
, TVGN_CARET
, 0);
297 hSelect
= (HTREEITEM
)SendMessageW(globals
.hTree
,
298 TVM_GETNEXTITEM
, TVGN_CARET
, 0);
299 CopyHTMLTag(hSelect
);
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
);
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
);
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
);
323 globals
.bExpert
= !globals
.bExpert
;
324 CheckMenuItem(GetMenu(hWnd
), LOWORD(wParam
),
325 globals
.bExpert
? MF_CHECKED
: MF_UNCHECKED
);
327 if(globals
.bExpert
) AddTreeEx();
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
);
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
);
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
);
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
);
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
);
368 if(globals
.bExpert
) AddTreeEx();
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
);
378 PROCESS_INFORMATION pi
;
381 GetWindowsDirectoryW(app
, MAX_PATH
- ARRAY_SIZE(wszRegEdit
));
382 lstrcatW( app
, wszRegEdit
);
383 memset(&si
, 0, sizeof(si
));
385 if (CreateProcessW(app
, app
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
387 CloseHandle(pi
.hProcess
);
388 CloseHandle(pi
.hThread
);
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
);
400 DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF
), hWnd
, SysConfProc
);
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
);
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};
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
);
426 hSelect
= (HTREEITEM
)SendMessageW(globals
.hTree
,
427 TVM_GETNEXTITEM
, TVGN_CARET
, 0);
428 if(IsInterface(hSelect
)) InterfaceViewer(hSelect
);
429 else CreateTypeLibWindow(globals
.hMainInst
, NULL
);
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
)
455 PaneRegisterClassW();
456 TypeLibRegisterClassW();
457 if(!CreatePanedWindow(hWnd
, &globals
.hPaneWnd
, globals
.hMainInst
))
459 SetLeft(globals
.hPaneWnd
, CreateTreeWindow(globals
.hMainInst
));
460 SetRight(globals
.hPaneWnd
, CreateDetailsWindow(globals
.hMainInst
));
461 SetFocus(globals
.hTree
);
464 MenuCommand(LOWORD(wParam
), hWnd
);
472 UpdateStatusBar(LOWORD(wParam
));
475 SetFocus(globals
.hTree
);
478 if(wParam
== SIZE_MINIMIZED
) break;
482 return DefWindowProcW(hWnd
, uMsg
, wParam
, lParam
);
487 static BOOL
InitApplication(HINSTANCE hInst
)
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
))
507 static BOOL
InitInstance(HINSTANCE hInst
, int nCmdShow
)
510 WCHAR wszAppName
[MAX_LOAD_STRING
];
511 WCHAR wszTitle
[MAX_LOAD_STRING
];
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
,
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
);
552 int APIENTRY
WinMain(HINSTANCE hInst
, HINSTANCE hPrevInst
, LPSTR lpCmdLine
, int nCmdShow
)
557 if(!InitApplication(hInst
))
560 if(!InitInstance(hInst
, nCmdShow
))
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
);