[ros-diffs] [jimtabor] 54255: [User32] - Up Dialog.c to 1.3.31, sync port and minimized differences. - Sync Information: Alexandre Julliard <julliard at winehq.org> : Don't overwrite the default button id when cr...

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Wed Oct 26 02:17:04 UTC 2011


Author: jimtabor
Date: Wed Oct 26 02:17:02 2011
New Revision: 54255

URL: http://svn.reactos.org/svn/reactos?rev=54255&view=rev
Log:
[User32]
- Up Dialog.c to 1.3.31, sync port and minimized differences.
- Sync Information:
  Alexandre Julliard <julliard at winehq.org> : Don't overwrite the default button id when creating the dialog structure.
  Michael Stefaniuc <mstefani at redhat.de>: Avoid using long. Avoid using HIWORD() on atoms/resources.

Modified:
    trunk/reactos/dll/win32/user32/windows/dialog.c

Modified: trunk/reactos/dll/win32/user32/windows/dialog.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/dialog.c?rev=54255&r1=54254&r2=54255&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] Wed Oct 26 02:17:02 2011
@@ -133,10 +133,10 @@
 *
 * ReactOS
 */
-DIALOGINFO * DIALOG_get_info( HWND hWnd, BOOL create )
+DIALOGINFO *DIALOG_get_info( HWND hWnd, BOOL create )
 {
     PWND pWindow;
-    DIALOGINFO* dlgInfo = (DIALOGINFO *)GetWindowLongPtrW( hWnd, DWLP_ROS_DIALOGINFO );
+    DIALOGINFO* dlgInfo;
 
     pWindow = ValidateHwnd( hWnd );
     if (!pWindow)
@@ -144,14 +144,17 @@
        return NULL;
     }
 
+    dlgInfo = (DIALOGINFO *)GetWindowLongPtrW( hWnd, DWLP_ROS_DIALOGINFO );
+
     if (!dlgInfo && create)
     {
-       if (pWindow && pWindow->cbwndExtra >= DLGWINDOWEXTRA && hWnd != GetDesktopWindow())
-       {
-           if (!(dlgInfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dlgInfo) )))
-              return NULL;
-
-           SETDLGINFO( hWnd, dlgInfo );
+        if (pWindow && pWindow->cbwndExtra >= DLGWINDOWEXTRA)
+        {
+            if (!(dlgInfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dlgInfo) )))
+                return NULL;
+
+            dlgInfo->idResult = IDOK;
+            SETDLGINFO( hWnd, dlgInfo );
 
            NtUserxSetDialogPointer( hWnd, dlgInfo );
        }
@@ -353,14 +356,14 @@
             LPSTR class = (LPSTR)info.className;
             LPSTR caption = (LPSTR)info.windowName;
 
-            if (HIWORD(class))
+            if (!IS_INTRESOURCE(class))
             {
                 DWORD len = WideCharToMultiByte( CP_ACP, 0, info.className, -1, NULL, 0, NULL, NULL );
                 class = HeapAlloc( GetProcessHeap(), 0, len );
                 if (class != NULL)
                     WideCharToMultiByte( CP_ACP, 0, info.className, -1, class, len, NULL, NULL );
             }
-            if (HIWORD(caption))
+            if (!IS_INTRESOURCE(caption))
             {
                 DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL );
                 caption = HeapAlloc( GetProcessHeap(), 0, len );
@@ -381,8 +384,8 @@
             }
             else
                 hwndCtrl = NULL;
-            if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
-            if (HIWORD(caption)) HeapFree( GetProcessHeap(), 0, caption );
+            if (!IS_INTRESOURCE(class)) HeapFree( GetProcessHeap(), 0, class );
+            if (!IS_INTRESOURCE(caption)) HeapFree( GetProcessHeap(), 0, caption );
         }
 
         if (info.windowNameFree)
@@ -511,7 +514,7 @@
 
         pWnd = ValidateHwnd(hParent);
         // FIXME: Use pWnd->fnid == FNID_DESKTOP
