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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

caret movement(depending on char width)

Status
Not open for further replies.

Raywall

Programmer
Oct 1, 2003
51
RO
what should be the new position of the caret after moving one position(left or right)?
tm.tmAveCharWidth(textmetric structure) is no good beacuse chars width depend on their value,so...?
 
In MFC we use the member functions from the direct context, specificly CClientDC.GetTextExtent(CString, int number of characters from the left)

-Bones
 
Sorry but I don't use MFC.
I must use api,that's it.
I tried :
newcaretpos=oldcaretpos+tm.AveCharWidth+1
when an ascii char was pressed.
It works for 'a' for ex but for 's' and some other chars the new position is much to far from the old one and I don't now why.
 
Well, MFC is a wrapper for API so there possibly may be some API function for GetTextExtent(). Try MSDN. Of course it is a direct context member function so I'm not sure, never used API :( . Hopefully someone else will see this post, its a fairly simple question. You could also try the VC++ forum.

-Bones
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top