Restructured URL code so it fits better with how winboard is set up.
[xboard.git] / winboard / winboard.c
index c7aebcf..6c5d0ee 100644 (file)
@@ -4703,7 +4703,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)
        GetDIBits(tmphdc,bufferBitmap,0,b.bmHeight,pData,(BITMAPINFO*)&bih,DIB_RGB_COLORS);\r
 //     fprintf(diagFile, "%8x\n", (int) pData);\r
 \r
-#if 1\r
        wb = b.bmWidthBytes;\r
        // count colors\r
        for(i=0; i<wb*(b.bmHeight - boardRect.top + OUTER_MARGIN)>>2; i++) {\r
@@ -4751,7 +4750,6 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)
        // write bitmap data\r
        for(i=0; i<wb*(b.bmHeight - boardRect.top + OUTER_MARGIN); i++) \r
                fputc(pData[i], diagFile);\r
-#endif\r
      }\r
   }\r
 \r
@@ -8107,6 +8105,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   static int sizeX, sizeY;\r
   int newSizeX, newSizeY;\r
   MINMAXINFO *mmi;\r
+  WORD wMask;\r
 \r
   switch (message) {\r
   case WM_NOTIFY:\r
@@ -8115,14 +8114,13 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       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
-          hText = GetDlgItem(hDlg, OPT_ConsoleText);\r
-          SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr);\r
-          ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW);\r
-          free(tr.lpstrText);\r
+        TEXTRANGE tr;\r
+\r
+        tr.chrg = pLink->chrg;\r
+        tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin);\r
+        SendMessage(hText, EM_GETTEXTRANGE, 0, (LPARAM)&tr);\r
+        ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW);\r
+        free(tr.lpstrText);\r
       }\r
     }\r
     break;\r
@@ -8157,7 +8155,7 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height;\r
       SetWindowPlacement(hDlg, &wp);\r
     }\r
-#if 1\r
+\r
    // [HGM] Chessknight's change 2004-07-13\r
    else { /* Determine Defaults */\r
        WINDOWPLACEMENT wp;\r
@@ -8176,7 +8174,12 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height;\r
        SetWindowPlacement(hDlg, &wp);\r
     }\r
-#endif\r
+\r
+   // Allow hText to highlight URLs and send notifications on them\r
+   wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L);\r
+   SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
+   SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L);\r
+\r
     return FALSE;\r
 \r
   case WM_SETFOCUS:\r
@@ -8246,18 +8249,10 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 VOID\r
 ConsoleCreate()\r
 {\r
-  HWND hCons, hText;\r
-  WORD wMask;\r
+  HWND hCons;\r
   if (hwndConsole) return;\r
   hCons = CreateDialog(hInst, szConsoleName, 0, NULL);\r
   SendMessage(hCons, WM_INITDIALOG, 0, 0);\r
-\r
-\r
-  // make the text item in the console do URL links\r
-  hText = GetDlgItem(hCons, OPT_ConsoleText);\r
-  wMask = SendMessage(hText, EM_GETEVENTMASK, 0, 0L);\r
-  SendMessage(hText, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
-  SendMessage(hText, EM_AUTOURLDETECT, TRUE, 0L);\r
 }\r
 \r
 \r