-        if (!pWnd || hParent == GetDesktopWindow()) break;
+        if (!pWnd || !TestWindowProcess(pWnd) || hParent == GetDesktopWindow()) break;
 
         if (!(pWnd->state & WNDS_DIALOGWINDOW))
         {
@@ -934,14 +937,14 @@
         LPSTR class_tmp = NULL;
         LPSTR caption_tmp = NULL;
 
-        if (HIWORD(class))
+        if (!IS_INTRESOURCE(class))
         {
             DWORD len = WideCharToMultiByte( CP_ACP, 0, template.className, -1, NULL, 0, NULL, NULL );
             class_tmp = HeapAlloc( GetProcessHeap(), 0, len );
             WideCharToMultiByte( CP_ACP, 0, template.className, -1, class_tmp, len, NULL, NULL );
             class = class_tmp;
         }
-        if (HIWORD(caption))
+        if (!IS_INTRESOURCE(caption))
         {
             DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL );
             caption_tmp = HeapAlloc( GetProcessHeap(), 0, len );
@@ -967,6 +970,7 @@
     will be valid only after WM_CREATE message has been handled in DefDlgProc
     All the members of the structure get filled here using temp variables */
     dlgInfo = DIALOG_get_info( hwnd, TRUE );
+    // ReactOS
     if (dlgInfo == NULL)
     {
         if (hUserFont) DeleteObject( hUserFont );
@@ -974,13 +978,12 @@
         if (modal && (flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
         return 0;
     }
-
+    //
     dlgInfo->hwndFocus   = 0;
     dlgInfo->hUserFont   = hUserFont;
     dlgInfo->hMenu       = hMenu;
     dlgInfo->xBaseUnit   = xBaseUnit;
     dlgInfo->yBaseUnit   = yBaseUnit;
-    dlgInfo->idResult    = IDOK;
     dlgInfo->flags       = flags;
 
     if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
@@ -1973,7 +1976,11 @@
     DIALOGINFO * dlgInfo;
     HWND owner;
 
-    if (!(dlgInfo = GETDLGINFO(hDlg))) return FALSE;
+    if (!(dlgInfo = GETDLGINFO(hDlg)))
+    {
+        ERR("got invalid window handle (%p); buggy app !?\n", hDlg);
+        return FALSE;
+    }
 
     dlgInfo->idResult = nResult;
     dlgInfo->flags |= DF_END;
@@ -2073,7 +2080,7 @@
 {
     char str[30];
     char * endptr;
-    long result = 0;
+    LONG_PTR result = 0;
 
     if (lpTranslated) *lpTranslated = FALSE;
     if (!SendDlgItemMessageA(hDlg, nIDDlgItem, WM_GETTEXT, sizeof(str), (LPARAM)str))
@@ -2259,16 +2266,26 @@
   HWND hCtl,
   BOOL bPrevious)
 {
-	/* Undocumented but tested under Win2000 and WinME */
-	if (hDlg == hCtl) hCtl = NULL;
-
-	/* Contrary to MSDN documentation, tested under Win2000 and WinME
-	* NB GetLastError returns whatever was set before the function was
-	* called.
-	*/
-	if (!hCtl && bPrevious) return 0;
-
-	return DIALOG_GetNextTabItem(hDlg, hDlg, hCtl, bPrevious);
+    PWND pWindow;
+      
+    pWindow = ValidateHwnd( hDlg );
+    if (!pWindow) return NULL;
+    if (hCtl)
+    {
+       pWindow = ValidateHwnd( hCtl );
+       if (!pWindow) return NULL;
+    }
+
+    /* Undocumented but tested under Win2000 and WinME */
+    if (hDlg == hCtl) hCtl = NULL;
+
+    /* Contrary to MSDN documentation, tested under Win2000 and WinME
+     * NB GetLastError returns whatever was set before the function was
+     * called.
+     */
+    if (!hCtl && bPrevious) return 0;
+
+    return DIALOG_GetNextTabItem(hDlg, hDlg, hCtl, bPrevious);
 }
 
 
@@ -2409,6 +2426,14 @@
          case VK_TAB:
             if (!(dlgCode & DLGC_WANTTAB))
             {
+                BOOL fIsDialog = TRUE;
+                WND *pWnd = ValidateHwnd(hDlg);
+
+                if (pWnd && TestWindowProcess(pWnd))
+                {
+                    fIsDialog = (GETDLGINFO(hDlg) != NULL);
+                }
+  
                 SendMessageW(hDlg, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0);
 
                 /* I am not sure under which circumstances the TAB is handled
@@ -2416,7 +2441,7 @@
                  * send WM_NEXTDLGCTL.  (Personally I have never yet seen it
                  * do so but I presume someone has)
                  */
-                if (GETDLGINFO(hDlg))
+                if (fIsDialog)
                     SendMessageW( hDlg, WM_NEXTDLGCTL, (GetKeyState(VK_SHIFT) & 0x8000), 0 );
                 else
                 {
@@ -2517,7 +2542,7 @@
 //// ReactOS
      case WM_SYSKEYDOWN:
          /* If the ALT key is being pressed display the keyboard cues */
-         if (lpMsg->lParam & (1 << 29))
+         if (HIWORD(lpMsg->lParam) & KF_ALTDOWN)
              SendMessageW(hDlg, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL | UISF_HIDEFOCUS), 0);
          break;
 




More information about the Ros-diffs mailing list