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.

91 lines
2.1 KiB

  1. /* (C) Copyright Microsoft Corporation 1991-1994. All Rights Reserved */
  2. /* sframe.c
  3. *
  4. * Implements the shadow-frame static text control ("sb_sframe").
  5. *
  6. * This is NOT a general-purpose control (see the globals below).
  7. *
  8. * Borrowed from KeithH (with many, many modifications).
  9. */
  10. /* Revision History.
  11. 4/2/91 LaurieGr (AKA LKG) Ported to WIN32 / WIN16 common code
  12. */
  13. #include "nocrap.h"
  14. #include <windows.h>
  15. #include <mmsystem.h>
  16. #include "SoundRec.h"
  17. /* PatB(hdc, x, y, dx, dy, rgb)
  18. *
  19. * Fast solid color PatBlt() using ExtTextOut().
  20. */
  21. void
  22. PatB(HDC hdc, int x, int y, int dx, int dy, DWORD rgb)
  23. {
  24. RECT rc;
  25. SetBkColor(hdc, rgb);
  26. rc.left = x;
  27. rc.top = y;
  28. rc.right = x + dx;
  29. rc.bottom = y + dy;
  30. ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
  31. }
  32. /* DrawShadowFrame(hdc, prc)
  33. *
  34. * Draw a shadow frame inside <prc> in <hdc>.
  35. */
  36. void FAR PASCAL
  37. DrawShadowFrame(HDC hdc, LPRECT prc)
  38. {
  39. int dx, dy;
  40. dx = prc->right - prc->left;
  41. dy = prc->bottom - prc->top;
  42. PatB(hdc, prc->left, prc->top, 1, dy, RGB_DARKSHADOW);
  43. PatB(hdc, prc->left, prc->top, dx, 1, RGB_DARKSHADOW);
  44. PatB(hdc, prc->right-1, prc->top+1, 1, dy-1, RGB_LIGHTSHADOW);
  45. PatB(hdc, prc->left+1, prc->bottom-1, dx-1, 1, RGB_LIGHTSHADOW);
  46. }
  47. /* SFrameWndProc(hwnd, wMsg, wParam, lParam)
  48. *
  49. * Window procedure for "tb_sframe" window class.
  50. */
  51. INT_PTR CALLBACK
  52. SFrameWndProc(HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
  53. {
  54. PAINTSTRUCT ps;
  55. HDC hdc;
  56. RECT rc;
  57. switch (wMsg)
  58. {
  59. case WM_ERASEBKGND:
  60. return 0L;
  61. case WM_PAINT:
  62. hdc = BeginPaint(hwnd, &ps);
  63. GetClientRect(hwnd, &rc);
  64. DrawShadowFrame(hdc, &rc);
  65. InflateRect(&rc, -1, -1);
  66. // DrawShadowFrame(hdc, &rc);
  67. // InflateRect(&rc, -1, -1);
  68. // FillRect(hdc, &rc, GetStockObject(SOBJ_BGSFRAME));
  69. PatB(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, RGB_BGNFTEXT);
  70. EndPaint(hwnd, &ps);
  71. return 0L;
  72. }
  73. return DefWindowProc(hwnd, wMsg, wParam, lParam);
  74. }