Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Text Editing in an EDITTEXT box in C++ while keeping scrolling enabled

Tags:

c++

winapi

So my dilemma comes from making a UI in C++ with the windows API. I need to have an EDITTEXT box which allows for scrolling but doesn't allow the user to edit the text that gets displayed in the box. So far, it looks like this.

EDITTEXT        ID_STATUS,7,237,439,50, WS_VSCROLL | ES_MULTILINE 

This allows for the text to be scrolled if it's long and breaks it into new lines. However, if i add the DISABLED option to this, it disables both the scrollbar and the text. What would be the best way to solve this situation? I've also tried adding

SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, 0, 0);

before the UI gets previewed to see if this would disable text editing but it doesn't. Any help would be appreciated.

like image 635
Spartan 117 Avatar asked Mar 03 '23 22:03

Spartan 117


1 Answers

EM_SETREADONLY is correct but you failed to actually ask it to be read-only. Try

SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, TRUE, 0);

wParam

Specifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY style; a value of FALSE removes the ES_READONLY style.

You can also specify the ES_READONLY style when you create the control.

like image 198
Anders Avatar answered Apr 07 '23 03:04

Anders