From e833cd22af38d0042dd3e5e6ccf7914fb18cf767 Mon Sep 17 00:00:00 2001 From: Eric Mullins Date: Sat, 10 Oct 2009 11:12:10 -0600 Subject: [PATCH] Restructured URL code so it fits better with how winboard is set up. --- winboard/winboard.c | 31 ++++++++++++++----------------- 1 files changed, 14 insertions(+), 17 deletions(-) diff --git a/winboard/winboard.c b/winboard/winboard.c index bcd0c9c..6c5d0ee 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -8105,6 +8105,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static int sizeX, sizeY; int newSizeX, newSizeY; MINMAXINFO *mmi; + WORD wMask; switch (message) { case WM_NOTIFY: @@ -8113,14 +8114,13 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ENLINK *pLink = (ENLINK*)lParam; if (pLink->msg == WM_LBUTTONUP) { - TEXTRANGE tr; - - tr.chrg = pLink->chrg; - tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); - hText = GetDlgItem(hDlg, OPT_ConsoleText); - SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); - free(tr.lpstrText); + TEXTRANGE tr; + + tr.chrg = pLink->chrg; + tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); + SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); + free(tr.lpstrText); } } break; @@ -8175,6 +8175,11 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetWindowPlacement(hDlg, &wp); } + // Allow hText to highlight URLs and send notifications on them + wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); + SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); + SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); + return FALSE; case WM_SETFOCUS: @@ -8244,18 +8249,10 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) VOID ConsoleCreate() { - HWND hCons, hText; - WORD wMask; + HWND hCons; if (hwndConsole) return; hCons = CreateDialog(hInst, szConsoleName, 0, NULL); SendMessage(hCons, WM_INITDIALOG, 0, 0); - - - // make the text item in the console do URL links - hText = GetDlgItem(hCons, OPT_ConsoleText); - wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L); - SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK); - SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L); } -- 1.7.0.4