[User32]
[reactos.git] / reactos / dll / win32 / user32 / controls / icontitle.c
index a884c01..6daf27e 100644 (file)
 
 #include <wine/debug.h>
 
-#ifdef __REACTOS__
-#define MAKEINTATOMW(atom)  ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
-#define ICONTITLE_CLASS_ATOM MAKEINTATOMW(32772)
-#endif
-
 static BOOL bMultiLineTitle;
 static HFONT hIconTitleFont;
 
-static LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
-
 /*********************************************************************
  * icon title class descriptor
  */
 const struct builtin_class_descr ICONTITLE_builtin_class =
 {
-    (LPCWSTR)ICONTITLE_CLASS_ATOM, /* name */
-    0,                    /* style */
-    NULL,                 /* procA (winproc is Unicode only) */
-    IconTitleWndProc,     /* procW */
-    0,                    /* extra */
-    IDC_ARROW,            /* cursor */
-    0                     /* brush */
+    WC_ICONTITLE,     /* name */
+    0,                /* style */
+    NULL,             /* procA (winproc is Unicode only) */
+    IconTitleWndProc, /* procW */
+    0,                /* extra */
+    IDC_ARROW,        /* cursor */
+    0                 /* brush */
 };
 
 
@@ -59,7 +52,7 @@ HWND ICONTITLE_Create( HWND owner )
     LONG style = WS_CLIPSIBLINGS;
 
     if (!IsWindowEnabled(owner)) style |= WS_DISABLED;
-    if( GetWindowLongA( owner, GWL_STYLE ) & WS_CHILD )
+    if( GetWindowLongPtrA( owner, GWL_STYLE ) & WS_CHILD )
        hWnd = CreateWindowExA( 0, (LPCSTR)ICONTITLE_CLASS_ATOM, NULL,
                                 style | WS_CHILD, 0, 0, 1, 1,
                                 GetParent(owner), 0, instance, NULL );
@@ -68,8 +61,8 @@ HWND ICONTITLE_Create( HWND owner )
                                 style, 0, 0, 1, 1,
                                 owner, 0, instance, NULL );
     WIN_SetOwner( hWnd, owner );  /* MDI depends on this */
-    SetWindowLongW( hWnd, GWL_STYLE,
-                    GetWindowLongW( hWnd, GWL_STYLE ) & ~(WS_CAPTION | WS_BORDER) );
+    SetWindowLongPtrW( hWnd, GWL_STYLE,
+                       GetWindowLongPtrW( hWnd, GWL_STYLE ) & ~(WS_CAPTION | WS_BORDER) );
     return hWnd;
 }
 #endif
@@ -142,7 +135,7 @@ static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive )
     }
     else
     {
-        if( GetWindowLongA( hwnd, GWL_STYLE ) & WS_CHILD )
+        if( GetWindowLongPtrA( hwnd, GWL_STYLE ) & WS_CHILD )
        {
            hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
            if( hBrush )
@@ -196,6 +189,18 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
     HWND owner = GetWindow( hWnd, GW_OWNER );
 
     if (!IsWindow(hWnd)) return 0;
+#ifdef __REACTOS__ // Do this now, remove after Server side is fixed.
+    PWND pWnd;
+
+    pWnd = ValidateHwnd(hWnd);
+    if (pWnd)
+    {
+       if (!pWnd->fnid)
+       {
+          NtUserSetWindowFNID(hWnd, FNID_ICONTITLE);
+       }
+    }    
+#endif    
 
     switch( msg )
     {
@@ -208,6 +213,11 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
                 hIconTitleFont = CreateFontIndirectA( &logFont );
             }
             return (hIconTitleFont ? 0 : -1);
+#ifdef __REACTOS__
+        case WM_DESTROY:
+          NtUserSetWindowFNID(hWnd, FNID_DESTROY);
+          break;
+#endif
        case WM_NCHITTEST:
             return HTCAPTION;
        case WM_NCMOUSEMOVE:
@@ -222,7 +232,7 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
             if (wParam) ICONTITLE_SetTitlePos( hWnd, owner );
             return 0;
        case WM_ERASEBKGND:
-            if( GetWindowLongW( owner, GWL_STYLE ) & WS_CHILD )
+            if( GetWindowLongPtrW( owner, GWL_STYLE ) & WS_CHILD )
                 lParam = SendMessageW( owner, WM_ISACTIVEICON, 0, 0 );
             else
                 lParam = (owner == GetActiveWindow());