3

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...

Alessandro Jacopson
  • 18,047
  • 15
  • 98
  • 153

1 Answers1

2

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.

xMRi
  • 14,982
  • 3
  • 26
  • 59
  • thank you, I'll give it a try. It seems to me that I have to use `EM_SETWORDBREAKPROC` and `EditWordBreakProc` (instead of the `EX` version) since I have Riche Edit 2.0. – Alessandro Jacopson Jul 20 '18 at 13:06
  • I have found an interesting example here https://github.com/petterh/textedit/blob/v2.5.1003.0/EditWordBreakProc.cpp courtesy of Petter Hesselberg https://stackoverflow.com/users/3968276/petter-hesselberg?tab=profile – Alessandro Jacopson Jul 20 '18 at 14:19