[Bug 2388] WM_NEXTDLGCTL changes the default button ID and does not restore default control identifier

Katia Maculan katia.maculan at isis-papyrus.com
Wed Oct 6 04:25:44 CDT 2004


Skipped content of type multipart/alternative-------------- next part --------------
diff -urN oldwinever/dlls/user/button.c newwinever/dlls/user/button.c
--- oldwinever/dlls/user/button.c	2004-09-17 14:43:04.000000000 +0200
+++ newwinever/dlls/user/button.c	2004-09-17 14:09:06.000000000 +0200
@@ -275,6 +275,22 @@
             break;
         }
         SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 );
+	if (SendMessageA (hWnd, WM_GETDLGCODE, 0, 0) & DLGC_UNDEFPUSHBUTTON)
+	{
+	    // check if there's already a default push button 
+    	    HWND hwndChild = GetWindow( GetParent(hWnd), GW_CHILD );
+    	    while (hwndChild)
+    	    {
+                if (SendMessageW( hwndChild, WM_GETDLGCODE, 0, 0 ) & DLGC_DEFPUSHBUTTON)            break;
+        	hwndChild = GetWindow( hwndChild, GW_HWNDNEXT );
+    	    }
+    	    if (hwndChild)
+            	SendMessageA( hwndChild, BM_SETSTYLE, BS_PUSHBUTTON, TRUE);
+
+            SendMessageA( hWnd, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
+	}
         ReleaseCapture();
         GetClientRect( hWnd, &rect );
 	if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
diff -urN oldwinever/windows/dialog.c newwinever/windows/dialog.c
--- oldwinever/windows/dialog.c	2004-09-17 14:43:49.000000000 +0200
+++ newwinever/windows/dialog.c	2004-09-17 10:33:13.000000000 +0200
@@ -666,6 +666,27 @@
             if( dlgInfo->hwndFocus )
                 SetFocus( dlgInfo->hwndFocus );
         }
+	if (dlgInfo->hwndFocus) 
+	{
+	    //if the control with the focus is a pushbutton it is set as default pushbutton
+       	    DWORD idHwndFocus;
+	    idHwndFocus = GetDlgCtrlID (dlgInfo->hwndFocus);
+
+ 	    if ((idHwndFocus != dlgInfo->idResult) &&
+                (SendMessageA(dlgInfo->hwndFocus, WM_GETDLGCODE, 0, 0) & DLGC_UNDEFPUSHBUTTON))
+	    {
+	        if (dlgInfo->idResult)  // if already exists a defpushbutton it is reset
+	        {
+                    HWND hwndOld = GetDlgItem (hwnd, dlgInfo->idResult);
+                    if (hwndOld && (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
+            	        SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
+                }
+	        SendMessageA( dlgInfo->hwndFocus, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
+
+	    }
+	}
 	if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
 	{
 	   ShowWindow( hwnd, SW_SHOWNORMAL );	/* SW_SHOW doesn't always work */



More information about the wine-patches mailing list