I use a CEdit
text field to input a search term in an MFC application. When using it on FullHD resolution it works fine, I can input as long as big of a string as i need, but when using on 4k resolution the text is limited to 10 characters. The return of GetLimitText
is 3000, and if I SetLimitText
to a value smaller than 10 it works, limiting to more (such as 20) doesn't do anything, only 10 characters can be input still. Has anyone had this problem before or it might be from my implementation?

- 17,769
- 16
- 66
- 164

- 827
- 1
- 8
- 15
-
1Have you verified, that you cannot actually input more characters (as opposed to the input just not being visible)? You can Ctrl+A, Ctrl+C the entire text, and paste it into Notepad, for example. – IInspectable Aug 27 '20 at 07:11
-
@IInspectable yes, after i input the search term it is also printed and only shows what i inputted (limited characters) – user3808318 Aug 27 '20 at 07:22
-
2Please show a [mcve]. – IInspectable Aug 27 '20 at 07:56
-
@IInspectable i added a solution thanks – user3808318 Aug 27 '20 at 10:35
2 Answers
I "fixed" it in a way. I was calling CWnd::ModifyStyleEx(0, WS_EX_CLIENTEDGE)
. I replaced with CWnd::ModifyStyle(0, WS_BORDER)
. This is not a true fix as it changes the way it looks a bit, but I guess this is a bug.

- 17,769
- 16
- 66
- 164

- 827
- 1
- 8
- 15
-
2This could well be a bug in your code. We don't know, since we cannot see your code. – IInspectable Aug 27 '20 at 12:37
I ran into a similar problem when creating the equivalent of resources for a CDialogBar on-the-fly (instead of using the resource editor). One of the controls was a CEdit control, and as user3808318 pointed out, MFC or Windows mysteriously ignores any value you assign using SetLimitText, and seems to ignore any characters you type that would extend beyond the edit control on the screen.
This is the original way that I created the edit control that resulted in this problem.
Create (WS_CHILD | WS_VISIBLE | WS_BORDER, rectDummy, this, IDC_FIND_TEXT)
Here is the correct way, now including the ES_AUTOHSCROLL option.
Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL, rectDummy, this, IDC_FIND_TEXT)

- 1
- 1
-
I tried adding ES_AUTOHSCROLL as well, it didn't fix my issue unfortunately. Also i found out the problem only occured using 4k Resolution or 150% scaling on 1080. – user3808318 Sep 13 '20 at 19:39