Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

582 lines
20 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: WIADBGUI.CPP
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 5/11/1998
  12. *
  13. * DESCRIPTION: Private interfaces for the debug window
  14. *
  15. *******************************************************************************/
  16. #include <windows.h>
  17. #include <commctrl.h>
  18. #include <shfusion.h>
  19. #define IN_WIA_DEBUG_CODE 1
  20. #include "wianew.h"
  21. #include "wiadbgui.h"
  22. #include "simstr.h"
  23. #include "simcrack.h"
  24. #include "waitcurs.h"
  25. #include "resource.h"
  26. #include "dbgmask.h"
  27. HINSTANCE g_hInstance;
  28. #define ID_LISTBOX 1000
  29. /*
  30. * Constructor
  31. */
  32. CWiaDebugWindow::CWiaDebugWindow( HWND hWnd )
  33. : m_hWnd(hWnd),
  34. m_hDebugUiMutex(NULL)
  35. {
  36. }
  37. /*
  38. * Destructor
  39. */
  40. CWiaDebugWindow::~CWiaDebugWindow(void)
  41. {
  42. }
  43. /*
  44. * Add a string/color to the list and set the selection to the last
  45. * string, if the last string was already selected.
  46. */
  47. LRESULT CWiaDebugWindow::OnAddString( WPARAM wParam, LPARAM lParam )
  48. {
  49. HWND hWndListBox = GetDlgItem(m_hWnd,ID_LISTBOX);
  50. if (hWndListBox)
  51. {
  52. LRESULT nIndex = SendMessage( hWndListBox, LB_ADDSTRING, 0, lParam );
  53. // If the listbox is full, remove the first 1000 items
  54. if (nIndex == LB_ERR)
  55. {
  56. for (int i=0;i<1000;i++)
  57. {
  58. // Remove the 0th item, 1000 times
  59. SendMessage( hWndListBox, LB_DELETESTRING, 0, 0 );
  60. }
  61. nIndex = SendMessage( hWndListBox, LB_ADDSTRING, 0, lParam );
  62. }
  63. if (nIndex != LB_ERR)
  64. {
  65. int nSelCount = static_cast<int>(SendMessage( hWndListBox, LB_GETSELCOUNT, 0, 0 ));
  66. if (nSelCount == 0)
  67. {
  68. SendMessage(hWndListBox, LB_SETSEL, TRUE, nIndex );
  69. SendMessage(hWndListBox, LB_SETTOPINDEX, nIndex, 0 );
  70. }
  71. else if (nSelCount == 1)
  72. {
  73. int nSelIndex;
  74. SendMessage( hWndListBox, LB_GETSELITEMS, static_cast<WPARAM>(1), reinterpret_cast<LPARAM>(&nSelIndex) );
  75. if (nSelIndex == nIndex-1)
  76. {
  77. SendMessage(hWndListBox, LB_SETSEL, FALSE, -1 );
  78. SendMessage(hWndListBox, LB_SETSEL, TRUE, nIndex );
  79. SendMessage(hWndListBox, LB_SETTOPINDEX, nIndex, 0 );
  80. }
  81. }
  82. UpdateWindow(hWndListBox);
  83. return(nIndex);
  84. }
  85. }
  86. return(-1);
  87. }
  88. /*
  89. * Copy selected strings in the listbox to the clipboard
  90. */
  91. void CWiaDebugWindow::OnCopy( WPARAM, LPARAM )
  92. {
  93. CWaitCursor wc;
  94. HWND hwndList = GetDlgItem( m_hWnd, ID_LISTBOX );
  95. if (hwndList)
  96. {
  97. int nSelCount;
  98. nSelCount = (int)SendMessage(hwndList,LB_GETSELCOUNT,0,0);
  99. if (nSelCount)
  100. {
  101. int *nSelIndices = new int[nSelCount];
  102. if (nSelIndices)
  103. {
  104. if (nSelCount == SendMessage( hwndList, LB_GETSELITEMS, (WPARAM)nSelCount, (LPARAM)nSelIndices ))
  105. {
  106. int nTotalLength = 0;
  107. for (int i=0;i<nSelCount;i++)
  108. {
  109. CDebugWindowStringData *pData = GetStringData(nSelIndices[i]);
  110. if (pData)
  111. {
  112. int nLineCount = 1;
  113. int nLen = pData->String() ? lstrlen(pData->String()) : 0;
  114. for (LPTSTR pszTmpPtr = pData->String();pszTmpPtr && *pszTmpPtr;pszTmpPtr++)
  115. {
  116. if (TEXT('\n') == *pszTmpPtr)
  117. {
  118. nLineCount++;
  119. }
  120. }
  121. nTotalLength += (nLen + (nLineCount * 2));
  122. }
  123. }
  124. HGLOBAL hGlobal = GlobalAlloc(GMEM_DDESHARE,(nTotalLength+1)*sizeof(TCHAR));
  125. if (hGlobal)
  126. {
  127. LPTSTR pszBuffer = (LPTSTR)GlobalLock(hGlobal);
  128. if (pszBuffer)
  129. {
  130. LPTSTR pszTgt = pszBuffer;
  131. for (i = 0;i<nSelCount;i++)
  132. {
  133. CDebugWindowStringData *pData = GetStringData(nSelIndices[i]);
  134. if (pData)
  135. {
  136. for (LPTSTR pszSrc = pData->String();pszSrc && *pszSrc;pszSrc++)
  137. {
  138. if (TEXT('\n') == *pszSrc)
  139. *pszTgt++ = TEXT('\r');
  140. if (TEXT('\r') != *pszSrc) // Discard \r
  141. *pszTgt++ = *pszSrc;
  142. }
  143. if (i<nSelCount-1)
  144. {
  145. // Don't append a \r\n to the last string
  146. *pszTgt++ = TEXT('\r');
  147. *pszTgt++ = TEXT('\n');
  148. }
  149. }
  150. }
  151. *pszTgt = TEXT('\0');
  152. GlobalUnlock(pszBuffer);
  153. if (OpenClipboard(hwndList))
  154. {
  155. EmptyClipboard();
  156. SetClipboardData(sizeof(TCHAR)==sizeof(char) ? CF_TEXT : CF_UNICODETEXT,hGlobal);
  157. CloseClipboard();
  158. }
  159. }
  160. }
  161. }
  162. delete[] nSelIndices;
  163. }
  164. }
  165. }
  166. }
  167. /*
  168. * Delete selected strings
  169. */
  170. void CWiaDebugWindow::OnDelete( WPARAM, LPARAM )
  171. {
  172. CWaitCursor wc;
  173. HWND hwndList = GetDlgItem( m_hWnd, ID_LISTBOX );
  174. if (hwndList)
  175. {
  176. int nSelCount;
  177. nSelCount = (int)SendMessage(hwndList,LB_GETSELCOUNT,0,0);
  178. if (nSelCount)
  179. {
  180. int *nSelIndices = new int[nSelCount];
  181. if (nSelIndices)
  182. {
  183. if (nSelCount == SendMessage( hwndList, LB_GETSELITEMS, (WPARAM)nSelCount, (LPARAM)nSelIndices ))
  184. {
  185. SendMessage( hwndList, WM_SETREDRAW, 0, 0 );
  186. for (int i=0,nOffset=0;i<nSelCount;i++,nOffset++)
  187. {
  188. SendMessage( hwndList, LB_DELETESTRING, nSelIndices[i]-nOffset, 0 );
  189. }
  190. int nCount = (int)SendMessage( hwndList, LB_GETCOUNT, 0, 0 );
  191. int nSel = nSelIndices[i-1]-nOffset+1;
  192. if (nSel >= nCount)
  193. nSel = nCount-1;
  194. SendMessage( hwndList, LB_SETSEL, TRUE, nSel );
  195. SendMessage( hwndList, WM_SETREDRAW, 1, 0 );
  196. InvalidateRect( hwndList, NULL, FALSE );
  197. UpdateWindow( hwndList );
  198. }
  199. delete[] nSelIndices;
  200. }
  201. }
  202. }
  203. }
  204. void CWiaDebugWindow::OnCut( WPARAM, LPARAM )
  205. {
  206. SendMessage( m_hWnd, WM_COMMAND, ID_COPY, 0 );
  207. SendMessage( m_hWnd, WM_COMMAND, ID_DELETE, 0 );
  208. }
  209. /*
  210. * Respond to WM_CREATE
  211. */
  212. LRESULT CWiaDebugWindow::OnCreate( WPARAM, LPARAM lParam )
  213. {
  214. LPCREATESTRUCT pCreateStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
  215. m_hDebugUiMutex = CreateMutex( NULL, FALSE, WIADEBUG_DEBUGCLIENT_MUTEXNAME );
  216. if (!m_hDebugUiMutex)
  217. {
  218. HWND hWndOtherDbgWindow = m_DebugData.DebugWindow();
  219. if (hWndOtherDbgWindow)
  220. SetForegroundWindow(hWndOtherDbgWindow);
  221. return -1;
  222. }
  223. DWORD dwWait = WaitForSingleObject( m_hDebugUiMutex, 1000 );
  224. if (dwWait != WAIT_OBJECT_0)
  225. {
  226. HWND hWndOtherDbgWindow = m_DebugData.DebugWindow();
  227. if (hWndOtherDbgWindow)
  228. SetForegroundWindow(hWndOtherDbgWindow);
  229. return -1;
  230. }
  231. // Set the debug window
  232. if (!m_DebugData.DebugWindow(m_hWnd))
  233. {
  234. MessageBox( m_hWnd, TEXT("Unable to register debug window"), TEXT("Error"), MB_ICONHAND );
  235. return -1;
  236. }
  237. //
  238. // Set the icons
  239. //
  240. SendMessage( m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadImage(pCreateStruct->hInstance,MAKEINTRESOURCE(IDI_BUG),IMAGE_ICON,GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON),LR_DEFAULTCOLOR) );
  241. SendMessage( m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadImage(pCreateStruct->hInstance,MAKEINTRESOURCE(IDI_BUG),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),LR_DEFAULTCOLOR) );
  242. // Create the listbox
  243. HWND hWndList = CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("LISTBOX"), NULL,
  244. WS_CHILD|WS_VISIBLE|LBS_USETABSTOPS|WS_VSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWVARIABLE|LBS_EXTENDEDSEL|WS_HSCROLL
  245. , 0, 0, 0, 0, m_hWnd, reinterpret_cast<HMENU>(ID_LISTBOX), pCreateStruct->hInstance, NULL );
  246. if (hWndList == NULL)
  247. return(-1);
  248. // Set the font to a more readable fixed font
  249. SendMessage( hWndList, WM_SETFONT, reinterpret_cast<WPARAM>(GetStockObject(ANSI_FIXED_FONT)), MAKELPARAM(TRUE,0));
  250. SendMessage( hWndList, LB_SETHORIZONTALEXTENT, 32767, 0);
  251. return(0);
  252. }
  253. LRESULT CWiaDebugWindow::OnDestroy( WPARAM, LPARAM )
  254. {
  255. DWORD dwWait = WaitForSingleObject( m_hDebugUiMutex, 1000 );
  256. if (dwWait == WAIT_OBJECT_0)
  257. {
  258. m_DebugData.DebugWindow(NULL);
  259. ReleaseMutex(m_hDebugUiMutex);
  260. }
  261. return 0;
  262. }
  263. /*
  264. * Respond to WM_SIZE
  265. */
  266. LRESULT CWiaDebugWindow::OnSize( WPARAM wParam, LPARAM lParam )
  267. {
  268. if (SIZE_MAXIMIZED == wParam || SIZE_RESTORED == wParam)
  269. MoveWindow(GetDlgItem(m_hWnd,ID_LISTBOX), 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  270. return(0);
  271. }
  272. CDebugWindowStringData *CWiaDebugWindow::GetStringData( int nIndex )
  273. {
  274. return reinterpret_cast<CDebugWindowStringData*>(SendDlgItemMessage( m_hWnd, ID_LISTBOX, LB_GETITEMDATA, nIndex, 0 ));
  275. }
  276. LRESULT CWiaDebugWindow::OnDeleteItem( WPARAM wParam, LPARAM lParam )
  277. {
  278. if (wParam == ID_LISTBOX)
  279. {
  280. LPDELETEITEMSTRUCT pDeleteItemStruct = reinterpret_cast<LPDELETEITEMSTRUCT>(lParam);
  281. if (pDeleteItemStruct)
  282. {
  283. CDebugWindowStringData *pDebugWindowStringData = reinterpret_cast<CDebugWindowStringData*>(pDeleteItemStruct->itemData);
  284. if (pDebugWindowStringData)
  285. {
  286. delete pDebugWindowStringData;
  287. }
  288. }
  289. }
  290. return 0;
  291. }
  292. /*
  293. * Respond to WM_MEASUREITEM
  294. */
  295. LRESULT CWiaDebugWindow::OnMeasureItem( WPARAM wParam, LPARAM lParam )
  296. {
  297. if (wParam == ID_LISTBOX)
  298. {
  299. LPMEASUREITEMSTRUCT pMeasureItemStruct = reinterpret_cast<LPMEASUREITEMSTRUCT>(lParam);
  300. if (pMeasureItemStruct)
  301. {
  302. // Get the font
  303. HFONT hFontWnd = NULL;
  304. HWND hWndListBox = GetDlgItem(m_hWnd,ID_LISTBOX);
  305. if (hWndListBox)
  306. hFontWnd = (HFONT)::SendMessage( hWndListBox, WM_GETFONT, 0, 0 );
  307. if (!hFontWnd)
  308. hFontWnd = (HFONT)::GetStockObject(SYSTEM_FONT);
  309. HDC hDC = GetDC( hWndListBox );
  310. if (hDC)
  311. {
  312. HFONT hOldFont = (HFONT)::SelectObject( hDC, (HGDIOBJ)hFontWnd );
  313. TEXTMETRIC tm;
  314. GetTextMetrics( hDC, &tm );
  315. int nLineHeight = tm.tmHeight + tm.tmExternalLeading + 2;
  316. int nLineCount = 1;
  317. if (pMeasureItemStruct->itemID != static_cast<UINT>(-1))
  318. {
  319. CDebugWindowStringData *pDebugWindowStringData = reinterpret_cast<CDebugWindowStringData*>(pMeasureItemStruct->itemData);
  320. if (pDebugWindowStringData)
  321. {
  322. for (LPTSTR lpszPtr = pDebugWindowStringData->String();lpszPtr && *lpszPtr;lpszPtr++)
  323. if (*lpszPtr == TEXT('\n'))
  324. nLineCount++;
  325. }
  326. }
  327. pMeasureItemStruct->itemHeight = nLineHeight * nLineCount;
  328. SelectObject( hDC, hOldFont );
  329. ReleaseDC( hWndListBox, hDC );
  330. }
  331. }
  332. }
  333. return(0);
  334. }
  335. /*
  336. * Respond to WM_DRAWITEM
  337. */
  338. LRESULT CWiaDebugWindow::OnDrawItem( WPARAM wParam, LPARAM lParam )
  339. {
  340. if (wParam == ID_LISTBOX)
  341. {
  342. LPDRAWITEMSTRUCT pDrawItemStruct = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
  343. if (pDrawItemStruct)
  344. {
  345. // Save the draw rect
  346. RECT rcItem = pDrawItemStruct->rcItem;
  347. // Get the data
  348. CDebugWindowStringData *pDebugWindowStringData = NULL;
  349. if (pDrawItemStruct->itemID != (UINT)-1)
  350. pDebugWindowStringData = reinterpret_cast<CDebugWindowStringData*>(pDrawItemStruct->itemData);
  351. // Get the foreground color
  352. COLORREF crForeground;
  353. if (pDrawItemStruct->itemState & ODS_SELECTED)
  354. crForeground = GetSysColor(COLOR_HIGHLIGHTTEXT);
  355. else if (pDebugWindowStringData)
  356. crForeground = pDebugWindowStringData->ForegroundColor();
  357. else crForeground = GetSysColor(COLOR_WINDOWTEXT);
  358. // Get the background color
  359. COLORREF crBackground;
  360. if (pDrawItemStruct->itemState & ODS_SELECTED)
  361. crBackground = GetSysColor(COLOR_HIGHLIGHT);
  362. else if (pDebugWindowStringData)
  363. crBackground = pDebugWindowStringData->BackgroundColor();
  364. else crBackground = GetSysColor(COLOR_WINDOW);
  365. // Paint the background
  366. COLORREF crOldBkColor = SetBkColor( pDrawItemStruct->hDC, crBackground );
  367. ExtTextOut( pDrawItemStruct->hDC, rcItem.left, rcItem.top, ETO_OPAQUE, &rcItem, NULL, 0, NULL );
  368. SetBkColor( pDrawItemStruct->hDC, crOldBkColor );
  369. if (pDebugWindowStringData)
  370. {
  371. COLORREF crOldColor = SetTextColor(pDrawItemStruct->hDC,crForeground);
  372. if (pDebugWindowStringData->String())
  373. {
  374. int nLength = lstrlen(pDebugWindowStringData->String());
  375. for (;nLength>0;nLength--)
  376. {
  377. if (pDebugWindowStringData->String()[nLength-1] != TEXT('\n'))
  378. break;
  379. }
  380. int nOldBkMode = SetBkMode( pDrawItemStruct->hDC, TRANSPARENT );
  381. InflateRect( &rcItem, -1, -1 );
  382. DrawTextEx( pDrawItemStruct->hDC, pDebugWindowStringData->String(), nLength, &rcItem, DT_LEFT|DT_NOPREFIX|DT_EXPANDTABS, NULL );
  383. SetBkMode( pDrawItemStruct->hDC, nOldBkMode );
  384. }
  385. SetTextColor(pDrawItemStruct->hDC,crOldColor);
  386. }
  387. if (pDrawItemStruct->itemState & ODS_FOCUS)
  388. {
  389. DrawFocusRect( pDrawItemStruct->hDC, &pDrawItemStruct->rcItem );
  390. }
  391. }
  392. }
  393. return(0);
  394. }
  395. /*
  396. * Respond to WM_SETFOCUS
  397. */
  398. LRESULT CWiaDebugWindow::OnSetFocus( WPARAM, LPARAM )
  399. {
  400. HWND hWndListBox = GetDlgItem(m_hWnd,ID_LISTBOX);
  401. if (hWndListBox)
  402. ::SetFocus(hWndListBox);
  403. return(0);
  404. }
  405. LRESULT CWiaDebugWindow::OnClose( WPARAM, LPARAM )
  406. {
  407. PostQuitMessage(0);
  408. return(0);
  409. }
  410. void CWiaDebugWindow::OnSelectAll( WPARAM, LPARAM )
  411. {
  412. SendDlgItemMessage(m_hWnd,ID_LISTBOX,LB_SETSEL,TRUE,-1);
  413. }
  414. LRESULT CWiaDebugWindow::OnCopyData( WPARAM wParam, LPARAM lParam )
  415. {
  416. COPYDATASTRUCT *pCopyDataStruct = reinterpret_cast<COPYDATASTRUCT*>(lParam);
  417. if (pCopyDataStruct && pCopyDataStruct->dwData == 0xDEADBEEF)
  418. {
  419. CDebugStringMessageData *pDebugStringMessageData = reinterpret_cast<CDebugStringMessageData*>(pCopyDataStruct->lpData);
  420. if (pDebugStringMessageData)
  421. {
  422. CSimpleString strMsg = pDebugStringMessageData->bUnicode ?
  423. CSimpleStringConvert::NaturalString( CSimpleStringWide(reinterpret_cast<LPWSTR>(pDebugStringMessageData->szString) ) ) :
  424. CSimpleStringConvert::NaturalString( CSimpleStringAnsi(reinterpret_cast<LPSTR>(pDebugStringMessageData->szString) ) );
  425. CDebugWindowStringData *pDebugWindowStringData = CDebugWindowStringData::Allocate( strMsg, pDebugStringMessageData->crBackground, pDebugStringMessageData->crForeground );
  426. if (pDebugWindowStringData)
  427. {
  428. PostMessage( m_hWnd, DWM_ADDSTRING, 0, reinterpret_cast<LPARAM>(pDebugWindowStringData) );
  429. }
  430. }
  431. }
  432. return TRUE;
  433. }
  434. void CWiaDebugWindow::OnQuit( WPARAM, LPARAM )
  435. {
  436. SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
  437. }
  438. void CWiaDebugWindow::OnFlags( WPARAM, LPARAM )
  439. {
  440. DialogBoxParam( g_hInstance, MAKEINTRESOURCE(IDD_FLAGS_DIALOG), m_hWnd, CDebugMaskDialog::DialogProc, NULL );
  441. }
  442. LRESULT CWiaDebugWindow::OnCommand( WPARAM wParam, LPARAM lParam )
  443. {
  444. SC_BEGIN_COMMAND_HANDLERS()
  445. {
  446. SC_HANDLE_COMMAND(ID_COPY,OnCopy);
  447. SC_HANDLE_COMMAND(ID_CUT,OnCut);
  448. SC_HANDLE_COMMAND(ID_DELETE,OnDelete);
  449. SC_HANDLE_COMMAND(ID_SELECTALL,OnSelectAll);
  450. SC_HANDLE_COMMAND(IDM_QUIT,OnQuit);
  451. SC_HANDLE_COMMAND(IDM_FLAGS,OnFlags);
  452. }
  453. SC_END_COMMAND_HANDLERS();
  454. }
  455. /*
  456. * Main window proc
  457. */
  458. LRESULT CALLBACK CWiaDebugWindow::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  459. {
  460. SC_BEGIN_MESSAGE_HANDLERS(CWiaDebugWindow)
  461. {
  462. SC_HANDLE_MESSAGE( WM_CREATE, OnCreate );
  463. SC_HANDLE_MESSAGE( WM_DESTROY, OnDestroy );
  464. SC_HANDLE_MESSAGE( WM_SIZE, OnSize );
  465. SC_HANDLE_MESSAGE( WM_DELETEITEM, OnDeleteItem );
  466. SC_HANDLE_MESSAGE( WM_MEASUREITEM, OnMeasureItem );
  467. SC_HANDLE_MESSAGE( WM_DRAWITEM, OnDrawItem );
  468. SC_HANDLE_MESSAGE( WM_SETFOCUS, OnSetFocus );
  469. SC_HANDLE_MESSAGE( WM_CLOSE, OnClose );
  470. SC_HANDLE_MESSAGE( WM_COMMAND, OnCommand );
  471. SC_HANDLE_MESSAGE( WM_COPYDATA, OnCopyData );
  472. SC_HANDLE_MESSAGE( DWM_ADDSTRING, OnAddString );
  473. }
  474. SC_END_MESSAGE_HANDLERS();
  475. }
  476. /*
  477. * Register the window class
  478. */
  479. BOOL CWiaDebugWindow::Register( HINSTANCE hInstance )
  480. {
  481. WNDCLASSEX wcex;
  482. ZeroMemory( &wcex, sizeof(wcex) );
  483. wcex.cbSize = sizeof(wcex);
  484. wcex.style = 0;
  485. wcex.lpfnWndProc = WndProc;
  486. wcex.hInstance = hInstance;
  487. wcex.hIcon = NULL;
  488. wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW);
  489. wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
  490. wcex.lpszClassName = DEBUGWINDOW_CLASSNAME;
  491. wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
  492. if (!::RegisterClassEx(&wcex))
  493. return(FALSE);
  494. return(TRUE);
  495. }
  496. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nShowCmd )
  497. {
  498. g_hInstance = hInstance;
  499. InitCommonControls();
  500. SHFusionInitialize(NULL);
  501. if (CWiaDebugWindow::Register(hInstance))
  502. {
  503. HWND hWnd = CreateWindowEx( 0, DEBUGWINDOW_CLASSNAME, TEXT("Debug Window"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, 0, hInstance, NULL );
  504. if (hWnd)
  505. {
  506. ShowWindow(hWnd,nShowCmd);
  507. UpdateWindow(hWnd);
  508. HACCEL hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(IDR_DBGWND_ACCEL) );
  509. if (hAccel)
  510. {
  511. MSG msg;
  512. while (GetMessage(&msg,0,0,0))
  513. {
  514. if (!TranslateAccelerator( hWnd, hAccel, &msg ))
  515. {
  516. TranslateMessage(&msg);
  517. DispatchMessage(&msg);
  518. }
  519. }
  520. }
  521. }
  522. }
  523. SHFusionUninitialize();
  524. return 0;
  525. }