Spartan 117
Spartan 117

Reputation: 619

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

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.

Upvotes: 4

Views: 1911

Answers (1)

Anders
Anders

Reputation: 101569

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.

Upvotes: 7

Related Questions