Add cyrillic glyphs to Wine System.
[wine/dcerpc.git] / dlls / comctl32 / syslink.c
blob2a7a58d07a2cb04a355c325516dceac04bf3fbee
1 /*
2 * SysLink control
4 * Copyright 2004 Thomas Weidenmueller <w3seek@reactos.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * TODO:
21 * - Fix SHIFT+TAB and TAB issue (wrong link is selected when control gets the focus)
22 * - Better string parsing
23 * - Improve word wrapping
24 * - Control styles?!
28 #include <stdarg.h>
29 #include <string.h>
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "winnls.h"
35 #include "commctrl.h"
36 #include "comctl32.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(progress);
41 INT WINAPI StrCmpNIW(LPCWSTR,LPCWSTR,INT);
43 #define SYSLINK_Alloc(size) HeapAlloc(GetProcessHeap(), 0, (size))
44 #define SYSLINK_Free(ptr) HeapFree(GetProcessHeap(), 0, (ptr))
45 #define SYSLINK_ReAlloc(ptr, size) HeapReAlloc(GetProcessHeap(), 0, ptr, (size))
47 typedef struct
49 int nChars;
50 RECT rc;
51 } DOC_TEXTBLOCK, *PDOC_TEXTBLOCK;
53 #define LIF_FLAGSMASK (LIF_STATE | LIF_ITEMID | LIF_URL)
54 #define LIS_MASK (LIS_FOCUSED | LIS_ENABLED | LIS_VISITED)
56 typedef enum
58 slText = 0,
59 slLink
60 } SL_ITEM_TYPE;
62 typedef struct _DOC_ITEM
64 struct _DOC_ITEM *Next; /* Address to the next item */
65 LPWSTR Text; /* Text of the document item */
66 UINT nText; /* Number of characters of the text */
67 SL_ITEM_TYPE Type; /* type of the item */
68 PDOC_TEXTBLOCK Blocks; /* Array of text blocks */
69 union
71 struct
73 UINT state; /* Link state */
74 WCHAR *szID; /* Link ID string */
75 WCHAR *szUrl; /* Link URL string */
76 HRGN hRgn; /* Region of the link */
77 } Link;
78 struct
80 UINT Dummy;
81 } Text;
82 } u;
83 } DOC_ITEM, *PDOC_ITEM;
85 typedef struct
87 HWND Self; /* The window handle for this control */
88 PDOC_ITEM Items; /* Address to the first document item */
89 BOOL HasFocus; /* Whether the control has the input focus */
90 int MouseDownID; /* ID of the link that the mouse button first selected */
91 HFONT Font; /* Handle to the font for text */
92 HFONT LinkFont; /* Handle to the font for links */
93 COLORREF TextColor; /* Color of the text */
94 COLORREF LinkColor; /* Color of links */
95 COLORREF VisitedColor; /* Color of visited links */
96 } SYSLINK_INFO;
98 static const WCHAR SL_LINKOPEN[] = { '<','a', 0 };
99 static const WCHAR SL_HREF[] = { 'h','r','e','f','=','\"',0 };
100 static const WCHAR SL_ID[] = { 'i','d','=','\"',0 };
101 static const WCHAR SL_LINKCLOSE[] = { '<','/','a','>',0 };
103 /* Control configuration constants */
105 #define SL_LEFTMARGIN (0)
106 #define SL_TOPMARGIN (0)
107 #define SL_RIGHTMARGIN (0)
108 #define SL_BOTTOMMARGIN (0)
110 /***********************************************************************
111 * SYSLINK_FreeDocItem
112 * Frees all data and gdi objects associated with a document item
114 static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem)
116 if(DocItem->Type == slLink)
118 if(DocItem->u.Link.szID != NULL)
120 SYSLINK_Free(DocItem->u.Link.szID);
122 if(DocItem->u.Link.szUrl != NULL)
124 SYSLINK_Free(DocItem->u.Link.szUrl);
128 if(DocItem->Type == slLink && DocItem->u.Link.hRgn != NULL)
130 DeleteObject(DocItem->u.Link.hRgn);
133 /* we don't free Text because it's just a pointer to a character in the
134 entire window text string */
136 SYSLINK_Free(DocItem);
139 /***********************************************************************
140 * SYSLINK_AppendDocItem
141 * Create and append a new document item.
143 static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPWSTR Text, UINT textlen,
144 SL_ITEM_TYPE type, PDOC_ITEM LastItem)
146 PDOC_ITEM Item;
147 Item = SYSLINK_Alloc(sizeof(DOC_ITEM) + ((textlen + 1) * sizeof(WCHAR)));
148 if(Item == NULL)
150 ERR("Failed to alloc DOC_ITEM structure!\n");
151 return NULL;
153 textlen = min(textlen, lstrlenW(Text));
155 Item->Next = NULL;
156 Item->Text = (LPWSTR)(Item + 1);
157 Item->nText = textlen;
158 Item->Type = type;
159 Item->Blocks = NULL;
161 if(LastItem != NULL)
163 LastItem->Next = Item;
165 else
167 infoPtr->Items = Item;
170 lstrcpynW(Item->Text, Text, textlen + 1);
171 Item->Text[textlen] = 0;
173 return Item;
176 /***********************************************************************
177 * SYSLINK_ClearDoc
178 * Clears the document tree
180 static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr)
182 PDOC_ITEM Item, Next;
184 Item = infoPtr->Items;
185 while(Item != NULL)
187 Next = Item->Next;
188 SYSLINK_FreeDocItem(Item);
189 Item = Next;
192 infoPtr->Items = NULL;
195 /***********************************************************************
196 * SYSLINK_ParseText
197 * Parses the window text string and creates a document. Returns the
198 * number of document items created.
200 static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPWSTR Text)
202 WCHAR *current, *textstart, *linktext, *firsttag;
203 int taglen = 0, textlen, linklen, docitems = 0;
204 PDOC_ITEM Last = NULL;
205 SL_ITEM_TYPE CurrentType = slText;
206 DWORD Style;
207 LPWSTR lpID, lpUrl;
208 UINT lenId, lenUrl;
210 Style = GetWindowLongW(infoPtr->Self, GWL_STYLE);
212 firsttag = NULL;
213 textstart = NULL;
214 linktext = NULL;
215 textlen = 0;
216 linklen = 0;
218 for(current = (WCHAR*)Text; *current != 0;)
220 if(*current == '<')
222 if(!StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText))
224 BOOL ValidParam = FALSE, ValidLink = FALSE;
226 switch (*(current + 2))
228 case '>':
229 /* we just have to deal with a <a> tag */
230 taglen = 3;
231 ValidLink = TRUE;
232 ValidParam = TRUE;
233 firsttag = current;
234 linklen = 0;
235 lpID = NULL;
236 lpUrl = NULL;
237 break;
238 case ' ':
240 /* we expect parameters, parse them */
241 LPWSTR *CurrentParameter = NULL;
242 UINT *CurrentParameterLen = NULL;
243 WCHAR *tmp;
245 taglen = 3;
246 tmp = current + taglen;
247 lpID = NULL;
248 lpUrl = NULL;
250 CheckParameter:
251 /* compare the current position with all known parameters */
252 if(!StrCmpNIW(tmp, SL_HREF, 6))
254 taglen += 6;
255 ValidParam = TRUE;
256 CurrentParameter = &lpUrl;
257 CurrentParameterLen = &lenUrl;
259 else if(!StrCmpNIW(tmp, SL_ID, 4))
261 taglen += 4;
262 ValidParam = TRUE;
263 CurrentParameter = &lpID;
264 CurrentParameterLen = &lenId;
266 else
268 ValidParam = FALSE;
271 if(ValidParam)
273 /* we got a known parameter, now search until the next " character.
274 If we can't find a " character, there's a syntax error and we just assume it's text */
275 ValidParam = FALSE;
276 *CurrentParameter = current + taglen;
277 *CurrentParameterLen = 0;
279 for(tmp = *CurrentParameter; *tmp != 0; tmp++)
281 taglen++;
282 if(*tmp == '\"')
284 ValidParam = TRUE;
285 tmp++;
286 break;
288 (*CurrentParameterLen)++;
291 if(ValidParam)
293 /* we're done with this parameter, now there are only 2 possibilities:
294 * 1. another parameter is coming, so expect a ' ' (space) character
295 * 2. the tag is being closed, so expect a '<' character
297 switch(*tmp)
299 case ' ':
300 /* we expect another parameter, do the whole thing again */
301 taglen++;
302 tmp++;
303 goto CheckParameter;
305 case '>':
306 /* the tag is being closed, we're done */
307 ValidLink = TRUE;
308 taglen++;
309 break;
310 default:
311 tmp++;
312 break;
316 break;
320 if(ValidLink && ValidParam)
322 /* the <a ...> tag appears to be valid. save all information
323 so we can add the link if we find a valid </a> tag later */
324 CurrentType = slLink;
325 linktext = current + taglen;
326 linklen = 0;
327 firsttag = current;
329 else
331 taglen = 1;
332 lpID = NULL;
333 lpUrl = NULL;
334 if(textstart == NULL)
336 textstart = current;
340 else if(!StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag)
342 /* there's a <a...> tag opened, first add the previous text, if present */
343 if(textstart != NULL && textlen > 0 && firsttag > textstart)
345 Last = SYSLINK_AppendDocItem(infoPtr, textstart, firsttag - textstart, slText, Last);
346 if(Last == NULL)
348 ERR("Unable to create new document item!\n");
349 return docitems;
351 docitems++;
352 textstart = NULL;
353 textlen = 0;
356 /* now it's time to add the link to the document */
357 current += 4;
358 if(linktext != NULL && linklen > 0)
360 Last = SYSLINK_AppendDocItem(infoPtr, linktext, linklen, slLink, Last);
361 if(Last == NULL)
363 ERR("Unable to create new document item!\n");
364 return docitems;
366 docitems++;
367 if(CurrentType == slLink)
369 int nc;
371 if(!(Style & WS_DISABLED))
373 Last->u.Link.state |= LIS_ENABLED;
375 /* Copy the tag parameters */
376 if(lpID != NULL)
378 nc = min(lenId, lstrlenW(lpID));
379 nc = min(nc, MAX_LINKID_TEXT);
380 Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
381 if(Last->u.Link.szID != NULL)
383 lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
384 Last->u.Link.szID[nc] = 0;
387 else
388 Last->u.Link.szID = NULL;
389 if(lpUrl != NULL)
391 nc = min(lenUrl, lstrlenW(lpUrl));
392 nc = min(nc, L_MAX_URL_LENGTH);
393 Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
394 if(Last->u.Link.szUrl != NULL)
396 lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
397 Last->u.Link.szUrl[nc] = 0;
400 else
401 Last->u.Link.szUrl = NULL;
403 linktext = NULL;
405 CurrentType = slText;
406 firsttag = NULL;
407 textstart = NULL;
408 continue;
410 else
412 /* we don't know what tag it is, so just continue */
413 taglen = 1;
414 linklen++;
415 if(CurrentType == slText && textstart == NULL)
417 textstart = current;
421 textlen += taglen;
422 current += taglen;
424 else
426 textlen++;
427 linklen++;
429 /* save the pointer of the current text item if we couldn't find a tag */
430 if(textstart == NULL && CurrentType == slText)
432 textstart = current;
435 current++;
439 if(textstart != NULL && textlen > 0)
441 Last = SYSLINK_AppendDocItem(infoPtr, textstart, textlen, CurrentType, Last);
442 if(Last == NULL)
444 ERR("Unable to create new document item!\n");
445 return docitems;
447 if(CurrentType == slLink)
449 int nc;
451 if(!(Style & WS_DISABLED))
453 Last->u.Link.state |= LIS_ENABLED;
455 /* Copy the tag parameters */
456 if(lpID != NULL)
458 nc = min(lenId, lstrlenW(lpID));
459 nc = min(nc, MAX_LINKID_TEXT);
460 Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
461 if(Last->u.Link.szID != NULL)
463 lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
464 Last->u.Link.szID[nc] = 0;
467 else
468 Last->u.Link.szID = NULL;
469 if(lpUrl != NULL)
471 nc = min(lenUrl, lstrlenW(lpUrl));
472 nc = min(nc, L_MAX_URL_LENGTH);
473 Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR));
474 if(Last->u.Link.szUrl != NULL)
476 lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
477 Last->u.Link.szUrl[nc] = 0;
480 else
481 Last->u.Link.szUrl = NULL;
483 docitems++;
486 if(linktext != NULL && linklen > 0)
488 /* we got a unclosed link, just display the text */
489 Last = SYSLINK_AppendDocItem(infoPtr, linktext, linklen, slText, Last);
490 if(Last == NULL)
492 ERR("Unable to create new document item!\n");
493 return docitems;
495 docitems++;
498 return docitems;
501 /***********************************************************************
502 * SYSLINK_RepaintLink
503 * Repaints a link.
505 static VOID SYSLINK_RepaintLink (SYSLINK_INFO *infoPtr, PDOC_ITEM DocItem)
507 if(DocItem->Type != slLink)
509 ERR("DocItem not a link!\n");
510 return;
513 if(DocItem->u.Link.hRgn != NULL)
515 /* repaint the region */
516 RedrawWindow(infoPtr->Self, NULL, DocItem->u.Link.hRgn, RDW_INVALIDATE | RDW_UPDATENOW);
520 /***********************************************************************
521 * SYSLINK_GetLinkItemByIndex
522 * Retreives a document link by it's index
524 static PDOC_ITEM SYSLINK_GetLinkItemByIndex (SYSLINK_INFO *infoPtr, int iLink)
526 PDOC_ITEM Current = infoPtr->Items;
528 while(Current != NULL)
530 if((Current->Type == slLink) && (iLink-- <= 0))
532 return Current;
534 Current = Current->Next;
536 return NULL;
539 /***********************************************************************
540 * SYSLINK_GetFocusLink
541 * Retreives the link that has the LIS_FOCUSED bit
543 static PDOC_ITEM SYSLINK_GetFocusLink (SYSLINK_INFO *infoPtr, int *LinkId)
545 PDOC_ITEM Current = infoPtr->Items;
546 int id = 0;
548 while(Current != NULL)
550 if((Current->Type == slLink))
552 if(Current->u.Link.state & LIS_FOCUSED)
554 if(LinkId != NULL)
555 *LinkId = id;
556 return Current;
558 id++;
560 Current = Current->Next;
562 return NULL;
565 /***********************************************************************
566 * SYSLINK_GetNextLink
567 * Gets the next link
569 static PDOC_ITEM SYSLINK_GetNextLink (SYSLINK_INFO *infoPtr, PDOC_ITEM Current)
571 for(Current = (Current != NULL ? Current->Next : infoPtr->Items);
572 Current != NULL;
573 Current = Current->Next)
575 if(Current->Type == slLink)
577 return Current;
580 return NULL;
583 /***********************************************************************
584 * SYSLINK_GetPrevLink
585 * Gets the previous link
587 static PDOC_ITEM SYSLINK_GetPrevLink (SYSLINK_INFO *infoPtr, PDOC_ITEM Current)
589 if(Current == NULL)
591 /* returns the last link */
592 PDOC_ITEM Last = NULL;
594 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
596 if(Current->Type == slLink)
598 Last = Current;
601 return Last;
603 else
605 /* returns the previous link */
606 PDOC_ITEM Cur, Prev = NULL;
608 for(Cur = infoPtr->Items; Cur != NULL; Cur = Cur->Next)
610 if(Cur == Current)
612 break;
614 if(Cur->Type == slLink)
616 Prev = Cur;
619 return Prev;
623 /***********************************************************************
624 * SYSLINK_WrapLine
625 * Tries to wrap a line.
627 static BOOL SYSLINK_WrapLine (HDC hdc, LPWSTR Text, WCHAR BreakChar, int *LineLen, int nFit, LPSIZE Extent, int Width)
629 WCHAR *Current;
631 if(nFit == *LineLen)
633 return FALSE;
636 *LineLen = nFit;
638 Current = Text + nFit;
640 /* check if we're in the middle of a word */
641 if((*Current) != BreakChar)
643 /* search for the beginning of the word */
644 while(Current > Text && (*(Current - 1)) != BreakChar)
646 Current--;
647 (*LineLen)--;
650 if((*LineLen) == 0)
652 Extent->cx = 0;
653 Extent->cy = 0;
655 return TRUE;
658 return TRUE;
661 /***********************************************************************
662 * SYSLINK_Render
663 * Renders the document in memory
665 static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
667 RECT rc;
668 PDOC_ITEM Current;
669 HGDIOBJ hOldFont;
670 int x, y, LineHeight;
671 TEXTMETRICW tm;
673 GetClientRect(infoPtr->Self, &rc);
674 rc.right -= SL_RIGHTMARGIN;
675 rc.bottom -= SL_BOTTOMMARGIN;
677 if(rc.right - SL_LEFTMARGIN < 0 || rc.bottom - SL_TOPMARGIN < 0) return;
679 hOldFont = SelectObject(hdc, infoPtr->Font);
680 GetTextMetricsW(hdc, &tm);
682 x = SL_LEFTMARGIN;
683 y = SL_TOPMARGIN;
684 LineHeight = 0;
686 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
688 int n, nBlocks;
689 LPWSTR tx;
690 PDOC_TEXTBLOCK bl, cbl;
691 INT nFit;
692 SIZE szDim;
694 if(Current->nText == 0)
696 ERR("DOC_ITEM with no text?!\n");
697 continue;
700 tx = Current->Text;
701 n = Current->nText;
702 bl = Current->Blocks;
703 nBlocks = 0;
705 if(Current->Type == slText)
707 SelectObject(hdc, infoPtr->Font);
709 else if(Current->Type == slLink)
711 SelectObject(hdc, infoPtr->LinkFont);
714 while(n > 0)
716 if(GetTextExtentExPointW(hdc, tx, n, rc.right - x, &nFit, NULL, &szDim))
718 int LineLen = n;
719 BOOL Wrap = SYSLINK_WrapLine(hdc, tx, tm.tmBreakChar, &LineLen, nFit, &szDim, rc.right - x);
721 if(LineLen == 0)
723 if(x > SL_LEFTMARGIN)
725 /* move one line down, the word didn't fit into the line */
726 x = SL_LEFTMARGIN;
727 y += LineHeight;
728 LineHeight = 0;
729 continue;
731 else
733 /* the word starts at the beginning of the line and doesn't
734 fit into the line, so break it at the last character that fits */
735 LineLen = max(nFit, 1);
739 if(LineLen != n)
741 GetTextExtentExPointW(hdc, tx, LineLen, rc.right - x, NULL, NULL, &szDim);
744 if(bl != NULL)
746 bl = SYSLINK_ReAlloc(bl, ++nBlocks * sizeof(DOC_TEXTBLOCK));
748 else
750 bl = SYSLINK_Alloc(++nBlocks * sizeof(DOC_TEXTBLOCK));
753 if(bl != NULL)
755 cbl = bl + nBlocks - 1;
757 cbl->nChars = LineLen;
758 cbl->rc.left = x;
759 cbl->rc.top = y;
760 cbl->rc.right = x + szDim.cx;
761 cbl->rc.bottom = y + szDim.cy;
763 x += szDim.cx;
764 LineHeight = max(LineHeight, szDim.cy);
766 /* (re)calculate the link's region */
767 if(Current->Type == slLink)
769 if(nBlocks <= 1)
771 if(Current->u.Link.hRgn != NULL)
773 DeleteObject(Current->u.Link.hRgn);
775 /* initialize the link's hRgn */
776 Current->u.Link.hRgn = CreateRectRgnIndirect(&cbl->rc);
778 else if(Current->u.Link.hRgn != NULL)
780 HRGN hrgn;
781 hrgn = CreateRectRgnIndirect(&cbl->rc);
782 /* add the rectangle */
783 CombineRgn(Current->u.Link.hRgn, Current->u.Link.hRgn, hrgn, RGN_OR);
784 DeleteObject(hrgn);
788 if(Wrap)
790 x = SL_LEFTMARGIN;
791 y += LineHeight;
792 LineHeight = 0;
795 else
797 ERR("Failed to alloc DOC_TEXTBLOCK structure!\n");
798 break;
800 n -= LineLen;
801 tx += LineLen;
803 else
805 ERR("GetTextExtentExPoint() failed?!\n");
806 n--;
809 Current->Blocks = bl;
812 SelectObject(hdc, hOldFont);
815 /***********************************************************************
816 * SYSLINK_Draw
817 * Draws the SysLink control.
819 static LRESULT SYSLINK_Draw (SYSLINK_INFO *infoPtr, HDC hdc)
821 RECT rc;
822 PDOC_ITEM Current;
823 HFONT hOldFont;
824 COLORREF OldTextColor, OldBkColor;
826 hOldFont = SelectObject(hdc, infoPtr->Font);
827 OldTextColor = SetTextColor(hdc, infoPtr->TextColor);
828 OldBkColor = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
830 GetClientRect(infoPtr->Self, &rc);
831 rc.right -= SL_RIGHTMARGIN + SL_LEFTMARGIN;
832 rc.bottom -= SL_BOTTOMMARGIN + SL_TOPMARGIN;
834 if(rc.right < 0 || rc.bottom < 0) return 0;
836 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
838 int n;
839 LPWSTR tx;
840 PDOC_TEXTBLOCK bl;
842 bl = Current->Blocks;
843 if(bl != NULL)
845 tx = Current->Text;
846 n = Current->nText;
848 if(Current->Type == slText)
850 SelectObject(hdc, infoPtr->Font);
851 SetTextColor(hdc, infoPtr->TextColor);
853 else
855 SelectObject(hdc, infoPtr->LinkFont);
856 SetTextColor(hdc, (!(Current->u.Link.state & LIS_VISITED) ? infoPtr->LinkColor : infoPtr->VisitedColor));
859 while(n > 0)
861 ExtTextOutW(hdc, bl->rc.left, bl->rc.top, ETO_OPAQUE | ETO_CLIPPED, &bl->rc, tx, bl->nChars, NULL);
862 if((Current->Type == slLink) && (Current->u.Link.state & LIS_FOCUSED) && infoPtr->HasFocus)
864 COLORREF PrevColor;
865 PrevColor = SetBkColor(hdc, OldBkColor);
866 DrawFocusRect(hdc, &bl->rc);
867 SetBkColor(hdc, PrevColor);
869 tx += bl->nChars;
870 n -= bl->nChars;
871 bl++;
876 SetBkColor(hdc, OldBkColor);
877 SetTextColor(hdc, OldTextColor);
878 SelectObject(hdc, hOldFont);
880 return 0;
884 /***********************************************************************
885 * SYSLINK_Paint
886 * Handles the WM_PAINT message.
888 static LRESULT SYSLINK_Paint (SYSLINK_INFO *infoPtr)
890 HDC hdc;
891 PAINTSTRUCT ps;
892 hdc = BeginPaint (infoPtr->Self, &ps);
893 SYSLINK_Draw (infoPtr, hdc);
894 EndPaint (infoPtr->Self, &ps);
895 return 0;
899 /***********************************************************************
900 * SYSLINK_SetFont
901 * Set new Font for the SysLink control.
903 static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
905 HDC hdc;
906 LOGFONTW lf;
907 HFONT hOldFont = infoPtr->Font;
908 infoPtr->Font = hFont;
910 /* free the underline font */
911 if(infoPtr->LinkFont != NULL)
913 DeleteObject(infoPtr->LinkFont);
914 infoPtr->LinkFont = NULL;
917 /* Render text position and word wrapping in memory */
918 hdc = GetDC(infoPtr->Self);
919 if(hdc != NULL)
921 /* create a new underline font */
922 if(GetObjectW(infoPtr->Font, sizeof(LOGFONTW), &lf))
924 lf.lfUnderline = TRUE;
925 infoPtr->LinkFont = CreateFontIndirectW(&lf);
927 else
929 ERR("Failed to create link font!\n");
932 SYSLINK_Render(infoPtr, hdc);
933 ReleaseDC(infoPtr->Self, hdc);
936 if(bRedraw)
938 RedrawWindow(infoPtr->Self, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
941 return hOldFont;
944 /***********************************************************************
945 * SYSLINK_SetText
946 * Set new text for the SysLink control.
948 static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPWSTR Text)
950 int textlen;
952 /* clear the document */
953 SYSLINK_ClearDoc(infoPtr);
955 textlen = lstrlenW(Text);
956 if(Text == NULL || textlen == 0)
958 return TRUE;
961 /* let's parse the string and create a document */
962 if(SYSLINK_ParseText(infoPtr, Text) > 0)
964 /* Render text position and word wrapping in memory */
965 HDC hdc = GetDC(infoPtr->Self);
966 SYSLINK_Render(infoPtr, hdc);
967 SYSLINK_Draw(infoPtr, hdc);
968 ReleaseDC(infoPtr->Self, hdc);
971 return TRUE;
974 /***********************************************************************
975 * SYSLINK_SetFocusLink
976 * Updates the focus status bits and focusses the specified link.
977 * If no document item is specified, the focus bit will be removed from all links.
978 * Returns the previous focused item.
980 static PDOC_ITEM SYSLINK_SetFocusLink (SYSLINK_INFO *infoPtr, PDOC_ITEM DocItem)
982 PDOC_ITEM Current, PrevFocus = NULL;
984 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
986 if(Current->Type == slLink)
988 if((PrevFocus == NULL) && (Current->u.Link.state & LIS_FOCUSED))
990 PrevFocus = Current;
993 if(Current == DocItem)
995 Current->u.Link.state |= LIS_FOCUSED;
997 else
999 Current->u.Link.state &= ~LIS_FOCUSED;
1004 return PrevFocus;
1007 /***********************************************************************
1008 * SYSLINK_SetItem
1009 * Sets the states and attributes of a link item.
1011 static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
1013 PDOC_ITEM di;
1014 BOOL Repaint = FALSE;
1015 BOOL Ret = TRUE;
1017 if(!(Item->mask & LIF_ITEMINDEX) || !(Item->mask & (LIF_FLAGSMASK)))
1019 ERR("Invalid Flags!\n");
1020 return FALSE;
1023 di = SYSLINK_GetLinkItemByIndex(infoPtr, Item->iLink);
1024 if(di == NULL)
1026 ERR("Link %d couldn't be found\n", Item->iLink);
1027 return FALSE;
1030 if(Item->mask & LIF_STATE)
1032 UINT oldstate = di->u.Link.state;
1033 /* clear the masked bits */
1034 di->u.Link.state &= ~(Item->stateMask & LIS_MASK);
1035 /* copy the bits */
1036 di->u.Link.state |= (Item->state & Item->stateMask) & LIS_MASK;
1037 Repaint = (oldstate != di->u.Link.state);
1039 /* update the focus */
1040 SYSLINK_SetFocusLink(infoPtr, ((di->u.Link.state & LIS_FOCUSED) ? di : NULL));
1043 if(Item->mask & LIF_ITEMID)
1045 if(!di->u.Link.szID)
1047 di->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
1048 if(!Item->szID)
1050 ERR("Unable to allocate memory for link id\n");
1051 Ret = FALSE;
1054 if(di->u.Link.szID)
1056 lstrcpynW(di->u.Link.szID, Item->szID, MAX_LINKID_TEXT + 1);
1060 if(Item->mask & LIF_URL)
1062 if(!di->u.Link.szUrl)
1064 di->u.Link.szUrl = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR));
1065 if(!Item->szUrl)
1067 ERR("Unable to allocate memory for link url\n");
1068 Ret = FALSE;
1071 if(di->u.Link.szUrl)
1073 lstrcpynW(di->u.Link.szUrl, Item->szUrl, MAX_LINKID_TEXT + 1);
1077 if(Repaint)
1079 SYSLINK_RepaintLink(infoPtr, di);
1082 return Ret;
1085 /***********************************************************************
1086 * SYSLINK_GetItem
1087 * Retrieves the states and attributes of a link item.
1089 static LRESULT SYSLINK_GetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
1091 PDOC_ITEM di;
1093 if(!(Item->mask & LIF_ITEMINDEX) || !(Item->mask & (LIF_FLAGSMASK)))
1095 ERR("Invalid Flags!\n");
1096 return FALSE;
1099 di = SYSLINK_GetLinkItemByIndex(infoPtr, Item->iLink);
1100 if(di == NULL)
1102 ERR("Link %d couldn't be found\n", Item->iLink);
1103 return FALSE;
1106 if(Item->mask & LIF_STATE)
1108 Item->state = (di->u.Link.state & Item->stateMask);
1109 if(!infoPtr->HasFocus)
1111 /* remove the LIS_FOCUSED bit if the control doesn't have focus */
1112 Item->state &= ~LIS_FOCUSED;
1116 if(Item->mask & LIF_ITEMID)
1118 if(di->u.Link.szID)
1120 lstrcpynW(Item->szID, di->u.Link.szID, MAX_LINKID_TEXT + 1);
1122 else
1124 Item->szID[0] = 0;
1128 if(Item->mask & LIF_URL)
1130 if(di->u.Link.szUrl)
1132 lstrcpynW(Item->szUrl, di->u.Link.szUrl, L_MAX_URL_LENGTH + 1);
1134 else
1136 Item->szUrl[0] = 0;
1140 return TRUE;
1143 /***********************************************************************
1144 * SYSLINK_HitTest
1145 * Determines the link the user clicked on.
1147 static LRESULT SYSLINK_HitTest (SYSLINK_INFO *infoPtr, PLHITTESTINFO HitTest)
1149 PDOC_ITEM Current;
1150 int id = 0;
1152 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
1154 if(Current->Type == slLink)
1156 if((Current->u.Link.hRgn != NULL) &&
1157 PtInRegion(Current->u.Link.hRgn, HitTest->pt.x, HitTest->pt.y))
1159 HitTest->item.mask = 0;
1160 HitTest->item.iLink = id;
1161 HitTest->item.state = 0;
1162 HitTest->item.stateMask = 0;
1163 if(Current->u.Link.szID)
1165 lstrcpynW(HitTest->item.szID, Current->u.Link.szID, MAX_LINKID_TEXT + 1);
1167 else
1169 HitTest->item.szID[0] = 0;
1171 if(Current->u.Link.szUrl)
1173 lstrcpynW(HitTest->item.szUrl, Current->u.Link.szUrl, L_MAX_URL_LENGTH + 1);
1175 else
1177 HitTest->item.szUrl[0] = 0;
1179 return TRUE;
1181 id++;
1185 return FALSE;
1188 /***********************************************************************
1189 * SYSLINK_GetIdealHeight
1190 * Returns the preferred height of a link at the current control's width.
1192 static LRESULT SYSLINK_GetIdealHeight (SYSLINK_INFO *infoPtr)
1194 HDC hdc = GetDC(infoPtr->Self);
1195 if(hdc != NULL)
1197 LRESULT height;
1198 TEXTMETRICW tm;
1199 HGDIOBJ hOldFont = SelectObject(hdc, infoPtr->Font);
1201 if(GetTextMetricsW(hdc, &tm))
1203 height = tm.tmHeight;
1205 else
1207 height = 0;
1209 SelectObject(hdc, hOldFont);
1210 ReleaseDC(infoPtr->Self, hdc);
1212 return height;
1214 return 0;
1217 /***********************************************************************
1218 * SYSLINK_SendParentNotify
1219 * Sends a WM_NOTIFY message to the parent window.
1221 static LRESULT SYSLINK_SendParentNotify (SYSLINK_INFO *infoPtr, UINT code, PDOC_ITEM Link, int iLink)
1223 NMLINK nml;
1225 nml.hdr.hwndFrom = infoPtr->Self;
1226 nml.hdr.idFrom = GetWindowLongPtrW(infoPtr->Self, GWLP_ID);
1227 nml.hdr.code = code;
1229 nml.item.mask = 0;
1230 nml.item.iLink = iLink;
1231 nml.item.state = 0;
1232 nml.item.stateMask = 0;
1233 if(Link->u.Link.szID)
1235 lstrcpynW(nml.item.szID, Link->u.Link.szID, MAX_LINKID_TEXT + 1);
1237 else
1239 nml.item.szID[0] = 0;
1241 if(Link->u.Link.szUrl)
1243 lstrcpynW(nml.item.szUrl, Link->u.Link.szUrl, L_MAX_URL_LENGTH + 1);
1245 else
1247 nml.item.szUrl[0] = 0;
1250 return SendMessageW(GetParent(infoPtr->Self), WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml);
1253 /***********************************************************************
1254 * SYSLINK_SetFocus
1255 * Handles receiving the input focus.
1257 static LRESULT SYSLINK_SetFocus (SYSLINK_INFO *infoPtr, HWND PrevFocusWindow)
1259 PDOC_ITEM Focus;
1261 infoPtr->HasFocus = TRUE;
1263 #if 1
1264 /* FIXME - How to detect whether SHIFT+TAB or just TAB has been pressed?
1265 * The problem is we could get this message without keyboard input, too
1267 Focus = SYSLINK_GetFocusLink(infoPtr, NULL);
1269 if(Focus == NULL && (Focus = SYSLINK_GetNextLink(infoPtr, NULL)))
1271 SYSLINK_SetFocusLink(infoPtr, Focus);
1273 #else
1274 /* This is a temporary hack since I'm not really sure how to detect which link to select.
1275 See message above! */
1276 Focus = SYSLINK_GetNextLink(infoPtr, NULL);
1277 if(Focus != NULL)
1279 SYSLINK_SetFocusLink(infoPtr, Focus);
1281 #endif
1283 SYSLINK_RepaintLink(infoPtr, Focus);
1285 return 0;
1288 /***********************************************************************
1289 * SYSLINK_KillFocus
1290 * Handles losing the input focus.
1292 static LRESULT SYSLINK_KillFocus (SYSLINK_INFO *infoPtr, HWND NewFocusWindow)
1294 PDOC_ITEM Focus;
1296 infoPtr->HasFocus = FALSE;
1297 Focus = SYSLINK_GetFocusLink(infoPtr, NULL);
1299 if(Focus != NULL)
1301 SYSLINK_RepaintLink(infoPtr, Focus);
1304 return 0;
1307 /***********************************************************************
1308 * SYSLINK_LinkAtPt
1309 * Returns a link at the specified position
1311 static PDOC_ITEM SYSLINK_LinkAtPt (SYSLINK_INFO *infoPtr, POINT *pt, int *LinkId, BOOL MustBeEnabled)
1313 PDOC_ITEM Current;
1314 int id = 0;
1316 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
1318 if((Current->Type == slLink) && (Current->u.Link.hRgn != NULL) &&
1319 PtInRegion(Current->u.Link.hRgn, pt->x, pt->y) &&
1320 (!MustBeEnabled || (MustBeEnabled && (Current->u.Link.state & LIS_ENABLED))))
1322 if(LinkId != NULL)
1324 *LinkId = id;
1326 return Current;
1328 id++;
1331 return NULL;
1334 /***********************************************************************
1335 * SYSLINK_LButtonDown
1336 * Handles mouse clicks
1338 static LRESULT SYSLINK_LButtonDown (SYSLINK_INFO *infoPtr, DWORD Buttons, POINT *pt)
1340 PDOC_ITEM Current, Old;
1341 int id;
1343 Current = SYSLINK_LinkAtPt(infoPtr, pt, &id, TRUE);
1344 if(Current != NULL)
1346 Old = SYSLINK_SetFocusLink(infoPtr, Current);
1347 if(Old != NULL && Old != Current)
1349 SYSLINK_RepaintLink(infoPtr, Old);
1351 infoPtr->MouseDownID = id;
1352 SYSLINK_RepaintLink(infoPtr, Current);
1353 SetFocus(infoPtr->Self);
1356 return 0;
1359 /***********************************************************************
1360 * SYSLINK_LButtonUp
1361 * Handles mouse clicks
1363 static LRESULT SYSLINK_LButtonUp (SYSLINK_INFO *infoPtr, DWORD Buttons, POINT *pt)
1365 if(infoPtr->MouseDownID > -1)
1367 PDOC_ITEM Current;
1368 int id;
1370 Current = SYSLINK_LinkAtPt(infoPtr, pt, &id, TRUE);
1371 if((Current != NULL) && (Current->u.Link.state & LIS_FOCUSED) && (infoPtr->MouseDownID == id))
1373 SYSLINK_SendParentNotify(infoPtr, NM_CLICK, Current, id);
1377 infoPtr->MouseDownID = -1;
1379 return 0;
1382 /***********************************************************************
1383 * SYSLINK_OnEnter
1384 * Handles ENTER key events
1386 static BOOL SYSLINK_OnEnter (SYSLINK_INFO *infoPtr)
1388 if(infoPtr->HasFocus)
1390 PDOC_ITEM Focus;
1391 int id;
1393 Focus = SYSLINK_GetFocusLink(infoPtr, &id);
1394 if(Focus != NULL)
1396 SYSLINK_SendParentNotify(infoPtr, NM_RETURN, Focus, id);
1397 return TRUE;
1400 return FALSE;
1403 /***********************************************************************
1404 * SYSKEY_SelectNextPrevLink
1405 * Changes the currently focused link
1407 static BOOL SYSKEY_SelectNextPrevLink (SYSLINK_INFO *infoPtr, BOOL Prev)
1409 if(infoPtr->HasFocus)
1411 PDOC_ITEM Focus;
1412 int id;
1414 Focus = SYSLINK_GetFocusLink(infoPtr, &id);
1415 if(Focus != NULL)
1417 PDOC_ITEM NewFocus, OldFocus;
1419 if(Prev)
1420 NewFocus = SYSLINK_GetPrevLink(infoPtr, Focus);
1421 else
1422 NewFocus = SYSLINK_GetNextLink(infoPtr, Focus);
1424 if(NewFocus != NULL)
1426 OldFocus = SYSLINK_SetFocusLink(infoPtr, NewFocus);
1428 if(OldFocus != NewFocus)
1430 SYSLINK_RepaintLink(infoPtr, OldFocus);
1432 SYSLINK_RepaintLink(infoPtr, NewFocus);
1433 return TRUE;
1437 return FALSE;
1440 /***********************************************************************
1441 * SYSKEY_SelectNextPrevLink
1442 * Determines if there's a next or previous link to decide whether the control
1443 * should capture the tab key message
1445 static BOOL SYSLINK_NoNextLink (SYSLINK_INFO *infoPtr, BOOL Prev)
1447 PDOC_ITEM Focus, NewFocus;
1449 Focus = SYSLINK_GetFocusLink(infoPtr, NULL);
1450 if(Prev)
1451 NewFocus = SYSLINK_GetPrevLink(infoPtr, Focus);
1452 else
1453 NewFocus = SYSLINK_GetNextLink(infoPtr, Focus);
1455 return NewFocus == NULL;
1458 /***********************************************************************
1459 * SysLinkWindowProc
1461 static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message,
1462 WPARAM wParam, LPARAM lParam)
1464 SYSLINK_INFO *infoPtr;
1466 TRACE("hwnd=%p msg=%04x wparam=%x lParam=%lx\n", hwnd, message, wParam, lParam);
1468 infoPtr = (SYSLINK_INFO *)GetWindowLongPtrW(hwnd, 0);
1470 if (!infoPtr && message != WM_CREATE)
1471 return DefWindowProcW( hwnd, message, wParam, lParam );
1473 switch(message) {
1474 case WM_PAINT:
1475 return SYSLINK_Paint (infoPtr);
1477 case WM_SETCURSOR:
1479 LHITTESTINFO ht;
1480 POINTS pt;
1481 DWORD mp = GetMessagePos();
1483 pt = MAKEPOINTS(mp);
1484 ht.pt.x = pt.x;
1485 ht.pt.y = pt.y;
1487 ScreenToClient(infoPtr->Self, &ht.pt);
1488 if(SYSLINK_HitTest (infoPtr, &ht))
1490 SetCursor(LoadCursorW(0, (LPCWSTR)IDC_HAND));
1491 return TRUE;
1493 /* let the default window proc handle this message */
1494 return DefWindowProcW(hwnd, message, wParam, lParam);
1498 case WM_SIZE:
1500 HDC hdc = GetDC(infoPtr->Self);
1501 if(hdc != NULL)
1503 SYSLINK_Render(infoPtr, hdc);
1504 ReleaseDC(infoPtr->Self, hdc);
1506 return 0;
1509 case WM_GETFONT:
1510 return (LRESULT)infoPtr->Font;
1512 case WM_SETFONT:
1513 return (LRESULT)SYSLINK_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
1515 case WM_SETTEXT:
1516 SYSLINK_SetText(infoPtr, (LPWSTR)lParam);
1517 return DefWindowProcW(hwnd, message, wParam, lParam);
1519 case WM_LBUTTONDOWN:
1521 POINT pt;
1522 pt.x = LOWORD(lParam);
1523 pt.y = HIWORD(lParam);
1524 return SYSLINK_LButtonDown(infoPtr, wParam, &pt);
1526 case WM_LBUTTONUP:
1528 POINT pt;
1529 pt.x = LOWORD(lParam);
1530 pt.y = HIWORD(lParam);
1531 return SYSLINK_LButtonUp(infoPtr, wParam, &pt);
1534 case WM_KEYDOWN:
1536 switch(wParam)
1538 case VK_RETURN:
1539 SYSLINK_OnEnter(infoPtr);
1540 return 0;
1541 case VK_TAB:
1543 BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
1544 SYSKEY_SelectNextPrevLink(infoPtr, shift);
1545 return 0;
1548 return DefWindowProcW(hwnd, message, wParam, lParam);
1551 case WM_GETDLGCODE:
1553 LRESULT Ret = DLGC_HASSETSEL;
1554 int vk = (lParam != 0 ? (int)((LPMSG)lParam)->wParam : 0);
1555 switch(vk)
1557 case VK_RETURN:
1558 Ret |= DLGC_WANTMESSAGE;
1559 break;
1560 case VK_TAB:
1562 BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
1563 if(!SYSLINK_NoNextLink(infoPtr, shift))
1565 Ret |= DLGC_WANTTAB;
1567 else
1569 Ret |= DLGC_WANTCHARS;
1571 break;
1574 return Ret;
1577 case WM_NCHITTEST:
1579 POINT pt;
1580 RECT rc;
1581 pt.x = LOWORD(lParam);
1582 pt.y = HIWORD(lParam);
1584 GetClientRect(infoPtr->Self, &rc);
1585 ScreenToClient(infoPtr->Self, &pt);
1586 if(pt.x < 0 || pt.y < 0 || pt.x > rc.right || pt.y > rc.bottom)
1588 return HTNOWHERE;
1591 if(SYSLINK_LinkAtPt(infoPtr, &pt, NULL, FALSE))
1593 return HTCLIENT;
1596 return HTTRANSPARENT;
1599 case LM_HITTEST:
1600 return SYSLINK_HitTest(infoPtr, (PLHITTESTINFO)lParam);
1602 case LM_SETITEM:
1603 return SYSLINK_SetItem(infoPtr, (PLITEM)lParam);
1605 case LM_GETITEM:
1606 return SYSLINK_GetItem(infoPtr, (PLITEM)lParam);
1608 case LM_GETIDEALHEIGHT:
1609 return SYSLINK_GetIdealHeight(infoPtr);
1611 case WM_SETFOCUS:
1612 return SYSLINK_SetFocus(infoPtr, (HWND)wParam);
1614 case WM_KILLFOCUS:
1615 return SYSLINK_KillFocus(infoPtr, (HWND)wParam);
1617 case WM_CREATE:
1618 /* allocate memory for info struct */
1619 infoPtr = (SYSLINK_INFO *)SYSLINK_Alloc (sizeof(SYSLINK_INFO));
1620 if (!infoPtr) return -1;
1621 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
1623 /* initialize the info struct */
1624 infoPtr->Self = hwnd;
1625 infoPtr->Font = 0;
1626 infoPtr->LinkFont = 0;
1627 infoPtr->Items = NULL;
1628 infoPtr->HasFocus = FALSE;
1629 infoPtr->MouseDownID = -1;
1630 infoPtr->TextColor = GetSysColor(COLOR_WINDOWTEXT);
1631 infoPtr->LinkColor = GetSysColor(COLOR_HIGHLIGHT);
1632 infoPtr->VisitedColor = GetSysColor(COLOR_HIGHLIGHT);
1633 TRACE("SysLink Ctrl creation, hwnd=%p\n", hwnd);
1634 lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
1635 SYSLINK_SetText(infoPtr, (LPWSTR)lParam);
1636 return 0;
1638 case WM_DESTROY:
1639 TRACE("SysLink Ctrl destruction, hwnd=%p\n", hwnd);
1640 SYSLINK_ClearDoc(infoPtr);
1641 SYSLINK_Free (infoPtr);
1642 SetWindowLongPtrW(hwnd, 0, 0);
1643 return 0;
1645 default:
1646 if ((message >= WM_USER) && (message < WM_APP))
1647 ERR("unknown msg %04x wp=%04x lp=%08lx\n", message, wParam, lParam );
1648 return DefWindowProcW(hwnd, message, wParam, lParam);
1653 /***********************************************************************
1654 * SYSLINK_Register [Internal]
1656 * Registers the SysLink window class.
1658 VOID SYSLINK_Register (void)
1660 WNDCLASSW wndClass;
1662 ZeroMemory (&wndClass, sizeof(wndClass));
1663 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1664 wndClass.lpfnWndProc = (WNDPROC)SysLinkWindowProc;
1665 wndClass.cbClsExtra = 0;
1666 wndClass.cbWndExtra = sizeof (SYSLINK_INFO *);
1667 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
1668 wndClass.lpszClassName = WC_LINK;
1670 RegisterClassW (&wndClass);
1674 /***********************************************************************
1675 * SYSLINK_Unregister [Internal]
1677 * Unregisters the SysLink window class.
1679 VOID SYSLINK_Unregister (void)
1681 UnregisterClassW (WC_LINK, NULL);