# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1609770564 0 # Node ID bd642d04d7c693bc680c352b62e24ef361382208 # Parent b569023edb6f694e48bbaf2320db347d766a296f Win: Turn on horizontal scrollbar when word wrap is off in rich edit MLE. Also work around rich edit EM_SCROLLCARET bug by showing the selection first. diff -r b569023edb6f -r bd642d04d7c6 win/dw.c --- a/win/dw.c Mon Jan 04 12:33:20 2021 +0000 +++ b/win/dw.c Mon Jan 04 14:29:24 2021 +0000 @@ -9367,16 +9367,12 @@ */ void API dw_mle_set_word_wrap(HWND handle, int state) { - /* If ES_AUTOHSCROLL is not set and there is no - * horizontal scrollbar it word wraps. - */ - if(state) - dw_window_set_style(handle, 0, ES_AUTOHSCROLL); - else - dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL); /* If it is a rich edit control use the rich edit message */ if(hrichedit || hmsftedit) + { + SendMessage(handle, EM_SHOWSCROLLBAR, (WPARAM)SB_HORZ, (LPARAM)(state ? FALSE : TRUE)); SendMessage(handle, EM_SETTARGETDEVICE, 0, state ? 0 : 1); + } } /* @@ -9397,7 +9393,9 @@ */ void API dw_mle_set_cursor(HWND handle, int point) { - SendMessage(handle, EM_SETSEL, 0, MAKELPARAM(point,point)); + SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point); + if(hrichedit || hmsftedit) + SendMessage(handle, EM_HIDESELECTION, 0, 0); SendMessage(handle, EM_SCROLLCARET, 0, 0); } @@ -9440,6 +9438,8 @@ if(retval) { SendMessage(handle, EM_SETSEL, (WPARAM)retval - textlen, (LPARAM)retval); + if(hrichedit || hmsftedit) + SendMessage(handle, EM_HIDESELECTION, 0, 0); SendMessage(handle, EM_SCROLLCARET, 0, 0); }