Syslink: audit & cleanups

Dimitrie O. Paun dpaun at rogers.com
Mon Apr 4 21:27:10 CDT 2005


ChangeLog
    Audit the code against Comctl32.dll version 6.0.
    Handle notification and styles as in the other controls.
    Maintain the const for strings throughout parsing.


Index: dlls/comctl32/syslink.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/syslink.c,v
retrieving revision 1.12
diff -u -r1.12 syslink.c
--- dlls/comctl32/syslink.c	30 Mar 2005 17:08:34 -0000	1.12
+++ dlls/comctl32/syslink.c	5 Apr 2005 02:16:51 -0000
@@ -17,11 +17,19 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * NOTES
+ *
+ * This code was audited for completeness against the documented features
+ * of Comctl32.dll version 6.0 on Apr. 4, 2005, by Dimitrie O. Paun.
+ * 
+ * Unless otherwise noted, we believe this code to be complete, as per
+ * the specification mentioned above.
+ * If you discover missing features, or bugs, please note them below.
+ * 
  * TODO:
  * - Fix SHIFT+TAB and TAB issue (wrong link is selected when control gets the focus)
  * - Better string parsing
  * - Improve word wrapping
- * - Control styles?!
  *
  */
 
@@ -82,6 +90,8 @@
 typedef struct
 {
     HWND      Self;         /* The window handle for this control */
+    HWND      Notify;       /* The parent handle to receive notifications */
+    DWORD     Style;        /* Styles for this control */
     PDOC_ITEM Items;        /* Address to the first document item */
     BOOL      HasFocus;     /* Whether the control has the input focus */
     int       MouseDownID;  /* ID of the link that the mouse button first selected */
@@ -131,7 +141,7 @@
  * SYSLINK_AppendDocItem
  * Create and append a new document item.
  */
-static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPWSTR Text, UINT textlen,
+static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPCWSTR Text, UINT textlen,
                                         SL_ITEM_TYPE type, PDOC_ITEM LastItem)
 {
     PDOC_ITEM Item;
@@ -188,25 +198,16 @@
  * Parses the window text string and creates a document. Returns the
  * number of document items created.
  */
-static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPWSTR Text)
+static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
 {
-    WCHAR *current, *textstart, *linktext, *firsttag;
-    int taglen = 0, textlen, linklen, docitems = 0;
+    LPCWSTR current, textstart = NULL, linktext = NULL, firsttag = NULL;
+    int taglen = 0, textlen = 0, linklen = 0, docitems = 0;
     PDOC_ITEM Last = NULL;
     SL_ITEM_TYPE CurrentType = slText;
-    DWORD Style;
-    LPWSTR lpID, lpUrl;
+    LPCWSTR lpID, lpUrl;
     UINT lenId, lenUrl;
 
-    Style = GetWindowLongW(infoPtr->Self, GWL_STYLE);
-
-    firsttag = NULL;
-    textstart = NULL;
-    linktext = NULL;
-    textlen = 0;
-    linklen = 0;
-    
-    for(current = (WCHAR*)Text; *current != 0;)
+    for(current = Text; *current != 0;)
     {
         if(*current == '<')
         {
@@ -229,9 +230,8 @@
                 case ' ':
                 {
                     /* we expect parameters, parse them */
-                    LPWSTR *CurrentParameter = NULL;
+                    LPCWSTR *CurrentParameter = NULL, tmp;
                     UINT *CurrentParameterLen = NULL;
-                    WCHAR *tmp;
 
                     taglen = 3;
                     tmp = current + taglen;
@@ -359,7 +359,7 @@
                     {
                         int nc;
 
-                        if(!(Style & WS_DISABLED))
+                        if(!(infoPtr->Style & WS_DISABLED))
                         {
                             Last->u.Link.state |= LIS_ENABLED;
                         }
@@ -439,7 +439,7 @@
         {
             int nc;
 
-            if(!(Style & WS_DISABLED))
+            if(!(infoPtr->Style & WS_DISABLED))
             {
                 Last->u.Link.state |= LIS_ENABLED;
             }
@@ -937,7 +937,7 @@
  *           SYSLINK_SetText
  * Set new text for the SysLink control.
  */
-static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPWSTR Text)
+static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
 {
     int textlen;
 
@@ -1239,7 +1239,7 @@
         nml.item.szUrl[0] = 0;
     }
 
-    return SendMessageW(GetParent(infoPtr->Self), WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml);
+    return SendMessageW(infoPtr->Notify, WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml);
 }
 
 /***********************************************************************
@@ -1604,6 +1604,21 @@
     case WM_KILLFOCUS:
         return SYSLINK_KillFocus(infoPtr, (HWND)wParam);
 
+    case WM_ENABLE:
+	infoPtr->Style &= ~WS_DISABLED;
+	infoPtr->Style |= (wParam ? 0 : WS_DISABLED);
+	InvalidateRect (infoPtr->Self, NULL, FALSE);
+	return 0;
+
+    case WM_STYLECHANGED:
+        if (wParam == GWL_STYLE)
+        {
+            infoPtr->Style = ((LPSTYLESTRUCT)lParam)->styleNew;
+
+            InvalidateRect(infoPtr->Self, NULL, TRUE);
+        }
+        return 0;
+
     case WM_CREATE:
         /* allocate memory for info struct */
         infoPtr = Alloc (sizeof(SYSLINK_INFO));
@@ -1612,6 +1627,8 @@
 
         /* initialize the info struct */
         infoPtr->Self = hwnd;
+        infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent;
+        infoPtr->Style = ((LPCREATESTRUCTW)lParam)->style;
         infoPtr->Font = 0;
         infoPtr->LinkFont = 0;
         infoPtr->Items = NULL;
@@ -1621,8 +1638,7 @@
         infoPtr->LinkColor = GetSysColor(COLOR_HIGHLIGHT);
         infoPtr->VisitedColor = GetSysColor(COLOR_HIGHLIGHT);
         TRACE("SysLink Ctrl creation, hwnd=%p\n", hwnd);
-        lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName);
-        SYSLINK_SetText(infoPtr, (LPWSTR)lParam);
+        SYSLINK_SetText(infoPtr, ((LPCREATESTRUCTW)lParam)->lpszName);
         return 0;
 
     case WM_DESTROY:

-- 
Dimi.



More information about the wine-patches mailing list