home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 06 / pen.h < prev    next >
C/C++ Source or Header  |  1991-06-15  |  496b  |  29 lines

  1. class HPENCLASS
  2. {
  3.   HPEN hPen;
  4.   HPEN hOldPen;
  5.   HDC hDC;
  6.  
  7.   public:
  8.   HPENCLASS(HDC hDCPrm, int nPenStyle, int nWidth, COLORREF crColor)
  9.   {
  10.     hDC = hDCPrm;
  11.     hPen = NULL;
  12.     hOldPen = NULL;
  13.  
  14.     if (hDC)
  15.     {
  16.       hPen = CreatePen (nPenStyle, nWidth, crColor);
  17.       if (hPen)
  18.         hOldPen = SelectObject (hDC, hPen);
  19.     }
  20.   };
  21.   ~HPENCLASS()
  22.   {
  23.     if (hDC && hOldPen)
  24.       SelectObject (hDC, hOldPen);
  25.     if (hPen)
  26.       DeleteObject (hPen);
  27.   };
  28. };
  29.