Alessandro Jacopson
Alessandro Jacopson

Reputation: 18603

Rules for selecting a word in a Windows RichEdit20W control

In a MFC application I have an .rc file with this content:

IDD_PROP_TEXT DIALOGEX 0, 0, 210, 164
STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif", 400, 0, 0x0
BEGIN
    CONTROL         "",IDC_EDIT,"RichEdit20W",ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_TABSTOP,1,3,207,158
END

When I double click on a string like first_second in the Rich Edit control I get selected just the first part before the _ or the second part after the _ or just the _, depending on where I double click.

In the following screenshot I just double clicked on a character in second.

enter image description here

I would like to change this behavior and _ should not be treated as a breaking character.

How can I do that?

I have found ECO_AUTOWORDSELECTION at CRichEditCtrl::SetOptions but it does not explain the word breaking rules...

Upvotes: 3

Views: 273

Answers (1)

xMRi
xMRi

Reputation: 15355

You should use EM_SETWORDBREAKPROCEX.

With your own EditWordBreakProcEx it should be possible to define your own rules.

The flag ECO_AUTOWORDSELECTION just sets the feature that a double click selects a word.

I am not sure that this applies to this case too, but reading this seam to point to my supposed answer.

Upvotes: 2

Related Questions