changeset 2229:abbda3db3a3c

Win: Fix dw_mle_set_word_wrap() on Windows when -DRICHEDIT is enabled for MLEs. Add a Word Wrap checkbox to dwtest for testing changing word wrap on the fly. Rich Edit is not fully tested so this will probably land as default in 3.2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 03 Jan 2021 03:49:20 +0000
parents 2407c8b46143
children 7575eefcf881
files dwtest.c win/dw.c
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Mon Dec 28 19:52:27 2020 +0000
+++ b/dwtest.c	Sun Jan 03 03:49:20 2021 +0000
@@ -1194,6 +1194,13 @@
     dw_free(title);
 }
 
+int DWSIGNAL word_wrap_click_cb(HWND wordwrap, void *data)
+{
+    HWND container_mle = (HWND)data;
+
+    dw_mle_set_word_wrap(container_mle, dw_checkbox_get(wordwrap));
+}
+
 void container_add(void)
 {
     char *titles[4];
@@ -1207,11 +1214,17 @@
     CDATE date;
     unsigned long size, newpoint;
     HICN thisicon;
+    HWND checkbox;
 
     /* create a box to pack into the notebook page */
     containerbox = dw_box_new(DW_HORZ, 2);
     dw_box_pack_start( notebookbox4, containerbox, 500, 200, TRUE, TRUE, 0);
 
+    /* Add a word wrap checkbox */
+    checkbox = dw_checkbox_new("Word wrap", 0);
+    dw_box_pack_start( notebookbox4, checkbox, 100, -1, TRUE, FALSE, 1);
+    dw_checkbox_set(checkbox, TRUE);
+
     /* now a container area under this box */
     container = dw_container_new(100, TRUE);
     dw_box_pack_start( notebookbox4, container, 500, 200, TRUE, FALSE, 1);
@@ -1293,6 +1306,7 @@
     dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), DW_POINTER(container_status));
     dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), DW_POINTER(container_status));
     dw_signal_connect(container, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(column_click_cb), DW_POINTER(container_status));
+    dw_signal_connect(checkbox, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(word_wrap_click_cb), DW_POINTER(container_mle));
 }
 
 /* Beep every second */
--- a/win/dw.c	Mon Dec 28 19:52:27 2020 +0000
+++ b/win/dw.c	Sun Jan 03 03:49:20 2021 +0000
@@ -9294,12 +9294,7 @@
       dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL);
    /* If it is a rich edit control use the rich edit message */
    if(hrichedit || hmsftedit)
-   {
-      if(state)
-         SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_AND, (LPARAM)~ECO_AUTOHSCROLL);
-      else
-         SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_OR, (LPARAM)ECO_AUTOHSCROLL);
-   }
+      SendMessage(handle, EM_SETTARGETDEVICE, 0, state ? 0 : 1);
 }
 
 /*