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.

85 lines
2.5 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: draw.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains the DrawFrameControl API
  7. *
  8. * History:
  9. * 12-12-93 FritzS Ported from Chicago
  10. \***************************************************************************/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. /***************************************************************************\
  14. * PaintRect
  15. *
  16. * History:
  17. * 11-15-90 DarrinM Ported from Win 3.0 sources.
  18. * 01-21-91 IanJa Prefix '_' denoting exported function (although not API)
  19. * 12-12-94 JerrySh Copied from server - make sure to keep in sync
  20. \***************************************************************************/
  21. BOOL PaintRect(
  22. HWND hwndBrush,
  23. HWND hwndPaint,
  24. HDC hdc,
  25. HBRUSH hbr,
  26. LPRECT lprc)
  27. {
  28. POINT ptOrg;
  29. PWND pwndBrush;
  30. PWND pwndPaint;
  31. HWND hwndDesktop;
  32. hwndDesktop = GetDesktopWindow();
  33. if (hwndBrush == NULL) {
  34. hwndBrush = hwndDesktop;
  35. }
  36. if (hwndBrush != hwndPaint) {
  37. pwndBrush = ValidateHwnd(hwndBrush);
  38. if (pwndBrush == NULL) {
  39. RIPMSG1(RIP_WARNING, "PaintRect: invalid Brush window %lX", hwndBrush);
  40. return FALSE;
  41. }
  42. pwndPaint = ValidateHwnd(hwndPaint);
  43. if (pwndPaint == NULL) {
  44. RIPMSG1(RIP_WARNING, "PaintRect: invalid Paint window %lX", hwndBrush);
  45. return FALSE;
  46. }
  47. if (hwndBrush != hwndDesktop) {
  48. SetBrushOrgEx(
  49. hdc,
  50. pwndBrush->rcClient.left - pwndPaint->rcClient.left,
  51. pwndBrush->rcClient.top - pwndPaint->rcClient.top,
  52. &ptOrg);
  53. } else {
  54. SetBrushOrgEx(hdc, 0, 0, &ptOrg);
  55. }
  56. }
  57. /*
  58. * If hbr < CTLCOLOR_MAX, it isn't really a brush but is one of our
  59. * special color values. Translate it to the appropriate WM_CTLCOLOR
  60. * message and send it off to get back a real brush. The translation
  61. * process assumes the CTLCOLOR*** and WM_CTLCOLOR*** values map directly.
  62. */
  63. if (hbr < (HBRUSH)CTLCOLOR_MAX) {
  64. hbr = GetControlColor(hwndBrush, hwndPaint, hdc,
  65. HandleToUlong(hbr) + WM_CTLCOLORMSGBOX);
  66. }
  67. FillRect(hdc, lprc, hbr);
  68. if (hwndBrush != hwndPaint) {
  69. SetBrushOrgEx(hdc, ptOrg.x, ptOrg.y, NULL);
  70. }
  71. return TRUE;
  72. }