How to compensate cursor position in edit control?

I am creating a custom edit control that consists of adding an icon on the left and an icon button on the right, like inside an edit control. This requires shifting the starting point of the text (and cursor) to the right by the X number of pixels. It also means that I need to β€œlimit” how wide the text can be to make room for the button on the right. The goal is to provide both the custom icon on the left, for example, in the browser, and the β€œX” button on the right, to clear the contents of the edit control.

How to compensate for Rect , where to draw text and cursor in TCustomEdit stream?

+4
source share
1 answer

If you are using a later version of Delphi, there should already be TButtonedEdit Control and you can do your work.

If not, I think you can send the message EM_SETMARGINS to your TCustomEdit to set the left and right fields.

 SendMessage(CustomEdit.Handle, EM_SETMARGINS, EC_LEFTMARGIN or EC_RIGHTMARGIN, MakeLong(LeftMargin, RightMargin)); 
+6
source

Source: https://habr.com/ru/post/1401090/


All Articles