home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / pen / 572 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.1 KB  |  56 lines

  1. Newsgroups: comp.sys.pen
  2. Path: sparky!uunet!microsoft!hexnut!ericbe
  3. From: ericbe@microsoft.com (Eric Berman)
  4. Subject: Re: Pen Windows BEdit questions
  5. Message-ID: <1992Sep11.164412.9675@microsoft.com>
  6. Date: 11 Sep 92 16:44:12 GMT
  7. Organization: Microsoft Corporation
  8. References: <8012@lee.SEAS.UCLA.EDU>
  9. Lines: 45
  10.  
  11. In article <8012@lee.SEAS.UCLA.EDU> alexau@boole.seas.ucla.edu (King-Long Au) writes:
  12. >I have problems in retrieving characters in BEDIT.
  13. >But I don't know how to retreive characters in the comb field.
  14. >Does anyone know how to get those characters?
  15. >
  16. >p.s. please reply to alexau@seas.ucla.edu
  17. >
  18. Hello, Alex.
  19.  
  20. A BEdit is just like an Edit box; you can use the
  21. WM_GETTEXT message to extract the characters as an array of
  22. chars.  The 5th character in your array corresponds to the
  23. character in the 5th cell.  If you are using a multi-line
  24. BEdit, then you have to do a little bit of row and column
  25. arithmetic.  For example, the character in the 2nd cell of the
  26. 4th row in a 6 column BEdit is at array element 19  (= (4 - 1)
  27. * 6 + (2 - 1); remember that the 1st row is row 0 and the 1st
  28. column is column 0, so we subtract 1 from the row # and the
  29. column #.)
  30.  
  31. How do you know how many columns there are in the BEdit?  Easy.
  32.  Use the WM_HEDITCTL message with the HE_GETRC subfunction to
  33. get the RC for the BEdit, then look in its guide structure;
  34. rc.guide.cHorzBox tells you the # of columns in the BEdit.
  35.  
  36. OK, now comes the tricky part.  You could simply use the cell #
  37. as an offset into the array of chars, but this can cause
  38. problems for two reasons.  One is internationalization
  39. (double-byte characters), and the other is that some
  40. characters, such as CRLF are really two bytes.  Sooo...we've
  41. provided you with two handy subfunctions of the  WM_HEDITCTL
  42. message: HE_CHAROFFSET and HE_CHARPOSITION (page 277 of the Pen
  43. documentation).
  44.  
  45. Suppose you want the character in the cell position 19.  Use
  46. WM_GETTEXT to get the text from the BEdit, then use
  47. HE_CHAROFFSET to get a character offset into your string.  Odds
  48. are it will return 19, but you  should do this to be sure. 
  49. HE_CHARPOSITION performs the reverse operation.
  50.  
  51. Hope this helps!
  52.  
  53. --Eric Berman
  54.  
  55.  
  56.