In principle, you could do it. You can reproduce exact same text up the the point you need and calculate text metrics.
This is where to start:
Don't do it!
This is a very, very bad idea
. You're going to spend disproportionally long time to obtain very unreliable result. When you do it, you will have to struggle will your edit control going on top of your button when focused -- what event should be showing your button on top again? you will have to catch all events of scrolling the text (you mentioned scrolling yourself) or modification of the text, because any of those will mess up your layout.
Most likely, you will get the satisfactory behavior a little later than never