comctl32: Invalidate the entire progress bar any time it changes.
[wine/multimedia.git] / dlls / comctl32 / syslink.c
blob24d567e86747639ba2a78be25dc5d6021eec2478
1 /*
2 * SysLink control
4 * Copyright 2004 - 2006 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 * NOTES
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Apr. 4, 2005, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
30 #include <stdarg.h>
31 #include <string.h>
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "winnls.h"
37 #include "commctrl.h"
38 #include "comctl32.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(progress);
44 INT WINAPI StrCmpNIW(LPCWSTR,LPCWSTR,INT);
46 typedef struct
48 int nChars;
49 int nSkip;
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 UINT nText; /* Number of characters of the text */
66 SL_ITEM_TYPE Type; /* type of the item */
67 PDOC_TEXTBLOCK Blocks; /* Array of text blocks */
68 union
70 struct
72 UINT state; /* Link state */
73 WCHAR *szID; /* Link ID string */
74 WCHAR *szUrl; /* Link URL string */
75 } Link;
76 struct
78 UINT Dummy;
79 } Text;
80 } u;
81 WCHAR Text[1]; /* Text of the document item */
82 } DOC_ITEM, *PDOC_ITEM;
84 typedef struct
86 HWND Self; /* The window handle for this control */
87 HWND Notify; /* The parent handle to receive notifications */
88 DWORD Style; /* Styles for this control */
89 PDOC_ITEM Items; /* Address to the first document item */
90 BOOL HasFocus; /* Whether the control has the input focus */
91 int MouseDownID; /* ID of the link that the mouse button first selected */
92 HFONT Font; /* Handle to the font for text */
93 HFONT LinkFont; /* Handle to the font for links */
94 COLORREF TextColor; /* Color of the text */
95 COLORREF LinkColor; /* Color of links */
96 COLORREF VisitedColor; /* Color of visited links */
97 WCHAR BreakChar; /* Break Character for the current font */
98 } SYSLINK_INFO;
100 static const WCHAR SL_LINKOPEN[] = { '<','a', 0 };
101 static const WCHAR SL_HREF[] = { 'h','r','e','f','=','\"',0 };
102 static const WCHAR SL_ID[] = { 'i','d','=','\"',0 };
103 static const WCHAR SL_LINKCLOSE[] = { '<','/','a','>',0 };
105 /* Control configuration constants */
107 #define SL_LEFTMARGIN (0)
108 #define SL_TOPMARGIN (0)
109 #define SL_RIGHTMARGIN (0)
110 #define SL_BOTTOMMARGIN (0)
112 /***********************************************************************
113 * SYSLINK_FreeDocItem
114 * Frees all data and gdi objects associated with a document item
116 static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem)
118 if(DocItem->Type == slLink)
120 if (DocItem->u.Link.szID != NULL)
122 Free(DocItem->u.Link.szID);
124 if (DocItem->u.Link.szUrl != NULL)
126 Free(DocItem->u.Link.szUrl);
130 /* we don't free Text because it's just a pointer to a character in the
131 entire window text string */
133 Free(DocItem);
136 /***********************************************************************
137 * SYSLINK_AppendDocItem
138 * Create and append a new document item.
140 static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPCWSTR Text, UINT textlen,
141 SL_ITEM_TYPE type, PDOC_ITEM LastItem)
143 PDOC_ITEM Item;
145 textlen = min(textlen, lstrlenW(Text));
146 Item = Alloc(FIELD_OFFSET(DOC_ITEM, Text[textlen + 1]));
147 if(Item == NULL)
149 ERR("Failed to alloc DOC_ITEM structure!\n");
150 return NULL;
153 Item->Next = NULL;
154 Item->nText = textlen;
155 Item->Type = type;
156 Item->Blocks = NULL;
158 if(LastItem != NULL)
160 LastItem->Next = Item;
162 else
164 infoPtr->Items = Item;
167 lstrcpynW(Item->Text, Text, textlen + 1);
169 return Item;
172 /***********************************************************************
173 * SYSLINK_ClearDoc
174 * Clears the document tree
176 static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr)
178 PDOC_ITEM Item, Next;
180 Item = infoPtr->Items;
181 while(Item != NULL)
183 Next = Item->Next;
184 SYSLINK_FreeDocItem(Item);
185 Item = Next;
188 infoPtr->Items = NULL;
191 /***********************************************************************
192 * SYSLINK_ParseText
193 * Parses the window text string and creates a document. Returns the
194 * number of document items created.
196 static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
198 LPCWSTR current, textstart = NULL, linktext = NULL, firsttag = NULL;
199 int taglen = 0, textlen = 0, linklen = 0, docitems = 0;
200 PDOC_ITEM Last = NULL;
201 SL_ITEM_TYPE CurrentType = slText;
202 LPCWSTR lpID, lpUrl;
203 UINT lenId, lenUrl;
205 for(current = Text; *current != 0;)
207 if(*current == '<')
209 if(!StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText))
211 BOOL ValidParam = FALSE, ValidLink = FALSE;
213 if(*(current + 2) == '>')
215 /* we just have to deal with a <a> tag */
216 taglen = 3;
217 ValidLink = TRUE;
218 ValidParam = TRUE;
219 firsttag = current;
220 linklen = 0;
221 lpID = NULL;
222 lpUrl = NULL;
224 else if(*(current + 2) == infoPtr->BreakChar)
226 /* we expect parameters, parse them */
227 LPCWSTR *CurrentParameter = NULL, tmp;
228 UINT *CurrentParameterLen = NULL;
230 taglen = 3;
231 tmp = current + taglen;
232 lpID = NULL;
233 lpUrl = NULL;
235 CheckParameter:
236 /* compare the current position with all known parameters */
237 if(!StrCmpNIW(tmp, SL_HREF, 6))
239 taglen += 6;
240 ValidParam = TRUE;
241 CurrentParameter = &lpUrl;
242 CurrentParameterLen = &lenUrl;
244 else if(!StrCmpNIW(tmp, SL_ID, 4))
246 taglen += 4;
247 ValidParam = TRUE;
248 CurrentParameter = &lpID;
249 CurrentParameterLen = &lenId;
251 else
253 ValidParam = FALSE;
256 if(ValidParam)
258 /* we got a known parameter, now search until the next " character.
259 If we can't find a " character, there's a syntax error and we just assume it's text */
260 ValidParam = FALSE;
261 *CurrentParameter = current + taglen;
262 *CurrentParameterLen = 0;
264 for(tmp = *CurrentParameter; *tmp != 0; tmp++)
266 taglen++;
267 if(*tmp == '\"')
269 ValidParam = TRUE;
270 tmp++;
271 break;
273 (*CurrentParameterLen)++;
276 if(ValidParam)
278 /* we're done with this parameter, now there are only 2 possibilities:
279 * 1. another parameter is coming, so expect a ' ' (space) character
280 * 2. the tag is being closed, so expect a '<' character
282 if(*tmp == infoPtr->BreakChar)
284 /* we expect another parameter, do the whole thing again */
285 taglen++;
286 tmp++;
287 goto CheckParameter;
289 else if(*tmp == '>')
291 /* the tag is being closed, we're done */
292 ValidLink = TRUE;
293 taglen++;
295 else
296 tmp++;
300 if(ValidLink && ValidParam)
302 /* the <a ...> tag appears to be valid. save all information
303 so we can add the link if we find a valid </a> tag later */
304 CurrentType = slLink;
305 linktext = current + taglen;
306 linklen = 0;
307 firsttag = current;
309 else
311 taglen = 1;
312 lpID = NULL;
313 lpUrl = NULL;
314 if(textstart == NULL)
316 textstart = current;
320 else if(!StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag)
322 /* there's a <a...> tag opened, first add the previous text, if present */
323 if(textstart != NULL && textlen > 0 && firsttag > textstart)
325 Last = SYSLINK_AppendDocItem(infoPtr, textstart, firsttag - textstart, slText, Last);
326 if(Last == NULL)
328 ERR("Unable to create new document item!\n");
329 return docitems;
331 docitems++;
332 textstart = NULL;
333 textlen = 0;
336 /* now it's time to add the link to the document */
337 current += 4;
338 if(linktext != NULL && linklen > 0)
340 Last = SYSLINK_AppendDocItem(infoPtr, linktext, linklen, slLink, Last);
341 if(Last == NULL)
343 ERR("Unable to create new document item!\n");
344 return docitems;
346 docitems++;
347 if(CurrentType == slLink)
349 int nc;
351 if(!(infoPtr->Style & WS_DISABLED))
353 Last->u.Link.state |= LIS_ENABLED;
355 /* Copy the tag parameters */
356 if(lpID != NULL)
358 nc = min(lenId, strlenW(lpID));
359 nc = min(nc, MAX_LINKID_TEXT - 1);
360 Last->u.Link.szID = Alloc((nc + 1) * sizeof(WCHAR));
361 if(Last->u.Link.szID != NULL)
363 lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
366 else
367 Last->u.Link.szID = NULL;
368 if(lpUrl != NULL)
370 nc = min(lenUrl, strlenW(lpUrl));
371 nc = min(nc, L_MAX_URL_LENGTH - 1);
372 Last->u.Link.szUrl = Alloc((nc + 1) * sizeof(WCHAR));
373 if(Last->u.Link.szUrl != NULL)
375 lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
378 else
379 Last->u.Link.szUrl = NULL;
381 linktext = NULL;
383 CurrentType = slText;
384 firsttag = NULL;
385 textstart = NULL;
386 continue;
388 else
390 /* we don't know what tag it is, so just continue */
391 taglen = 1;
392 linklen++;
393 if(CurrentType == slText && textstart == NULL)
395 textstart = current;
399 textlen += taglen;
400 current += taglen;
402 else
404 textlen++;
405 linklen++;
407 /* save the pointer of the current text item if we couldn't find a tag */
408 if(textstart == NULL && CurrentType == slText)
410 textstart = current;
413 current++;
417 if(textstart != NULL && textlen > 0)
419 Last = SYSLINK_AppendDocItem(infoPtr, textstart, textlen, CurrentType, Last);
420 if(Last == NULL)
422 ERR("Unable to create new document item!\n");
423 return docitems;
425 if(CurrentType == slLink)
427 int nc;
429 if(!(infoPtr->Style & WS_DISABLED))
431 Last->u.Link.state |= LIS_ENABLED;
433 /* Copy the tag parameters */
434 if(lpID != NULL)
436 nc = min(lenId, strlenW(lpID));
437 nc = min(nc, MAX_LINKID_TEXT - 1);
438 Last->u.Link.szID = Alloc((nc + 1) * sizeof(WCHAR));
439 if(Last->u.Link.szID != NULL)
441 lstrcpynW(Last->u.Link.szID, lpID, nc + 1);
444 else
445 Last->u.Link.szID = NULL;
446 if(lpUrl != NULL)
448 nc = min(lenUrl, strlenW(lpUrl));
449 nc = min(nc, L_MAX_URL_LENGTH - 1);
450 Last->u.Link.szUrl = Alloc((nc + 1) * sizeof(WCHAR));
451 if(Last->u.Link.szUrl != NULL)
453 lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1);
456 else
457 Last->u.Link.szUrl = NULL;
459 docitems++;
462 if(linktext != NULL && linklen > 0)
464 /* we got an unclosed link, just display the text */
465 Last = SYSLINK_AppendDocItem(infoPtr, linktext, linklen, slText, Last);
466 if(Last == NULL)
468 ERR("Unable to create new document item!\n");
469 return docitems;
471 docitems++;
474 return docitems;
477 /***********************************************************************
478 * SYSLINK_RepaintLink
479 * Repaints a link.
481 static VOID SYSLINK_RepaintLink (SYSLINK_INFO *infoPtr, PDOC_ITEM DocItem)
483 PDOC_TEXTBLOCK bl;
484 int n;
486 if(DocItem->Type != slLink)
488 ERR("DocItem not a link!\n");
489 return;
492 bl = DocItem->Blocks;
493 if (bl != NULL)
495 n = DocItem->nText;
497 while(n > 0)
499 InvalidateRect(infoPtr->Self, &bl->rc, TRUE);
500 n -= bl->nChars + bl->nSkip;
501 bl++;
506 /***********************************************************************
507 * SYSLINK_GetLinkItemByIndex
508 * Retrieves a document link by its index
510 static PDOC_ITEM SYSLINK_GetLinkItemByIndex (SYSLINK_INFO *infoPtr, int iLink)
512 PDOC_ITEM Current = infoPtr->Items;
514 while(Current != NULL)
516 if((Current->Type == slLink) && (iLink-- <= 0))
518 return Current;
520 Current = Current->Next;
522 return NULL;
525 /***********************************************************************
526 * SYSLINK_GetFocusLink
527 * Retrieves the link that has the LIS_FOCUSED bit
529 static PDOC_ITEM SYSLINK_GetFocusLink (SYSLINK_INFO *infoPtr, int *LinkId)
531 PDOC_ITEM Current = infoPtr->Items;
532 int id = 0;
534 while(Current != NULL)
536 if((Current->Type == slLink))
538 if(Current->u.Link.state & LIS_FOCUSED)
540 if(LinkId != NULL)
541 *LinkId = id;
542 return Current;
544 id++;
546 Current = Current->Next;
548 return NULL;
551 /***********************************************************************
552 * SYSLINK_GetNextLink
553 * Gets the next link
555 static PDOC_ITEM SYSLINK_GetNextLink (SYSLINK_INFO *infoPtr, PDOC_ITEM Current)
557 for(Current = (Current != NULL ? Current->Next : infoPtr->Items);
558 Current != NULL;
559 Current = Current->Next)
561 if(Current->Type == slLink)
563 return Current;
566 return NULL;
569 /***********************************************************************
570 * SYSLINK_GetPrevLink
571 * Gets the previous link
573 static PDOC_ITEM SYSLINK_GetPrevLink (SYSLINK_INFO *infoPtr, PDOC_ITEM Current)
575 if(Current == NULL)
577 /* returns the last link */
578 PDOC_ITEM Last = NULL;
580 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
582 if(Current->Type == slLink)
584 Last = Current;
587 return Last;
589 else
591 /* returns the previous link */
592 PDOC_ITEM Cur, Prev = NULL;
594 for(Cur = infoPtr->Items; Cur != NULL; Cur = Cur->Next)
596 if(Cur == Current)
598 break;
600 if(Cur->Type == slLink)
602 Prev = Cur;
605 return Prev;
609 /***********************************************************************
610 * SYSLINK_WrapLine
611 * Tries to wrap a line.
613 static BOOL SYSLINK_WrapLine (HDC hdc, LPWSTR Text, WCHAR BreakChar, int *LineLen,
614 int nFit, LPSIZE Extent, int Width)
616 WCHAR *Current;
618 if(nFit == *LineLen)
620 return FALSE;
623 *LineLen = nFit;
625 Current = Text + nFit;
627 /* check if we're in the middle of a word */
628 if((*Current) != BreakChar)
630 /* search for the beginning of the word */
631 while(Current > Text && (*(Current - 1)) != BreakChar)
633 Current--;
634 (*LineLen)--;
637 if((*LineLen) == 0)
639 Extent->cx = 0;
640 Extent->cy = 0;
642 return TRUE;
645 return TRUE;
648 /***********************************************************************
649 * SYSLINK_Render
650 * Renders the document in memory
652 static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
654 RECT rc;
655 PDOC_ITEM Current;
656 HGDIOBJ hOldFont;
657 int x, y, LineHeight;
659 GetClientRect(infoPtr->Self, &rc);
660 rc.right -= SL_RIGHTMARGIN;
661 rc.bottom -= SL_BOTTOMMARGIN;
663 if(rc.right - SL_LEFTMARGIN < 0 || rc.bottom - SL_TOPMARGIN < 0) return;
665 hOldFont = SelectObject(hdc, infoPtr->Font);
667 x = SL_LEFTMARGIN;
668 y = SL_TOPMARGIN;
669 LineHeight = 0;
671 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
673 int n, nBlocks;
674 LPWSTR tx;
675 PDOC_TEXTBLOCK bl, cbl;
676 INT nFit;
677 SIZE szDim;
679 if(Current->nText == 0)
681 continue;
684 tx = Current->Text;
685 n = Current->nText;
687 if (Current->Blocks != NULL)
689 Free(Current->Blocks);
690 Current->Blocks = NULL;
692 bl = NULL;
693 nBlocks = 0;
695 if(Current->Type == slText)
697 SelectObject(hdc, infoPtr->Font);
699 else if(Current->Type == slLink)
701 SelectObject(hdc, infoPtr->LinkFont);
704 while(n > 0)
706 int SkipChars = 0;
708 /* skip break characters unless they're the first of the doc item */
709 if(tx != Current->Text || x == SL_LEFTMARGIN)
711 while(n > 0 && (*tx) == infoPtr->BreakChar)
713 tx++;
714 SkipChars++;
715 n--;
719 if((n == 0 && SkipChars != 0) ||
720 GetTextExtentExPointW(hdc, tx, n, rc.right - x, &nFit, NULL, &szDim))
722 int LineLen = n;
723 BOOL Wrap = FALSE;
725 if(n != 0)
727 Wrap = SYSLINK_WrapLine(hdc, tx, infoPtr->BreakChar, &LineLen, nFit, &szDim, rc.right - x);
729 if(LineLen == 0)
731 if(x > SL_LEFTMARGIN)
733 /* move one line down, the word didn't fit into the line */
734 x = SL_LEFTMARGIN;
735 y += LineHeight;
736 LineHeight = 0;
737 continue;
739 else
741 /* the word starts at the beginning of the line and doesn't
742 fit into the line, so break it at the last character that fits */
743 LineLen = max(nFit, 1);
747 if(LineLen != n)
749 if(!GetTextExtentExPointW(hdc, tx, LineLen, rc.right - x, NULL, NULL, &szDim))
751 if(bl != NULL)
753 Free(bl);
754 bl = NULL;
755 nBlocks = 0;
757 break;
762 if(bl != NULL)
764 PDOC_TEXTBLOCK nbl = ReAlloc(bl, (nBlocks + 1) * sizeof(DOC_TEXTBLOCK));
765 if (nbl != NULL)
767 bl = nbl;
768 nBlocks++;
770 else
772 Free(bl);
773 bl = NULL;
774 nBlocks = 0;
777 else
779 bl = Alloc(sizeof(DOC_TEXTBLOCK));
780 if (bl != NULL)
781 nBlocks++;
784 if(bl != NULL)
786 cbl = bl + nBlocks - 1;
788 cbl->nChars = LineLen;
789 cbl->nSkip = SkipChars;
790 cbl->rc.left = x;
791 cbl->rc.top = y;
792 cbl->rc.right = x + szDim.cx;
793 cbl->rc.bottom = y + szDim.cy;
795 if(LineLen != 0)
797 x += szDim.cx;
798 LineHeight = max(LineHeight, szDim.cy);
800 if(Wrap)
802 x = SL_LEFTMARGIN;
803 y += LineHeight;
804 LineHeight = 0;
808 else
810 ERR("Failed to alloc DOC_TEXTBLOCK structure!\n");
811 break;
813 n -= LineLen;
814 tx += LineLen;
816 else
818 n--;
822 if(nBlocks != 0)
824 Current->Blocks = bl;
828 SelectObject(hdc, hOldFont);
831 /***********************************************************************
832 * SYSLINK_Draw
833 * Draws the SysLink control.
835 static LRESULT SYSLINK_Draw (SYSLINK_INFO *infoPtr, HDC hdc)
837 RECT rc;
838 PDOC_ITEM Current;
839 HFONT hOldFont;
840 COLORREF OldTextColor, OldBkColor;
842 hOldFont = SelectObject(hdc, infoPtr->Font);
843 OldTextColor = SetTextColor(hdc, infoPtr->TextColor);
844 OldBkColor = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
846 GetClientRect(infoPtr->Self, &rc);
847 rc.right -= SL_RIGHTMARGIN + SL_LEFTMARGIN;
848 rc.bottom -= SL_BOTTOMMARGIN + SL_TOPMARGIN;
850 if(rc.right < 0 || rc.bottom < 0) return 0;
852 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
854 int n;
855 LPWSTR tx;
856 PDOC_TEXTBLOCK bl;
858 bl = Current->Blocks;
859 if(bl != NULL)
861 tx = Current->Text;
862 n = Current->nText;
864 if(Current->Type == slText)
866 SelectObject(hdc, infoPtr->Font);
867 SetTextColor(hdc, infoPtr->TextColor);
869 else
871 SelectObject(hdc, infoPtr->LinkFont);
872 SetTextColor(hdc, (!(Current->u.Link.state & LIS_VISITED) ? infoPtr->LinkColor : infoPtr->VisitedColor));
875 while(n > 0)
877 tx += bl->nSkip;
878 ExtTextOutW(hdc, bl->rc.left, bl->rc.top, ETO_OPAQUE | ETO_CLIPPED, &bl->rc, tx, bl->nChars, NULL);
879 if((Current->Type == slLink) && (Current->u.Link.state & LIS_FOCUSED) && infoPtr->HasFocus)
881 COLORREF PrevTextColor;
882 PrevTextColor = SetTextColor(hdc, infoPtr->TextColor);
883 DrawFocusRect(hdc, &bl->rc);
884 SetTextColor(hdc, PrevTextColor);
886 tx += bl->nChars;
887 n -= bl->nChars + bl->nSkip;
888 bl++;
893 SetBkColor(hdc, OldBkColor);
894 SetTextColor(hdc, OldTextColor);
895 SelectObject(hdc, hOldFont);
897 return 0;
901 /***********************************************************************
902 * SYSLINK_Paint
903 * Handles the WM_PAINT message.
905 static LRESULT SYSLINK_Paint (SYSLINK_INFO *infoPtr, HDC hdcParam)
907 HDC hdc;
908 PAINTSTRUCT ps;
910 hdc = hdcParam ? hdcParam : BeginPaint (infoPtr->Self, &ps);
911 if (hdc)
913 SYSLINK_Draw (infoPtr, hdc);
914 if (!hdcParam) EndPaint (infoPtr->Self, &ps);
916 return 0;
920 /***********************************************************************
921 * SYSLINK_SetFont
922 * Set new Font for the SysLink control.
924 static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
926 HDC hdc;
927 LOGFONTW lf;
928 TEXTMETRICW tm;
929 HFONT hOldFont = infoPtr->Font;
930 infoPtr->Font = hFont;
932 /* free the underline font */
933 if(infoPtr->LinkFont != NULL)
935 DeleteObject(infoPtr->LinkFont);
936 infoPtr->LinkFont = NULL;
939 /* Render text position and word wrapping in memory */
940 hdc = GetDC(infoPtr->Self);
941 if(hdc != NULL)
943 /* create a new underline font */
944 if(GetTextMetricsW(hdc, &tm) &&
945 GetObjectW(infoPtr->Font, sizeof(LOGFONTW), &lf))
947 lf.lfUnderline = TRUE;
948 infoPtr->LinkFont = CreateFontIndirectW(&lf);
949 infoPtr->BreakChar = tm.tmBreakChar;
951 else
953 ERR("Failed to create link font!\n");
956 SYSLINK_Render(infoPtr, hdc);
957 ReleaseDC(infoPtr->Self, hdc);
960 if(bRedraw)
962 RedrawWindow(infoPtr->Self, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
965 return hOldFont;
968 /***********************************************************************
969 * SYSLINK_SetText
970 * Set new text for the SysLink control.
972 static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
974 int textlen;
976 /* clear the document */
977 SYSLINK_ClearDoc(infoPtr);
979 if(Text == NULL || (textlen = lstrlenW(Text)) == 0)
981 return TRUE;
984 /* let's parse the string and create a document */
985 if(SYSLINK_ParseText(infoPtr, Text) > 0)
987 /* Render text position and word wrapping in memory */
988 HDC hdc = GetDC(infoPtr->Self);
989 if (hdc != NULL)
991 SYSLINK_Render(infoPtr, hdc);
992 ReleaseDC(infoPtr->Self, hdc);
994 InvalidateRect(infoPtr->Self, NULL, TRUE);
998 return TRUE;
1001 /***********************************************************************
1002 * SYSLINK_SetFocusLink
1003 * Updates the focus status bits and focusses the specified link.
1004 * If no document item is specified, the focus bit will be removed from all links.
1005 * Returns the previous focused item.
1007 static PDOC_ITEM SYSLINK_SetFocusLink (SYSLINK_INFO *infoPtr, PDOC_ITEM DocItem)
1009 PDOC_ITEM Current, PrevFocus = NULL;
1011 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
1013 if(Current->Type == slLink)
1015 if((PrevFocus == NULL) && (Current->u.Link.state & LIS_FOCUSED))
1017 PrevFocus = Current;
1020 if(Current == DocItem)
1022 Current->u.Link.state |= LIS_FOCUSED;
1024 else
1026 Current->u.Link.state &= ~LIS_FOCUSED;
1031 return PrevFocus;
1034 /***********************************************************************
1035 * SYSLINK_SetItem
1036 * Sets the states and attributes of a link item.
1038 static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
1040 PDOC_ITEM di;
1041 int nc;
1042 PWSTR szId = NULL;
1043 PWSTR szUrl = NULL;
1044 BOOL Repaint = FALSE;
1046 if(!(Item->mask & LIF_ITEMINDEX) || !(Item->mask & (LIF_FLAGSMASK)))
1048 ERR("Invalid Flags!\n");
1049 return FALSE;
1052 di = SYSLINK_GetLinkItemByIndex(infoPtr, Item->iLink);
1053 if(di == NULL)
1055 ERR("Link %d couldn't be found\n", Item->iLink);
1056 return FALSE;
1059 if(Item->mask & LIF_ITEMID)
1061 nc = min(lstrlenW(Item->szID), MAX_LINKID_TEXT - 1);
1062 szId = Alloc((nc + 1) * sizeof(WCHAR));
1063 if(szId)
1065 lstrcpynW(szId, Item->szID, nc + 1);
1067 else
1069 ERR("Unable to allocate memory for link id\n");
1070 return FALSE;
1074 if(Item->mask & LIF_URL)
1076 nc = min(lstrlenW(Item->szUrl), L_MAX_URL_LENGTH - 1);
1077 szUrl = Alloc((nc + 1) * sizeof(WCHAR));
1078 if(szUrl)
1080 lstrcpynW(szUrl, Item->szUrl, nc + 1);
1082 else
1084 if (szId)
1086 Free(szId);
1089 ERR("Unable to allocate memory for link url\n");
1090 return FALSE;
1094 if(Item->mask & LIF_ITEMID)
1096 if(di->u.Link.szID)
1098 Free(di->u.Link.szID);
1100 di->u.Link.szID = szId;
1103 if(Item->mask & LIF_URL)
1105 if(di->u.Link.szUrl)
1107 Free(di->u.Link.szUrl);
1109 di->u.Link.szUrl = szUrl;
1112 if(Item->mask & LIF_STATE)
1114 UINT oldstate = di->u.Link.state;
1115 /* clear the masked bits */
1116 di->u.Link.state &= ~(Item->stateMask & LIS_MASK);
1117 /* copy the bits */
1118 di->u.Link.state |= (Item->state & Item->stateMask) & LIS_MASK;
1119 Repaint = (oldstate != di->u.Link.state);
1121 /* update the focus */
1122 SYSLINK_SetFocusLink(infoPtr, ((di->u.Link.state & LIS_FOCUSED) ? di : NULL));
1125 if(Repaint)
1127 SYSLINK_RepaintLink(infoPtr, di);
1130 return TRUE;
1133 /***********************************************************************
1134 * SYSLINK_GetItem
1135 * Retrieves the states and attributes of a link item.
1137 static LRESULT SYSLINK_GetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
1139 PDOC_ITEM di;
1141 if(!(Item->mask & LIF_ITEMINDEX) || !(Item->mask & (LIF_FLAGSMASK)))
1143 ERR("Invalid Flags!\n");
1144 return FALSE;
1147 di = SYSLINK_GetLinkItemByIndex(infoPtr, Item->iLink);
1148 if(di == NULL)
1150 ERR("Link %d couldn't be found\n", Item->iLink);
1151 return FALSE;
1154 if(Item->mask & LIF_STATE)
1156 Item->state = (di->u.Link.state & Item->stateMask);
1157 if(!infoPtr->HasFocus)
1159 /* remove the LIS_FOCUSED bit if the control doesn't have focus */
1160 Item->state &= ~LIS_FOCUSED;
1164 if(Item->mask & LIF_ITEMID)
1166 if(di->u.Link.szID)
1168 lstrcpyW(Item->szID, di->u.Link.szID);
1170 else
1172 Item->szID[0] = 0;
1176 if(Item->mask & LIF_URL)
1178 if(di->u.Link.szUrl)
1180 lstrcpyW(Item->szUrl, di->u.Link.szUrl);
1182 else
1184 Item->szUrl[0] = 0;
1188 return TRUE;
1191 /***********************************************************************
1192 * SYSLINK_PtInDocItem
1193 * Determines if a point is in the region of a document item
1195 static BOOL SYSLINK_PtInDocItem (PDOC_ITEM DocItem, POINT pt)
1197 PDOC_TEXTBLOCK bl;
1198 int n;
1200 bl = DocItem->Blocks;
1201 if (bl != NULL)
1203 n = DocItem->nText;
1205 while(n > 0)
1207 if (PtInRect(&bl->rc, pt))
1209 return TRUE;
1211 n -= bl->nChars + bl->nSkip;
1212 bl++;
1216 return FALSE;
1219 /***********************************************************************
1220 * SYSLINK_HitTest
1221 * Determines the link the user clicked on.
1223 static LRESULT SYSLINK_HitTest (SYSLINK_INFO *infoPtr, PLHITTESTINFO HitTest)
1225 PDOC_ITEM Current;
1226 int id = 0;
1228 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
1230 if(Current->Type == slLink)
1232 if(SYSLINK_PtInDocItem(Current, HitTest->pt))
1234 HitTest->item.mask = 0;
1235 HitTest->item.iLink = id;
1236 HitTest->item.state = 0;
1237 HitTest->item.stateMask = 0;
1238 if(Current->u.Link.szID)
1240 lstrcpyW(HitTest->item.szID, Current->u.Link.szID);
1242 else
1244 HitTest->item.szID[0] = 0;
1246 if(Current->u.Link.szUrl)
1248 lstrcpyW(HitTest->item.szUrl, Current->u.Link.szUrl);
1250 else
1252 HitTest->item.szUrl[0] = 0;
1254 return TRUE;
1256 id++;
1260 return FALSE;
1263 /***********************************************************************
1264 * SYSLINK_GetIdealHeight
1265 * Returns the preferred height of a link at the current control's width.
1267 static LRESULT SYSLINK_GetIdealHeight (SYSLINK_INFO *infoPtr)
1269 HDC hdc = GetDC(infoPtr->Self);
1270 if(hdc != NULL)
1272 LRESULT height;
1273 TEXTMETRICW tm;
1274 HGDIOBJ hOldFont = SelectObject(hdc, infoPtr->Font);
1276 if(GetTextMetricsW(hdc, &tm))
1278 height = tm.tmHeight;
1280 else
1282 height = 0;
1284 SelectObject(hdc, hOldFont);
1285 ReleaseDC(infoPtr->Self, hdc);
1287 return height;
1289 return 0;
1292 /***********************************************************************
1293 * SYSLINK_SendParentNotify
1294 * Sends a WM_NOTIFY message to the parent window.
1296 static LRESULT SYSLINK_SendParentNotify (SYSLINK_INFO *infoPtr, UINT code, PDOC_ITEM Link, int iLink)
1298 NMLINK nml;
1300 nml.hdr.hwndFrom = infoPtr->Self;
1301 nml.hdr.idFrom = GetWindowLongPtrW(infoPtr->Self, GWLP_ID);
1302 nml.hdr.code = code;
1304 nml.item.mask = 0;
1305 nml.item.iLink = iLink;
1306 nml.item.state = 0;
1307 nml.item.stateMask = 0;
1308 if(Link->u.Link.szID)
1310 lstrcpyW(nml.item.szID, Link->u.Link.szID);
1312 else
1314 nml.item.szID[0] = 0;
1316 if(Link->u.Link.szUrl)
1318 lstrcpyW(nml.item.szUrl, Link->u.Link.szUrl);
1320 else
1322 nml.item.szUrl[0] = 0;
1325 return SendMessageW(infoPtr->Notify, WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml);
1328 /***********************************************************************
1329 * SYSLINK_SetFocus
1330 * Handles receiving the input focus.
1332 static LRESULT SYSLINK_SetFocus (SYSLINK_INFO *infoPtr, HWND PrevFocusWindow)
1334 PDOC_ITEM Focus;
1336 infoPtr->HasFocus = TRUE;
1338 /* We always select the first link, even if we activated the control using
1339 SHIFT+TAB. This is the default behavior */
1340 Focus = SYSLINK_GetNextLink(infoPtr, NULL);
1341 if(Focus != NULL)
1343 SYSLINK_SetFocusLink(infoPtr, Focus);
1346 SYSLINK_RepaintLink(infoPtr, Focus);
1348 return 0;
1351 /***********************************************************************
1352 * SYSLINK_KillFocus
1353 * Handles losing the input focus.
1355 static LRESULT SYSLINK_KillFocus (SYSLINK_INFO *infoPtr, HWND NewFocusWindow)
1357 PDOC_ITEM Focus;
1359 infoPtr->HasFocus = FALSE;
1360 Focus = SYSLINK_GetFocusLink(infoPtr, NULL);
1362 if(Focus != NULL)
1364 SYSLINK_RepaintLink(infoPtr, Focus);
1367 return 0;
1370 /***********************************************************************
1371 * SYSLINK_LinkAtPt
1372 * Returns a link at the specified position
1374 static PDOC_ITEM SYSLINK_LinkAtPt (SYSLINK_INFO *infoPtr, POINT *pt, int *LinkId, BOOL MustBeEnabled)
1376 PDOC_ITEM Current;
1377 int id = 0;
1379 for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
1381 if((Current->Type == slLink) && SYSLINK_PtInDocItem(Current, *pt) &&
1382 (!MustBeEnabled || (MustBeEnabled && (Current->u.Link.state & LIS_ENABLED))))
1384 if(LinkId != NULL)
1386 *LinkId = id;
1388 return Current;
1390 id++;
1393 return NULL;
1396 /***********************************************************************
1397 * SYSLINK_LButtonDown
1398 * Handles mouse clicks
1400 static LRESULT SYSLINK_LButtonDown (SYSLINK_INFO *infoPtr, DWORD Buttons, POINT *pt)
1402 PDOC_ITEM Current, Old;
1403 int id;
1405 Current = SYSLINK_LinkAtPt(infoPtr, pt, &id, TRUE);
1406 if(Current != NULL)
1408 SetFocus(infoPtr->Self);
1410 Old = SYSLINK_SetFocusLink(infoPtr, Current);
1411 if(Old != NULL && Old != Current)
1413 SYSLINK_RepaintLink(infoPtr, Old);
1415 infoPtr->MouseDownID = id;
1416 SYSLINK_RepaintLink(infoPtr, Current);
1419 return 0;
1422 /***********************************************************************
1423 * SYSLINK_LButtonUp
1424 * Handles mouse clicks
1426 static LRESULT SYSLINK_LButtonUp (SYSLINK_INFO *infoPtr, DWORD Buttons, POINT *pt)
1428 if(infoPtr->MouseDownID > -1)
1430 PDOC_ITEM Current;
1431 int id;
1433 Current = SYSLINK_LinkAtPt(infoPtr, pt, &id, TRUE);
1434 if((Current != NULL) && (Current->u.Link.state & LIS_FOCUSED) && (infoPtr->MouseDownID == id))
1436 SYSLINK_SendParentNotify(infoPtr, NM_CLICK, Current, id);
1440 infoPtr->MouseDownID = -1;
1442 return 0;
1445 /***********************************************************************
1446 * SYSLINK_OnEnter
1447 * Handles ENTER key events
1449 static BOOL SYSLINK_OnEnter (SYSLINK_INFO *infoPtr)
1451 if(infoPtr->HasFocus)
1453 PDOC_ITEM Focus;
1454 int id;
1456 Focus = SYSLINK_GetFocusLink(infoPtr, &id);
1457 if(Focus != NULL)
1459 SYSLINK_SendParentNotify(infoPtr, NM_RETURN, Focus, id);
1460 return TRUE;
1463 return FALSE;
1466 /***********************************************************************
1467 * SYSKEY_SelectNextPrevLink
1468 * Changes the currently focused link
1470 static BOOL SYSKEY_SelectNextPrevLink (SYSLINK_INFO *infoPtr, BOOL Prev)
1472 if(infoPtr->HasFocus)
1474 PDOC_ITEM Focus;
1475 int id;
1477 Focus = SYSLINK_GetFocusLink(infoPtr, &id);
1478 if(Focus != NULL)
1480 PDOC_ITEM NewFocus, OldFocus;
1482 if(Prev)
1483 NewFocus = SYSLINK_GetPrevLink(infoPtr, Focus);
1484 else
1485 NewFocus = SYSLINK_GetNextLink(infoPtr, Focus);
1487 if(NewFocus != NULL)
1489 OldFocus = SYSLINK_SetFocusLink(infoPtr, NewFocus);
1491 if(OldFocus != NewFocus)
1493 SYSLINK_RepaintLink(infoPtr, OldFocus);
1495 SYSLINK_RepaintLink(infoPtr, NewFocus);
1496 return TRUE;
1500 return FALSE;
1503 /***********************************************************************
1504 * SYSKEY_SelectNextPrevLink
1505 * Determines if there's a next or previous link to decide whether the control
1506 * should capture the tab key message
1508 static BOOL SYSLINK_NoNextLink (SYSLINK_INFO *infoPtr, BOOL Prev)
1510 PDOC_ITEM Focus, NewFocus;
1512 Focus = SYSLINK_GetFocusLink(infoPtr, NULL);
1513 if(Prev)
1514 NewFocus = SYSLINK_GetPrevLink(infoPtr, Focus);
1515 else
1516 NewFocus = SYSLINK_GetNextLink(infoPtr, Focus);
1518 return NewFocus == NULL;
1521 /***********************************************************************
1522 * SysLinkWindowProc
1524 static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message,
1525 WPARAM wParam, LPARAM lParam)
1527 SYSLINK_INFO *infoPtr;
1529 TRACE("hwnd=%p msg=%04x wparam=%x lParam=%lx\n", hwnd, message, wParam, lParam);
1531 infoPtr = (SYSLINK_INFO *)GetWindowLongPtrW(hwnd, 0);
1533 if (!infoPtr && message != WM_CREATE)
1534 goto HandleDefaultMessage;
1536 switch(message) {
1537 case WM_PRINTCLIENT:
1538 case WM_PAINT:
1539 return SYSLINK_Paint (infoPtr, (HDC)wParam);
1541 case WM_SETCURSOR:
1543 LHITTESTINFO ht;
1544 DWORD mp = GetMessagePos();
1546 ht.pt.x = (short)LOWORD(mp);
1547 ht.pt.y = (short)HIWORD(mp);
1549 ScreenToClient(infoPtr->Self, &ht.pt);
1550 if(SYSLINK_HitTest (infoPtr, &ht))
1552 SetCursor(LoadCursorW(0, (LPCWSTR)IDC_HAND));
1553 return TRUE;
1555 /* let the default window proc handle this message */
1556 goto HandleDefaultMessage;
1559 case WM_SIZE:
1561 HDC hdc = GetDC(infoPtr->Self);
1562 if(hdc != NULL)
1564 SYSLINK_Render(infoPtr, hdc);
1565 ReleaseDC(infoPtr->Self, hdc);
1567 return 0;
1570 case WM_GETFONT:
1571 return (LRESULT)infoPtr->Font;
1573 case WM_SETFONT:
1574 return (LRESULT)SYSLINK_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
1576 case WM_SETTEXT:
1577 SYSLINK_SetText(infoPtr, (LPWSTR)lParam);
1578 goto HandleDefaultMessage;
1580 case WM_LBUTTONDOWN:
1582 POINT pt;
1583 pt.x = LOWORD(lParam);
1584 pt.y = HIWORD(lParam);
1585 return SYSLINK_LButtonDown(infoPtr, wParam, &pt);
1587 case WM_LBUTTONUP:
1589 POINT pt;
1590 pt.x = LOWORD(lParam);
1591 pt.y = HIWORD(lParam);
1592 return SYSLINK_LButtonUp(infoPtr, wParam, &pt);
1595 case WM_KEYDOWN:
1597 switch(wParam)
1599 case VK_RETURN:
1600 SYSLINK_OnEnter(infoPtr);
1601 return 0;
1602 case VK_TAB:
1604 BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
1605 SYSKEY_SelectNextPrevLink(infoPtr, shift);
1606 return 0;
1609 goto HandleDefaultMessage;
1612 case WM_GETDLGCODE:
1614 LRESULT Ret = DLGC_HASSETSEL;
1615 int vk = (lParam != 0 ? (int)((LPMSG)lParam)->wParam : 0);
1616 switch(vk)
1618 case VK_RETURN:
1619 Ret |= DLGC_WANTMESSAGE;
1620 break;
1621 case VK_TAB:
1623 BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
1624 if(!SYSLINK_NoNextLink(infoPtr, shift))
1626 Ret |= DLGC_WANTTAB;
1628 else
1630 Ret |= DLGC_WANTCHARS;
1632 break;
1635 return Ret;
1638 case WM_NCHITTEST:
1640 POINT pt;
1641 RECT rc;
1642 pt.x = LOWORD(lParam);
1643 pt.y = HIWORD(lParam);
1645 GetClientRect(infoPtr->Self, &rc);
1646 ScreenToClient(infoPtr->Self, &pt);
1647 if(pt.x < 0 || pt.y < 0 || pt.x > rc.right || pt.y > rc.bottom)
1649 return HTNOWHERE;
1652 if(SYSLINK_LinkAtPt(infoPtr, &pt, NULL, FALSE))
1654 return HTCLIENT;
1657 return HTTRANSPARENT;
1660 case LM_HITTEST:
1661 return SYSLINK_HitTest(infoPtr, (PLHITTESTINFO)lParam);
1663 case LM_SETITEM:
1664 return SYSLINK_SetItem(infoPtr, (PLITEM)lParam);
1666 case LM_GETITEM:
1667 return SYSLINK_GetItem(infoPtr, (PLITEM)lParam);
1669 case LM_GETIDEALHEIGHT:
1670 return SYSLINK_GetIdealHeight(infoPtr);
1672 case WM_SETFOCUS:
1673 return SYSLINK_SetFocus(infoPtr, (HWND)wParam);
1675 case WM_KILLFOCUS:
1676 return SYSLINK_KillFocus(infoPtr, (HWND)wParam);
1678 case WM_ENABLE:
1679 infoPtr->Style &= ~WS_DISABLED;
1680 infoPtr->Style |= (wParam ? 0 : WS_DISABLED);
1681 InvalidateRect (infoPtr->Self, NULL, FALSE);
1682 return 0;
1684 case WM_STYLECHANGED:
1685 if (wParam == GWL_STYLE)
1687 infoPtr->Style = ((LPSTYLESTRUCT)lParam)->styleNew;
1689 InvalidateRect(infoPtr->Self, NULL, TRUE);
1691 return 0;
1693 case WM_CREATE:
1694 /* allocate memory for info struct */
1695 infoPtr = Alloc (sizeof(SYSLINK_INFO));
1696 if (!infoPtr) return -1;
1697 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
1699 /* initialize the info struct */
1700 infoPtr->Self = hwnd;
1701 infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent;
1702 infoPtr->Style = ((LPCREATESTRUCTW)lParam)->style;
1703 infoPtr->Font = 0;
1704 infoPtr->LinkFont = 0;
1705 infoPtr->Items = NULL;
1706 infoPtr->HasFocus = FALSE;
1707 infoPtr->MouseDownID = -1;
1708 infoPtr->TextColor = GetSysColor(COLOR_WINDOWTEXT);
1709 infoPtr->LinkColor = GetSysColor(COLOR_HIGHLIGHT);
1710 infoPtr->VisitedColor = GetSysColor(COLOR_HIGHLIGHT);
1711 infoPtr->BreakChar = ' ';
1712 TRACE("SysLink Ctrl creation, hwnd=%p\n", hwnd);
1713 SYSLINK_SetText(infoPtr, ((LPCREATESTRUCTW)lParam)->lpszName);
1714 return 0;
1716 case WM_DESTROY:
1717 TRACE("SysLink Ctrl destruction, hwnd=%p\n", hwnd);
1718 SYSLINK_ClearDoc(infoPtr);
1719 if(infoPtr->Font != 0) DeleteObject(infoPtr->Font);
1720 if(infoPtr->LinkFont != 0) DeleteObject(infoPtr->LinkFont);
1721 SetWindowLongPtrW(hwnd, 0, 0);
1722 Free (infoPtr);
1723 return 0;
1725 default:
1726 HandleDefaultMessage:
1727 if ((message >= WM_USER) && (message < WM_APP))
1729 ERR("unknown msg %04x wp=%04x lp=%08lx\n", message, wParam, lParam );
1731 return DefWindowProcW(hwnd, message, wParam, lParam);
1736 /***********************************************************************
1737 * SYSLINK_Register [Internal]
1739 * Registers the SysLink window class.
1741 VOID SYSLINK_Register (void)
1743 WNDCLASSW wndClass;
1745 ZeroMemory (&wndClass, sizeof(wndClass));
1746 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1747 wndClass.lpfnWndProc = SysLinkWindowProc;
1748 wndClass.cbClsExtra = 0;
1749 wndClass.cbWndExtra = sizeof (SYSLINK_INFO *);
1750 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
1751 wndClass.lpszClassName = WC_LINK;
1753 RegisterClassW (&wndClass);
1757 /***********************************************************************
1758 * SYSLINK_Unregister [Internal]
1760 * Unregisters the SysLink window class.
1762 VOID SYSLINK_Unregister (void)
1764 UnregisterClassW (WC_LINK, NULL);