How to measure a Char width in a text
-
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
-
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
Let me google that for you![^] and remember that google or any search engine is your friend.
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
What does it have to do with finding the character width? Can't you just call GetCursorPos()[^]?
It is a crappy thing, but it's life -^ Carlo Pallini
-
What does it have to do with finding the character width? Can't you just call GetCursorPos()[^]?
It is a crappy thing, but it's life -^ Carlo Pallini
-
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
CDC::GetTextExtent
[^]. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
CDC::GetTextExtent
[^]. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
no because i need to find th x and y where the mouse clicked in order to mark the text to copy it.
susanne1 wrote:
i need to find th x and y where the mouse clicked in order to mark the text to copy it.
Ugh... You need to find x and y? Ya know? That's *exactly* what
GetCursorPos()
does. :rolleyes:It is a crappy thing, but it's life -^ Carlo Pallini
-
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
What are you trying to achieve exactly ? On what the user is supposed to click and what do you want to do in response ?
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
i need to measure a char width in a text , to detrmine where the user clicked. void CTest_View::OnLButtonDown(UINT nFlags, CPoint point) { CString strInput; strInput = "Text 1234"; int nX = point.x; // but this is the position in pixel. } please help. Thanks
To get the character width you can use below sequence. Firstly use GetCursorPos() to get the cursor point and use HWND WindowFromPoint( POINT Point ) To get the handle and from that handle use the below API in which the LPTEXTMETRIC haves the character width. BOOL GetTextMetrics( HDC hdc, // handle to DC LPTEXTMETRIC lptm // text metrics ); i cannot understand whats your need to do such a step, well hope you are looking for the above :)
modified on Monday, July 13, 2009 4:46 AM
-
This method gives me the width of the whole text, wht i exactly need, is the width in pixel for each charchter in the text.
Actually this method gives the width of the passed string, if you pass a single-character string then you get the width of such character. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]