2

DrawText automatically breaks line when inputting text.

In single line I can use GetOutputTextExtent to locate a single letter. But with automatic line break I can't get the exact text of a single line. So I can't locate a letter (to be exact where the cursor is).

I have no experience in text editor in MFC-related programming.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
mathddsccc
  • 41
  • 2
  • Please specify better tags for your question. I've added the [tag:mfc] tag, but as the [mfc tag info](https://stackoverflow.com/tags/mfc/info) says, "*You should specify a tag for the version of C++ or Visual Studio being used. Due to the size of MFC, additional tags such as [com], [wininet], [winapi] or other subject matter tags are helpful.*" – Gino Mempin Dec 10 '22 at 10:49
  • 1
    You can call `DrawText()` with the `DT_CALCRECT` flag to determine the area needed for a (normal) draw (without the flag) - check the [documentation](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawtext). But this has nothing to do with the "cursor". If you want to perform user input you should use edit-boxes, which offer higher-level functions and messages, eg you don't need to draw the text yourself, neither determine where the "cursor" (the caret) is, you have selections and functions to select, unselect, get/set caret position, get/set the control's text etc. – Constantine Georgiou Dec 12 '22 at 09:43

0 Answers0