home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / mswindo / programm / misc / 1423 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  2.3 KB

  1. Path: sparky!uunet!kithrup!hoptoad!decwrl!sdd.hp.com!uakari.primate.wisc.edu!ames!bionet!raven.alaska.edu!news.u.washington.edu!milton!bytor
  2. From: bytor@milton.u.washington.edu (Jill Patterson)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: BC++ OWL TEdit Questions
  5. Message-ID: <bytor.714343854@milton>
  6. Date: 20 Aug 92 20:50:54 GMT
  7. Sender: news@u.washington.edu (USENET News System)
  8. Organization: University of Washington
  9. Lines: 69
  10.  
  11. Hi,
  12.   I am trying to derive a class from TEdit Called TXEdit, I
  13. am trying to draw a custom frame around the Edit Box.  A problem
  14. I am encountering is when the window containing the TXEdit Is moved
  15. the Text inside the Edit Box Is no longer visible.  Here Is the code
  16. for My WM_NCPAINT handler, where I Paint The Frame:
  17.  
  18. /*
  19. ** TXEdit::WMNCPaint()
  20. */
  21. void TXEdit::WMNCPaint(RTMessage Msg)
  22. {
  23.   HBRUSH      hBrFrame;
  24.   HPEN        hDkGrayPen;
  25.   HPEN        hOldPen;
  26.   PAINTSTRUCT ps;
  27.   RECT        rc;
  28.  
  29.   /* Setup */
  30.   BeginPaint(HWindow, &ps);
  31.   GetClientRect(HWindow, &rc);
  32.   InflateRect(&rc, 1, 1);
  33.  
  34.   hBrFrame   = CreateSolidBrush(RGB(0, 0, 0));
  35.   hDkGrayPen = CreatePen(PS_SOLID, 1, RGB(72, 72, 72));
  36.  
  37.   /* Draw Lower Right Corner */
  38.   if(fBorderState)
  39.     hOldPen    = (HPEN)SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
  40.   else
  41.     hOldPen    = (HPEN)SelectObject(ps.hdc, hDkGrayPen);
  42.  
  43.   MoveTo(ps.hdc, rc.right - 1, rc.top);
  44.   LineTo(ps.hdc, rc.right - 1, rc.bottom - 1);
  45.   LineTo(ps.hdc, rc.left,      rc.bottom - 1);
  46.  
  47.  
  48.   /* Draw Upper Left Corner */
  49.   if(fBorderState)
  50.     SelectObject(ps.hdc, hDkGrayPen);
  51.   else
  52.     SelectObject(ps.hdc, GetStockObject(WHITE_PEN));
  53.  
  54.   MoveTo(ps.hdc, rc.left,  rc.bottom - 1);
  55.   LineTo(ps.hdc, rc.left,  rc.top);
  56.   LineTo(ps.hdc, rc.right, rc.top);
  57.  
  58.   InflateRect(&rc, -1, -1);
  59.   FrameRect(ps.hdc, &rc, hBrFrame);
  60.  
  61.   /* Cleanup */
  62.   SelectObject(ps.hdc, hOldPen);
  63.   DeleteObject(hDkGrayPen);
  64.   DeleteObject(hBrFrame);
  65.   EndPaint(HWindow, &ps);
  66.  
  67. }
  68.  
  69.  Also I am drawing the frame outside of the actual window, because
  70. I call InflateRect with neg parms.  Will this be a problem?
  71.  
  72. I was thinking of maybe putting another InflateRect(&rc, -1, -1) at
  73. the end after the EndPaint, and then calling InvalidateRegion(ps.hdc,
  74. &rc, TRUE).  Would this be the best way to accomplish this?
  75.  
  76. THX
  77.   bytor@milton.u.washington.eud
  78.  
  79. oops thats edu
  80.