Thai editions of Windows come with a fairly sophisticated line-breaking algorithm. If you are writing a Thai-language application, take advantage of what the system provides rather than trying to come up with your own line-breaking code. To give you an idea of what would be involved, try to decipher the following line:
Imaginethatthisisastringtobewordwrappedtheonlywaytodosoinenglishwouldbetoidentifytheindividualwordsandthendeterminethebestplacetobreaktheline
Translation: Imagine that this is a string to be word-wrapped. The only way to do so in English would be to identify the individual words and then determine the best place to break the line.
The line-breaking algorithm provided by the system solves these problems for you.