Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text position in a text box control...

Status
Not open for further replies.

Foada

Programmer
Feb 4, 2002
1,110
US
I have looked all over for this and have had no luck. I am writing a user control that mimics the textbox control. For several reasons I can not just place an intrinsic textbox on my user control. I have been able to duplicate everything that the textbox control does with the exception of the text placement from the top of the textbox. There are API's that will postion the text in every other aspect but not the distance from the top. I have figured that it has something to do with the font size but I can not determine an exact calculation that works. Does anyone have any insite, links, articles, or even guesses that could help with this? Thanks in advance.

P.S. I know that this question is more suited for the API or usercontrol form, but I did not want to make more than one post. [neutral] If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
If you can reference the user control via a device context, then you might try using the SetTextAlign API in conjunction with the TextOut API?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks Cajun, but I am not sure I follow you. I can set the text position no problem. The problem is making sure that the text position from the top of my control matches the text position from the top in a standard text box so that they look the same. For example lets say a standard text box with a MS Sans Serif Size 10 font, the text is positioned 4 pixels from the top of the text box but a MS Sans Serif Size 18 font is positioned 6 pixels from the top of the text box. I am assuming that there is some sort of calculation that is used from the fonts Height, Ascent, Baseline, Desent, Internal and External leading attributes. Does that make sense or did I miss something from your post? If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
No wonder you're having difficulty following me, I totally misunderstood the problem. Sorry.

I don't know what the formula are, but will do some digging. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top