@@ -6597,14 +6597,12 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
65976597 const WCHAR * _special_symbs = L"`~!@#%^*-_+=|\\/:;\"',.?" ;
65986598
65996599 // [2e]: Enclose Selection - add links with quotation marks #280
6600- static int id_hover = 0 ;
6601- static int id_capture = 0 ;
6602- static HFONT hFontNormal = NULL ;
6603- static HFONT hFontHover = NULL ;
6604- static HCURSOR hCursorNormal = NULL ;
6605- static HCURSOR hCursorHover = NULL ;
6606- const DWORD iMinLinkID = 200 ;
6607- const DWORD iMaxLinkID = iMinLinkID + iUnicodeQuotesCount ;
6600+ static HFONT hFontLink = NULL ;
6601+ const DWORD iMinLinkID_SingleQuote = 200 ;
6602+ const DWORD iMaxLinkID_SingleQuote = iMinLinkID_SingleQuote + 9 ;
6603+ const DWORD iMinLinkID_DoubleQuote = iMaxLinkID_SingleQuote + 1 ;
6604+ const DWORD iMaxLinkID_DoubleQuote = iMinLinkID_DoubleQuote + 3 ;
6605+ static DWORD dwFocusID = 0 ;
66086606 // [/2e]
66096607
66106608 static PENCLOSESELDATA pdata ;
@@ -6617,21 +6615,33 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
66176615 // [2e]: Enclose Selection - add links with quotation marks #280
66186616 LOGFONT lf = { 0 };
66196617
6620- if (hFontNormal == NULL )
6621- hFontNormal = GetStockObject (DEFAULT_GUI_FONT );
6622- GetObject (hFontNormal , sizeof (LOGFONT ), & lf );
6623- lf .lfUnderline = TRUE;
6624- lf .lfHeight *= 1.25 ;
6625- hFontHover = CreateFontIndirect (& lf );
6618+ if (hFontLink == NULL )
6619+ {
6620+ HDC hdc = GetDC (hwnd );
6621+ GetObject (hFontLink , sizeof (LOGFONT ), & lf );
6622+ lstrcpy (lf .lfFaceName , L"Georgia" );
6623+ lf .lfUnderline = TRUE;
6624+ lf .lfHeight = - MulDiv (12 , GetDeviceCaps (hdc , LOGPIXELSY ), 72 );
6625+ ReleaseDC (hwnd , hdc );
6626+ hFontLink = CreateFontIndirect (& lf );
6627+ }
66266628
6627- hCursorNormal = LoadCursor (NULL , MAKEINTRESOURCE (IDC_ARROW ));
6628- if (!(hCursorHover = LoadCursor (NULL , MAKEINTRESOURCE (IDC_HAND ))))
6629- hCursorHover = LoadCursor (g_hInstance , MAKEINTRESOURCE (IDC_ARROW ));
6629+ for (DWORD dwId = iMinLinkID_SingleQuote ; dwId <= iMaxLinkID_SingleQuote ; ++ dwId )
6630+ {
6631+ WCHAR linkText [] = L"<a>X</a>" ;
6632+ linkText [3 ] = lpwstrUnicodeQuotes [dwId - iMinLinkID_SingleQuote ];
6633+ SetDlgItemTextW (hwnd , dwId , linkText );
6634+ SendDlgItemMessage (hwnd , dwId , WM_SETFONT , (WPARAM )hFontLink , 0 );
6635+ }
66306636
6631- for (DWORD dwId = iMinLinkID ; dwId <= iMaxLinkID ; ++ dwId )
6637+ for (DWORD dwId = iMinLinkID_DoubleQuote ; dwId <= iMaxLinkID_DoubleQuote ; ++ dwId )
66326638 {
6633- WCHAR linkText [2 ] = { lpwstrUnicodeQuotes [dwId - iMinLinkID ], 0 };
6639+ const int quoteIndex = (iMaxLinkID_SingleQuote - iMinLinkID_SingleQuote ) + 1 + (dwId - iMinLinkID_DoubleQuote ) * 2 ;
6640+ WCHAR linkText [] = L"<a>XX</a>" ;
6641+ linkText [3 ] = lpwstrUnicodeQuotes [quoteIndex ];
6642+ linkText [4 ] = lpwstrUnicodeQuotes [quoteIndex + 1 ];
66346643 SetDlgItemTextW (hwnd , dwId , linkText );
6644+ SendDlgItemMessage (hwnd , dwId , WM_SETFONT , (WPARAM )hFontLink , 0 );
66356645 }
66366646 // [/2e]
66376647
@@ -6645,122 +6655,6 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
66456655 }
66466656 return TRUE;
66476657
6648- // [2e]: Enclose Selection - add links with quotation marks #280
6649- case WM_DESTROY :
6650- DeleteObject (hFontHover );
6651- return FALSE;
6652-
6653- case WM_NCACTIVATE :
6654- if (!(BOOL )wParam )
6655- {
6656- if (id_hover != 0 )
6657- {
6658- int _id_hover = id_hover ;
6659- id_hover = 0 ;
6660- id_capture = 0 ;
6661- }
6662- }
6663- return FALSE;
6664-
6665- case WM_CTLCOLORSTATIC : {
6666- DWORD dwId = GetWindowLong ((HWND )lParam , GWL_ID );
6667- HDC hdc = (HDC )wParam ;
6668- if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6669- {
6670- SetBkMode (hdc , TRANSPARENT );
6671- if (GetSysColorBrush (COLOR_HOTLIGHT ))
6672- {
6673- SetTextColor (hdc , GetSysColor (COLOR_HOTLIGHT ));
6674- }
6675- else
6676- {
6677- SetTextColor (hdc , RGB (0 , 0 , 255 ));
6678- }
6679- SelectObject (hdc , hFontHover );
6680- return (LONG_PTR )GetSysColorBrush (COLOR_BTNFACE );
6681- }
6682- }
6683- break ;
6684-
6685- case WM_MOUSEMOVE : {
6686- POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6687- HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6688- DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6689- if (GetActiveWindow () == hwnd )
6690- {
6691- if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6692- {
6693- if (id_capture == dwId || id_capture == 0 )
6694- {
6695- if (id_hover != id_capture || id_hover == 0 )
6696- {
6697- id_hover = dwId ;
6698- }
6699- }
6700- else if (id_hover != 0 )
6701- {
6702- int _id_hover = id_hover ;
6703- id_hover = 0 ;
6704- }
6705- }
6706- else if (id_hover != 0 )
6707- {
6708- int _id_hover = id_hover ;
6709- id_hover = 0 ;
6710- }
6711- SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6712- }
6713- }
6714- break ;
6715-
6716- case WM_LBUTTONDOWN : {
6717- POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6718- HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6719- DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6720- if (dwId >= iMinLinkID && dwId <= iMaxLinkID )
6721- {
6722- GetCapture ();
6723- id_hover = dwId ;
6724- id_capture = dwId ;
6725- }
6726- SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6727- }
6728- break ;
6729-
6730- case WM_LBUTTONUP : {
6731- POINT pt = { LOWORD (lParam ), HIWORD (lParam ) };
6732- HWND hwndHover = ChildWindowFromPoint (hwnd , pt );
6733- DWORD dwId = GetWindowLong (hwndHover , GWL_ID );
6734- if (id_capture != 0 )
6735- {
6736- ReleaseCapture ();
6737- if (id_hover == id_capture )
6738- {
6739- int id_focus = GetWindowLong (GetFocus (), GWL_ID );
6740- if (id_focus == 100 || id_focus == 101 )
6741- {
6742- WCHAR wch [8 ];
6743- GetDlgItemText (hwnd , id_capture , wch , COUNTOF (wch ));
6744- SendDlgItemMessage (hwnd , id_focus , EM_REPLACESEL , (WPARAM )TRUE, (LPARAM )wch );
6745- }
6746- }
6747- id_capture = 0 ;
6748- }
6749- SetCursor (id_hover != 0 ? hCursorHover : hCursorNormal );
6750- }
6751- break ;
6752-
6753- case WM_CANCELMODE :
6754- if (id_capture != 0 )
6755- {
6756- ReleaseCapture ();
6757- id_hover = 0 ;
6758- id_capture = 0 ;
6759- SetCursor (hCursorNormal );
6760- }
6761- break ;
6762- // [/2e]
6763-
67646658 case WM_COMMAND :
67656659 switch (LOWORD (wParam ))
67666660 {
@@ -6821,7 +6715,75 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM wParam
68216715 EndDialog (hwnd , IDCANCEL );
68226716 break ;
68236717 }
6718+
6719+ // [2e]: Enclose Selection - add links with quotation marks #280
6720+ if (((LOWORD (wParam ) == 100 ) || (LOWORD (wParam ) == 101 ))
6721+ && ((HIWORD (wParam ) == EN_SETFOCUS ) || (HIWORD (wParam ) == EN_KILLFOCUS )))
6722+ {
6723+ dwFocusID = LOWORD (wParam );
6724+ }
6725+ // [/2e]
6726+
68246727 return TRUE;
6728+
6729+ // [2e]: Enclose Selection - add links with quotation marks #280
6730+ case WM_NOTIFY : {
6731+ LPNMHDR pnmhdr = (LPNMHDR )lParam ;
6732+ switch (pnmhdr -> code )
6733+ {
6734+ case NM_CLICK :
6735+ case NM_RETURN : {
6736+ const DWORD dwControlId = pnmhdr -> idFrom ;
6737+ if ((dwControlId >= iMinLinkID_SingleQuote ) && (dwControlId <= iMaxLinkID_SingleQuote ))
6738+ {
6739+ WCHAR wch [2 ] = { lpwstrUnicodeQuotes [dwControlId - iMinLinkID_SingleQuote ], 0 };
6740+ SendDlgItemMessage (hwnd , dwFocusID , EM_REPLACESEL , (WPARAM )TRUE, (LPARAM )wch );
6741+ SetFocus (GetDlgItem (hwnd , dwFocusID ));
6742+ return TRUE;
6743+ }
6744+ else if (((dwControlId >= iMinLinkID_DoubleQuote ) && (dwControlId <= iMaxLinkID_DoubleQuote ))
6745+ || (dwControlId == IDC_SYSLINK1 ) || (dwControlId == IDC_SYSLINK2 )
6746+ || (dwControlId == IDC_SYSLINK3 ) || (dwControlId == IDC_SYSLINK4 ))
6747+ {
6748+ WCHAR buf1 [2 ] = { 0 };
6749+ WCHAR buf2 [2 ] = { 0 };
6750+ switch (dwControlId )
6751+ {
6752+ case IDC_SYSLINK1 :
6753+ buf1 [0 ] = lpwstrUnicodeQuotesUS [0 ];
6754+ buf2 [0 ] = lpwstrUnicodeQuotesUS [1 ];
6755+ break ;
6756+ case IDC_SYSLINK2 :
6757+ buf1 [0 ] = lpwstrUnicodeQuotesUS [2 ];
6758+ buf2 [0 ] = lpwstrUnicodeQuotesUS [3 ];
6759+ break ;
6760+ case IDC_SYSLINK3 :
6761+ buf1 [0 ] = lpwstrUnicodeQuotesRU [0 ];
6762+ buf2 [0 ] = lpwstrUnicodeQuotesRU [1 ];
6763+ break ;
6764+ case IDC_SYSLINK4 :
6765+ buf1 [0 ] = lpwstrUnicodeQuotesRU [2 ];
6766+ buf2 [0 ] = lpwstrUnicodeQuotesRU [3 ];
6767+ break ;
6768+ default :
6769+ {
6770+ const int quoteIndex = (iMaxLinkID_SingleQuote - iMinLinkID_SingleQuote ) + 1 + (dwControlId - iMinLinkID_DoubleQuote ) * 2 ;
6771+ buf1 [0 ] = lpwstrUnicodeQuotes [quoteIndex ];
6772+ buf2 [0 ] = lpwstrUnicodeQuotes [quoteIndex + 1 ];
6773+ break ;
6774+ }
6775+ }
6776+ SetWindowText (GetDlgItem (hwnd , 100 ), (LPCWSTR )& buf1 );
6777+ SetWindowText (GetDlgItem (hwnd , 101 ), (LPCWSTR )& buf2 );
6778+ SetFocus (GetDlgItem (hwnd , dwFocusID ));
6779+ return TRUE;
6780+ }
6781+ }
6782+ break ;
6783+ }
6784+ }
6785+ break ;
6786+ // [/2e]
68256787 }
68266788 return FALSE;
68276789}
0 commit comments