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