zoomrect.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 2k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. // ZoomRect.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "magnify.h"
  5. #include "ZoomRect.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CZoomRect
  13. CZoomRect::CZoomRect()
  14. {
  15. LPCTSTR lpszClass = AfxRegisterWndClass(CS_SAVEBITS);
  16. CreateEx(WS_EX_TOPMOST, lpszClass, __TEXT("ZoomRect"), WS_POPUP /* | WS_VISIBLE*/, 0, 0, 10, 10, NULL, NULL);
  17. m_nBorderWidth = 5;
  18. }
  19. CZoomRect::~CZoomRect()
  20. {
  21. }
  22. BEGIN_MESSAGE_MAP(CZoomRect, CWnd)
  23. //{{AFX_MSG_MAP(CZoomRect)
  24. ON_WM_PAINT()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CZoomRect message handlers
  29. void CZoomRect::OnPaint() 
  30. {
  31. CPaintDC dc(this); // device context for painting
  32. CRect rcClient;
  33. GetClientRect(&rcClient);
  34. CBrush brush(RGB(255, 255, 128));
  35. dc.FillRect(&rcClient, &brush);
  36. }
  37. HRGN CreateRectRgn(LPCRECT lpRect)
  38. {
  39. return CreateRectRgn(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
  40. }
  41. void CZoomRect::SetLocation(int nLeft, int nTop, int nRight, int nBottom)
  42. {
  43. CRect rcInner(nLeft, nTop, nRight, nBottom);
  44. CRect rcOutter;
  45. rcOutter = rcInner;
  46. rcOutter.InflateRect(m_nBorderWidth, m_nBorderWidth);
  47. SetWindowPos(NULL, rcOutter.left, rcOutter.top, rcOutter.Width(), rcOutter.Height(), SWP_NOZORDER);
  48. ScreenToClient(&rcOutter);
  49. ScreenToClient(&rcInner);
  50. if(rcOutter != m_rcOutter)
  51. {
  52. m_rcOutter = rcOutter;
  53. HRGN hrgn1 = CreateRectRgn(&rcOutter);
  54. HRGN hrgn2 = CreateRectRgn(&rcInner);
  55. CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR);
  56. DeleteObject(hrgn2);
  57. SetWindowRgn(hrgn1, TRUE);
  58. }
  59. UpdateWindow();
  60. }