changeset 1550:78a2e6a51285

Added basic rich edit control support for MLEs on Windows. This is disabled by default, I tried switching to the richedit control to work around a problem with the edit control not being able to switch word wrap modes without recreating the control. However despite rich edit messages that look like they will do just that, the rich edit controls appear to have the same problem. Committing this code though in case we want to switch to rich edit in the future for other reasons.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 13 Jan 2012 22:01:15 +0000
parents ca6be9c48fff
children cf897886ceeb
files win/dw.c
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Fri Jan 13 17:40:22 2012 +0000
+++ b/win/dw.c	Fri Jan 13 22:01:15 2012 +0000
@@ -29,6 +29,7 @@
 #ifdef AEROGLASS
 #include <uxtheme.h>
 #endif
+#include <richedit.h>
 
 #ifdef GDIPLUS
 /* GDI+ Headers are not C compatible... so define what we need here instead */
@@ -118,6 +119,9 @@
 HANDLE hdwm = 0, huxtheme = 0;
 #endif
 
+/* Needed for Rich Edit controls */
+HANDLE hrichedit = 0;
+
 /*
  * MinGW Is missing a bunch of definitions
  * so #define them here...
@@ -3879,6 +3883,11 @@
       hdwm = 0;
    }
 #endif
+#ifdef RICHEDIT
+   /* Attempt to load rich edit library */
+   if(!(hrichedit = LoadLibrary("riched20")))
+      hrichedit = LoadLibrary("riched32");
+#endif      
    return 0;
 }
 
@@ -4475,7 +4484,8 @@
       extraheight = 6;
    }
    /* Entryfields and MLE */
-   else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0)
+   else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0 ||
+           strnicmp(tmpbuf, RICHEDIT_CLASS, strlen(RICHEDIT_CLASS)+1) == 0)
    {
       LONG style = GetWindowLong(handle, GWL_STYLE);
       if((style & ES_MULTILINE))
@@ -5776,7 +5786,7 @@
 {
 
    HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
-                       EDITCLASSNAME,
+                       hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
                        "",
                        WS_VISIBLE | WS_BORDER |
                        WS_VSCROLL | ES_MULTILINE |
@@ -7904,6 +7914,14 @@
       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)
+   {
+      if(state)
+         SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_AND, (LPARAM)~ECO_AUTOHSCROLL);
+      else
+         SendMessage(handle, EM_SETOPTIONS, (WPARAM)ECOOP_OR, (LPARAM)ECO_AUTOHSCROLL);
+   }
 }
 
 /*