PDA

View Full Version : Success with TX_SETWORDDIVISION


Unregistered
October 28, 2002, 22:46:52
Hi folks,

With the help of Meik Dankleff in Tech Support I have finally been able to get the TX_SETWORDDIVISION function to work with my own hypenation routine.

In the end the answer was too simple and, I must add, not a bug in TextControl. Just a bug in the sample provided by TextControl and copied into my app by me. I assumed incorrectly that the sample was correct and therefore the bug had to be in TextControl.

Basically the lpword parameter points to a buffer containing a Unicode Double Byte value. Therefore using the lpwordlength parameter only returns half of the word. The simple answer was to double the lpwordlength parameter. So simple I couldn't see the solution.

Anyway here is the updated function that should be used in their Word Division sample.

Hope it helps somebody out there.

Tony Stallan

' --------------------------------------------------------------------------------
' WordDivisionFunc
'
' This is the callback function which is called by Text Control each time
' a line break is newly formatted.
' --------------------------------------------------------------------------------
Public Function WordDivisionFunc(ByVal lpWord As Long, ByVal wDividePos As Integer, _
ByVal wWordLength As Integer, ByVal lpChangedWord As Long, ByVal bRechange As Long) As Integer

If Not bRechange Then
Dim sWordToBeDivided As String
Dim sByte() As Byte
Dim sByteLength As Long

'--------------------------------
'Double the wWordLengh parameter as the lpword
'pointer points to a UNICODE Double Byte value
'--------------------------------

sByteLength = wWordLength * 2

ReDim sByte(sByteLength)

CopyMemory sByte(0), lpWord, sByteLength
sWordToBeDivided = StrConv(sByte, vbLowerCase)

'------------------------------------------------
'Enter your code for the actual hyphenation here
'returning the result in WordDivisionFunc
'eg WordDivisionFunction = iResult
'-------------------------------------------------

' Just for demonstration purposes: Display the word in the second Text Control
' and return a fixed value of 3 as a division point.
Form1.TXTextControl2.Text = sWordToBeDivided

WordDivisionFunc = 3

End If
End Function


This message was originally posted by Tony in the old TX Text Control Support Forum.

Unregistered
November 10, 2002, 13:20:21
Now we use the function 'WordDivisionFunc' ( with VB 6.0). It can help
me wrap the Thai language. How can I hide the hyphen (-) at the end of the
line.


This message was originally posted by chatchai in the old TX Text Control Support Forum.