Make WB Chat Boxes wrap and handle URLs
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 12 Feb 2010 21:35:11 +0000 (22:35 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 19 Feb 2010 21:36:48 +0000 (22:36 +0100)
Cloned the code for the console text field to hande URL. (Initialization
to recogize the link, and notifiction to open it when clicked.)
Removed the ES_AUTOHSCROLL style from the RichEdit in the resource.

winboard/wchat.c
winboard/winboard.rc

index b02e00e..e1f43cf 100644 (file)
@@ -139,6 +139,8 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
     char buf[MSG_SIZ], mess[MSG_SIZ];\r
     int partner = -1, i;\r
     static BOOL filterHasFocus[MAX_CHAT];\r
+    WORD wMask;\r
+    HWND hMemo;\r
 \r
     for(i=0; i<MAX_CHAT; i++) if(hDlg == chatHandle[i]) { partner = i; break; }\r
 \r
@@ -158,8 +160,29 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
            filterHasFocus[partner] = FALSE;\r
            SetFocus( GetDlgItem(hDlg, OPT_ChatInput) );\r
        }\r
+       hMemo = GetDlgItem(hDlg, IDC_ChatMemo);\r
+       wMask = (WORD) SendMessage(hMemo, EM_GETEVENTMASK, 0, 0L);\r
+       SendMessage(hMemo, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
+       SendMessage(hMemo, EM_AUTOURLDETECT, TRUE, 0L);\r
         return FALSE;\r
 \r
+    case WM_NOTIFY:\r
+      if (((NMHDR*)lParam)->code == EN_LINK)\r
+      {\r
+       ENLINK *pLink = (ENLINK*)lParam;\r
+       if (pLink->msg == WM_LBUTTONUP)\r
+       {\r
+         TEXTRANGE tr;\r
+\r
+         tr.chrg = pLink->chrg;\r
+         tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin);\r
+         SendMessage( GetDlgItem(hDlg, IDC_ChatMemo), EM_GETTEXTRANGE, 0, (LPARAM)&tr);\r
+         ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW);\r
+         free(tr.lpstrText);\r
+       }\r
+      }\r
+    break;\r
+\r
     case WM_COMMAND:\r
       /* \r
         [AS]\r
index f0126ea..15d94dc 100644 (file)
@@ -835,7 +835,7 @@ BEGIN
     PUSHBUTTON      "Clear",IDC_Clear,198,3,25,13\r
     DEFPUSHBUTTON   "Send",IDC_Send,228,3,25,13\r
     CONTROL         "",IDC_ChatMemo,"RICHEDIT",ES_MULTILINE | ES_READONLY |\r
-                    ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | \r
+                    ES_AUTOVSCROLL | WS_BORDER | WS_VSCROLL | \r
                     WS_HSCROLL | WS_TABSTOP,3,17,250,70\r
     CONTROL         "",OPT_ChatInput,"RICHEDIT",ES_AUTOHSCROLL | ES_NOHIDESEL | \r
                     WS_BORDER | WS_TABSTOP,3,90,250,13\r