Leaked source code of windows server 2003
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.

830 lines
22 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* Microsoft Confidential */
  4. /* */
  5. /* Copyright (c) Microsoft Corp. 1987, 1990 */
  6. /* All Rights Reserved */
  7. /* */
  8. /****************************************************************************/
  9. /****************************** Module Header *******************************
  10. * Module Name: zoomin.c
  11. *
  12. * Microsoft ZoomIn utility. This tool magnifies a portion of the screen,
  13. * allowing you to see things at a pixel level.
  14. *
  15. * History:
  16. * 01/01/88 ToddLa Created.
  17. * 01/01/92 MarkTa Ported to NT.
  18. * 03/06/92 ByronD Cleanup.
  19. *
  20. ****************************************************************************/
  21. #include "zoomin.h"
  22. TCHAR szAppName[] = TEXT("ZoomIn"); // Aplication name.
  23. HINSTANCE ghInst; // Instance handle.
  24. HWND ghwndApp; // Main window handle.
  25. HANDLE ghaccelTable; // Main accelerator table.
  26. INT gnZoom = 4; // Zoom (magnification) factor.
  27. HPALETTE ghpalPhysical; // Handle to the physical palette.
  28. INT gcxScreenMax; // Width of the screen (less 1).
  29. INT gcyScreenMax; // Height of the screen (less 1).
  30. INT gcxZoomed; // Client width in zoomed pixels.
  31. INT gcyZoomed; // Client height in zoomed pixels.
  32. BOOL gfRefEnable = FALSE; // TRUE if refresh is enabled.
  33. INT gnRefInterval = 20; // Refresh interval in 10ths of seconds.
  34. BOOL gfTracking = FALSE; // TRUE if tracking is in progress.
  35. POINT gptZoom = {100, 100}; // The center of the zoomed area.
  36. BOOL gShowGrid = FALSE; // Show a grid so you can see the pixels
  37. /************************************************************************
  38. * WinMain
  39. *
  40. * Main entry point for the application.
  41. *
  42. * Arguments:
  43. *
  44. * History:
  45. *
  46. ************************************************************************/
  47. INT
  48. WINAPI
  49. WinMain(
  50. HINSTANCE hInst,
  51. HINSTANCE hPrevInst,
  52. LPSTR lpCmdLine,
  53. INT nCmdShow
  54. )
  55. {
  56. MSG msg;
  57. if (!InitInstance(hInst, nCmdShow))
  58. return FALSE;
  59. /*
  60. * Polling messages from event queue
  61. */
  62. while (GetMessage(&msg, NULL, 0, 0)) {
  63. if (!TranslateAccelerator(ghwndApp, ghaccelTable, &msg)) {
  64. TranslateMessage(&msg);
  65. DispatchMessage(&msg);
  66. }
  67. }
  68. return (INT)msg.wParam;
  69. }
  70. /************************************************************************
  71. * InitInstance
  72. *
  73. * Instance initialization for the app.
  74. *
  75. * Arguments:
  76. *
  77. * History:
  78. *
  79. ************************************************************************/
  80. BOOL
  81. InitInstance(
  82. HINSTANCE hInst,
  83. INT cmdShow
  84. )
  85. {
  86. WNDCLASS wc;
  87. INT dx;
  88. INT dy;
  89. DWORD flStyle;
  90. RECT rc;
  91. ghInst = hInst;
  92. /*
  93. * Register a class for the main application window.
  94. */
  95. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  96. wc.hIcon = LoadIcon(hInst, TEXT("zoomin"));
  97. wc.lpszMenuName = MAKEINTRESOURCE(IDMENU_ZOOMIN);
  98. wc.lpszClassName = szAppName;
  99. wc.hbrBackground = GetStockObject(BLACK_BRUSH);
  100. wc.hInstance = hInst;
  101. wc.style = CS_VREDRAW | CS_HREDRAW;
  102. wc.lpfnWndProc = AppWndProc;
  103. wc.cbWndExtra = 0;
  104. wc.cbClsExtra = 0;
  105. if (!RegisterClass(&wc))
  106. return FALSE;
  107. if (!(ghaccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDACCEL_ZOOMIN))))
  108. return FALSE;
  109. if (!(ghpalPhysical = CreatePhysicalPalette()))
  110. return FALSE;
  111. /* Get the size of the screen.
  112. ** In NT 4.0 sp3 and NT 5.0 new system metrics would get the
  113. ** desktop area which may go across multiple monitors. If that
  114. ** doesn't work, fall back to the old method.
  115. */
  116. #ifdef SM_CXVIRTUALSCREEN
  117. if( GetSystemMetrics(SM_CXVIRTUALSCREEN) )
  118. {
  119. gcxScreenMax= GetSystemMetrics(SM_CXVIRTUALSCREEN) -1;
  120. gcyScreenMax= GetSystemMetrics(SM_CYVIRTUALSCREEN) -1;
  121. }
  122. else
  123. #endif
  124. {
  125. gcxScreenMax= GetSystemMetrics(SM_CXSCREEN) - 1;
  126. gcyScreenMax= GetSystemMetrics(SM_CYSCREEN) - 1;
  127. }
  128. flStyle = WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_THICKFRAME |
  129. WS_MINIMIZEBOX | WS_VSCROLL;
  130. dx = 44 * gnZoom;
  131. dy = 36 * gnZoom;
  132. SetRect(&rc, 0, 0, dx, dy);
  133. AdjustWindowRect(&rc, flStyle, TRUE);
  134. ghwndApp = CreateWindow(szAppName, szAppName, flStyle,
  135. CW_USEDEFAULT, 0, rc.right - rc.left, rc.bottom - rc.top,
  136. NULL, NULL, hInst, NULL);
  137. if (!ghwndApp)
  138. return FALSE;
  139. ShowWindow(ghwndApp, cmdShow);
  140. return TRUE;
  141. }
  142. /************************************************************************
  143. * CreatePhysicalPalette
  144. *
  145. * Creates a palette for the app to use. The palette references the
  146. * physical palette, so that it can properly display images grabbed
  147. * from palette managed apps.
  148. *
  149. * History:
  150. *
  151. ************************************************************************/
  152. HPALETTE
  153. CreatePhysicalPalette(
  154. VOID
  155. )
  156. {
  157. PLOGPALETTE ppal;
  158. HPALETTE hpal = NULL;
  159. INT i;
  160. ppal = (PLOGPALETTE)LocalAlloc(LPTR,
  161. sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * NPAL);
  162. if (ppal) {
  163. ppal->palVersion = 0x300;
  164. ppal->palNumEntries = NPAL;
  165. for (i = 0; i < NPAL; i++) {
  166. ppal->palPalEntry[i].peFlags = (BYTE)PC_EXPLICIT;
  167. ppal->palPalEntry[i].peRed = (BYTE)i;
  168. ppal->palPalEntry[i].peGreen = (BYTE)0;
  169. ppal->palPalEntry[i].peBlue = (BYTE)0;
  170. }
  171. hpal = CreatePalette(ppal);
  172. LocalFree(ppal);
  173. }
  174. return hpal;
  175. }
  176. /************************************************************************
  177. * AppWndProc
  178. *
  179. * Main window proc for the zoomin utility.
  180. *
  181. * Arguments:
  182. * Standard window proc args.
  183. *
  184. * History:
  185. *
  186. ************************************************************************/
  187. INT_PTR
  188. APIENTRY
  189. AppWndProc(
  190. HWND hwnd,
  191. UINT msg,
  192. WPARAM wParam,
  193. LPARAM lParam
  194. )
  195. {
  196. PAINTSTRUCT ps;
  197. PRECT prc;
  198. HCURSOR hcurOld;
  199. switch (msg) {
  200. case WM_CREATE:
  201. SetScrollRange(hwnd, SB_VERT, MIN_ZOOM, MAX_ZOOM, FALSE);
  202. SetScrollPos(hwnd, SB_VERT, gnZoom, FALSE);
  203. break;
  204. case WM_TIMER:
  205. /*
  206. * Update on every timer message. The cursor will be
  207. * flashed to the hourglash for some visual feedback
  208. * of when a snapshot is being taken.
  209. */
  210. hcurOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
  211. DoTheZoomIn(NULL);
  212. SetCursor(hcurOld);
  213. break;
  214. case WM_PAINT:
  215. BeginPaint(hwnd, &ps);
  216. DoTheZoomIn(ps.hdc);
  217. EndPaint(hwnd, &ps);
  218. return 0L;
  219. case WM_SIZE:
  220. CalcZoomedSize();
  221. break;
  222. case WM_LBUTTONDOWN:
  223. gptZoom.x= (SHORT) LOWORD(lParam);
  224. gptZoom.y= (SHORT) HIWORD(lParam);
  225. ClientToScreen(hwnd, &gptZoom);
  226. DrawZoomRect();
  227. DoTheZoomIn(NULL);
  228. SetCapture(hwnd);
  229. gfTracking = TRUE;
  230. break;
  231. case WM_MOUSEMOVE:
  232. if (gfTracking) {
  233. DrawZoomRect();
  234. gptZoom.x= (SHORT) LOWORD(lParam);
  235. gptZoom.y= (SHORT) HIWORD(lParam);
  236. ClientToScreen(hwnd, &gptZoom);
  237. DrawZoomRect();
  238. DoTheZoomIn(NULL);
  239. }
  240. break;
  241. case WM_LBUTTONUP:
  242. if (gfTracking) {
  243. DrawZoomRect();
  244. ReleaseCapture();
  245. gfTracking = FALSE;
  246. }
  247. break;
  248. case WM_VSCROLL:
  249. switch (LOWORD(wParam)) {
  250. case SB_LINEDOWN:
  251. gnZoom++;
  252. break;
  253. case SB_LINEUP:
  254. gnZoom--;
  255. break;
  256. case SB_PAGEUP:
  257. gnZoom -= 2;
  258. break;
  259. case SB_PAGEDOWN:
  260. gnZoom += 2;
  261. break;
  262. case SB_THUMBPOSITION:
  263. case SB_THUMBTRACK:
  264. gnZoom = HIWORD(wParam);
  265. break;
  266. }
  267. gnZoom = BOUND(gnZoom, MIN_ZOOM, MAX_ZOOM);
  268. SetScrollPos(hwnd, SB_VERT, gnZoom, TRUE);
  269. CalcZoomedSize();
  270. DoTheZoomIn(NULL);
  271. break;
  272. case WM_KEYDOWN:
  273. switch (wParam) {
  274. case VK_UP:
  275. case VK_DOWN:
  276. case VK_LEFT:
  277. case VK_RIGHT:
  278. MoveView((INT)wParam, GetKeyState(VK_SHIFT) & 0x8000, GetKeyState(VK_CONTROL) & 0x8000);
  279. break;
  280. }
  281. break;
  282. case WM_COMMAND:
  283. switch (LOWORD(wParam)) {
  284. case MENU_EDIT_COPY:
  285. CopyToClipboard();
  286. break;
  287. case MENU_EDIT_REFRESH:
  288. DoTheZoomIn(NULL);
  289. break;
  290. case MENU_OPTIONS_REFRESHRATE:
  291. DialogBox(ghInst, MAKEINTRESOURCE(DID_REFRESHRATE), hwnd, RefreshRateDlgProc);
  292. break;
  293. case MENU_HELP_ABOUT:
  294. DialogBox(ghInst, MAKEINTRESOURCE(DID_ABOUT), hwnd, AboutDlgProc);
  295. break;
  296. case MENU_OPTIONS_SHOWGRID:
  297. {
  298. HMENU hMenu = GetSubMenu(GetMenu(ghwndApp), 1);
  299. gShowGrid = !gShowGrid;
  300. InvalidateRect(ghwndApp, NULL, FALSE);
  301. CheckMenuItem(hMenu,
  302. GetMenuItemID(hMenu, 1),
  303. gShowGrid ? MF_CHECKED : MF_UNCHECKED);
  304. }
  305. break;
  306. default:
  307. break;
  308. }
  309. break;
  310. case WM_CLOSE:
  311. if (ghpalPhysical)
  312. DeleteObject(ghpalPhysical);
  313. DestroyWindow(hwnd);
  314. break;
  315. case WM_DESTROY:
  316. PostQuitMessage(0);
  317. break;
  318. default:
  319. return DefWindowProc(hwnd, msg, wParam, lParam);
  320. }
  321. return 0L;
  322. }
  323. /************************************************************************
  324. * CalcZoomedSize
  325. *
  326. * Calculates some globals. This routine needs to be called any
  327. * time that the size of the app or the zoom factor changes.
  328. *
  329. * History:
  330. *
  331. ************************************************************************/
  332. VOID
  333. CalcZoomedSize(
  334. VOID
  335. )
  336. {
  337. RECT rc;
  338. GetClientRect(ghwndApp, &rc);
  339. gcxZoomed = (rc.right / gnZoom) + 1;
  340. gcyZoomed = (rc.bottom / gnZoom) + 1;
  341. }
  342. /************************************************************************
  343. * DoTheZoomIn
  344. *
  345. * Does the actual paint of the zoomed image.
  346. *
  347. * Arguments:
  348. * HDC hdc - If not NULL, this hdc will be used to paint with.
  349. * If NULL, a dc for the apps window will be obtained.
  350. *
  351. * History:
  352. *
  353. ************************************************************************/
  354. VOID
  355. DoTheZoomIn(
  356. HDC hdc
  357. )
  358. {
  359. BOOL fRelease;
  360. HPALETTE hpalOld = NULL;
  361. HDC hdcScreen;
  362. INT x;
  363. INT y;
  364. if (!hdc) {
  365. hdc = GetDC(ghwndApp);
  366. fRelease = TRUE;
  367. }
  368. else {
  369. fRelease = FALSE;
  370. }
  371. if (ghpalPhysical) {
  372. hpalOld = SelectPalette(hdc, ghpalPhysical, FALSE);
  373. RealizePalette(hdc);
  374. }
  375. /*
  376. * The point must not include areas outside the screen dimensions.
  377. */
  378. x = BOUND(gptZoom.x, gcxZoomed / 2, gcxScreenMax - (gcxZoomed / 2));
  379. y = BOUND(gptZoom.y, gcyZoomed / 2, gcyScreenMax - (gcyZoomed / 2));
  380. hdcScreen = GetDC(NULL);
  381. SetStretchBltMode(hdc, COLORONCOLOR);
  382. StretchBlt(hdc, 0, 0, gnZoom * gcxZoomed, gnZoom * gcyZoomed,
  383. hdcScreen, x - gcxZoomed / 2,
  384. y - gcyZoomed / 2, gcxZoomed, gcyZoomed, SRCCOPY);
  385. if (gShowGrid && gnZoom > 1) // don't bother if we're 1 to 1
  386. {
  387. int i = 0, j = 0;
  388. // use gray for now. later we could get fancy about the colors
  389. // so that the line is visible when the pixels are gray
  390. HGDIOBJ hBrush = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_GRAYTEXT));
  391. HGDIOBJ hOld = SelectObject(hdc, hBrush);
  392. // first draw the vertical lines...
  393. while (i < gcxZoomed*gnZoom)
  394. {
  395. MoveToEx(hdc, i, 0, NULL);
  396. LineTo(hdc, i, gcyZoomed*gnZoom);
  397. i += gnZoom;
  398. }
  399. // ... then draw the horizontal lines
  400. while (j < gcyZoomed*gnZoom)
  401. {
  402. MoveToEx(hdc, 0, j, NULL);
  403. LineTo(hdc, gcxZoomed*gnZoom, j);
  404. j += gnZoom;
  405. }
  406. DeleteObject(SelectObject(hdc, hOld));
  407. }
  408. ReleaseDC(NULL, hdcScreen);
  409. if (hpalOld)
  410. SelectPalette(hdc, hpalOld, FALSE);
  411. if (fRelease)
  412. ReleaseDC(ghwndApp, hdc);
  413. }
  414. /************************************************************************
  415. * MoveView
  416. *
  417. * This function moves the current view around.
  418. *
  419. * Arguments:
  420. * INT nDirectionCode - Direction to move. Must be VK_UP, VK_DOWN,
  421. * VK_LEFT or VK_RIGHT.
  422. * BOOL fFast - TRUE if the move should jump a larger increment.
  423. * If FALSE, the move is just one pixel.
  424. * BOOL fPeg - If TRUE, the view will be pegged to the screen
  425. * boundary in the specified direction. This overides
  426. * the fFast parameter.
  427. *
  428. * History:
  429. *
  430. ************************************************************************/
  431. VOID
  432. MoveView(
  433. INT nDirectionCode,
  434. BOOL fFast,
  435. BOOL fPeg
  436. )
  437. {
  438. INT delta;
  439. if (fFast)
  440. delta = FASTDELTA;
  441. else
  442. delta = 1;
  443. switch (nDirectionCode) {
  444. case VK_UP:
  445. if (fPeg)
  446. gptZoom.y = gcyZoomed / 2;
  447. else
  448. gptZoom.y -= delta;
  449. gptZoom.y = BOUND(gptZoom.y, 0, gcyScreenMax);
  450. break;
  451. case VK_DOWN:
  452. if (fPeg)
  453. gptZoom.y = gcyScreenMax - (gcyZoomed / 2);
  454. else
  455. gptZoom.y += delta;
  456. gptZoom.y = BOUND(gptZoom.y, 0, gcyScreenMax);
  457. break;
  458. case VK_LEFT:
  459. if (fPeg)
  460. gptZoom.x = gcxZoomed / 2;
  461. else
  462. gptZoom.x -= delta;
  463. gptZoom.x = BOUND(gptZoom.x, 0, gcxScreenMax);
  464. break;
  465. case VK_RIGHT:
  466. if (fPeg)
  467. gptZoom.x = gcxScreenMax - (gcxZoomed / 2);
  468. else
  469. gptZoom.x += delta;
  470. gptZoom.x = BOUND(gptZoom.x, 0, gcxScreenMax);
  471. break;
  472. }
  473. DoTheZoomIn(NULL);
  474. }
  475. /************************************************************************
  476. * DrawZoomRect
  477. *
  478. * This function draws the tracking rectangle. The size and shape of
  479. * the rectangle will be proportional to the size and shape of the
  480. * app's client, and will be affected by the zoom factor as well.
  481. *
  482. * History:
  483. *
  484. ************************************************************************/
  485. VOID
  486. DrawZoomRect(
  487. VOID
  488. )
  489. {
  490. HDC hdc;
  491. RECT rc;
  492. INT x;
  493. INT y;
  494. x = BOUND(gptZoom.x, gcxZoomed / 2, gcxScreenMax - (gcxZoomed / 2));
  495. y = BOUND(gptZoom.y, gcyZoomed / 2, gcyScreenMax - (gcyZoomed / 2));
  496. rc.left = x - gcxZoomed / 2;
  497. rc.top = y - gcyZoomed / 2;
  498. rc.right = rc.left + gcxZoomed;
  499. rc.bottom = rc.top + gcyZoomed;
  500. InflateRect(&rc, 1, 1);
  501. hdc = GetDC(NULL);
  502. PatBlt(hdc, rc.left, rc.top, rc.right-rc.left, 1, DSTINVERT);
  503. PatBlt(hdc, rc.left, rc.bottom, 1, -(rc.bottom-rc.top), DSTINVERT);
  504. PatBlt(hdc, rc.right-1, rc.top, 1, rc.bottom-rc.top, DSTINVERT);
  505. PatBlt(hdc, rc.right, rc.bottom-1, -(rc.right-rc.left), 1, DSTINVERT);
  506. ReleaseDC(NULL, hdc);
  507. }
  508. /************************************************************************
  509. * EnableRefresh
  510. *
  511. * This function turns on or off the auto-refresh feature.
  512. *
  513. * Arguments:
  514. * BOOL fEnable - TRUE to turn the refresh feature on, FALSE to
  515. * turn it off.
  516. *
  517. * History:
  518. *
  519. ************************************************************************/
  520. VOID
  521. EnableRefresh(
  522. BOOL fEnable
  523. )
  524. {
  525. if (fEnable) {
  526. /*
  527. * Already enabled. Do nothing.
  528. */
  529. if (gfRefEnable)
  530. return;
  531. if (SetTimer(ghwndApp, IDTIMER_ZOOMIN, gnRefInterval * 100, NULL))
  532. gfRefEnable = TRUE;
  533. }
  534. else {
  535. /*
  536. * Not enabled yet. Do nothing.
  537. */
  538. if (!gfRefEnable)
  539. return;
  540. KillTimer(ghwndApp, IDTIMER_ZOOMIN);
  541. gfRefEnable = FALSE;
  542. }
  543. }
  544. /************************************************************************
  545. * CopyToClipboard
  546. *
  547. * This function copies the client area image of the app into the
  548. * clipboard.
  549. *
  550. * History:
  551. *
  552. ************************************************************************/
  553. VOID
  554. CopyToClipboard(
  555. VOID
  556. )
  557. {
  558. HDC hdcSrc;
  559. HDC hdcDst;
  560. RECT rc;
  561. HBITMAP hbm;
  562. if (OpenClipboard(ghwndApp)) {
  563. EmptyClipboard();
  564. if (hdcSrc = GetDC(ghwndApp)) {
  565. GetClientRect(ghwndApp, &rc);
  566. if (hbm = CreateCompatibleBitmap(hdcSrc,
  567. rc.right - rc.left, rc.bottom - rc.top)) {
  568. if (hdcDst = CreateCompatibleDC(hdcSrc)) {
  569. /*
  570. * Calculate the dimensions of the bitmap and
  571. * convert them to tenths of a millimeter for
  572. * setting the size with the SetBitmapDimensionEx
  573. * call. This allows programs like WinWord to
  574. * retrieve the bitmap and know what size to
  575. * display it as.
  576. */
  577. SetBitmapDimensionEx(hbm,
  578. (DWORD)(((DWORD)(rc.right - rc.left)
  579. * MM10PERINCH) /
  580. (DWORD)GetDeviceCaps(hdcSrc, LOGPIXELSX)),
  581. (DWORD)(((DWORD)(rc.bottom - rc.top)
  582. * MM10PERINCH) /
  583. (DWORD)GetDeviceCaps(hdcSrc, LOGPIXELSY)), NULL);
  584. SelectObject(hdcDst, hbm);
  585. BitBlt(hdcDst, 0, 0,
  586. rc.right - rc.left, rc.bottom - rc.top,
  587. hdcSrc, rc.left, rc.top, SRCCOPY);
  588. DeleteDC(hdcDst);
  589. SetClipboardData(CF_BITMAP, hbm);
  590. }
  591. else {
  592. DeleteObject(hbm);
  593. }
  594. }
  595. ReleaseDC(ghwndApp, hdcSrc);
  596. }
  597. CloseClipboard();
  598. }
  599. else {
  600. MessageBeep(0);
  601. }
  602. }
  603. /************************************************************************
  604. * AboutDlgProc
  605. *
  606. * This is the About Box dialog procedure.
  607. *
  608. * History:
  609. *
  610. ************************************************************************/
  611. INT_PTR
  612. APIENTRY
  613. AboutDlgProc(
  614. HWND hwnd,
  615. UINT msg,
  616. WPARAM wParam,
  617. LPARAM lParam
  618. )
  619. {
  620. switch (msg) {
  621. case WM_INITDIALOG:
  622. return TRUE;
  623. case WM_COMMAND:
  624. EndDialog(hwnd, IDOK);
  625. return TRUE;
  626. default:
  627. return FALSE;
  628. }
  629. }
  630. /************************************************************************
  631. * RefreshRateDlgProc
  632. *
  633. * This is the Refresh Rate dialog procedure.
  634. *
  635. * History:
  636. *
  637. ************************************************************************/
  638. INT_PTR
  639. APIENTRY
  640. RefreshRateDlgProc(
  641. HWND hwnd,
  642. UINT msg,
  643. WPARAM wParam,
  644. LPARAM lParam
  645. )
  646. {
  647. BOOL fTranslated;
  648. switch (msg) {
  649. case WM_INITDIALOG:
  650. SendDlgItemMessage(hwnd, DID_REFRESHRATEINTERVAL, EM_LIMITTEXT,
  651. 3, 0L);
  652. SetDlgItemInt(hwnd, DID_REFRESHRATEINTERVAL, gnRefInterval, FALSE);
  653. CheckDlgButton(hwnd, DID_REFRESHRATEENABLE, gfRefEnable ? 1 : 0);
  654. return TRUE;
  655. case WM_COMMAND:
  656. switch (LOWORD(wParam)) {
  657. case IDOK:
  658. gnRefInterval = GetDlgItemInt(hwnd, DID_REFRESHRATEINTERVAL,
  659. &fTranslated, FALSE);
  660. /*
  661. * Stop any existing timers then start one with the
  662. * new interval if requested to.
  663. */
  664. EnableRefresh(FALSE);
  665. EnableRefresh(
  666. IsDlgButtonChecked(hwnd, DID_REFRESHRATEENABLE));
  667. EndDialog(hwnd, IDOK);
  668. break;
  669. case IDCANCEL:
  670. EndDialog(hwnd, IDCANCEL);
  671. break;
  672. }
  673. break;
  674. }
  675. return FALSE;
  676. }