DefPushButton management patch

Katia Maculan katia.maculan at isis-papyrus.com
Fri Jul 16 02:40:45 CDT 2004


Skipped content of type multipart/alternative-------------- next part --------------
diff -urN oldwinedir/dlls/user/controls.h newwinedir/dlls/user/controls.h
--- oldwinedir/dlls/user/controls.h	2004-03-04 02:41:11.000000000 +0100
+++ newwinedir/dlls/user/controls.h	2004-07-15 14:05:44.000000000 +0200
@@ -126,6 +126,7 @@
     INT       idResult;    /* EndDialog() result / default pushbutton ID */
     UINT      flags;       /* EndDialog() called for this dialog */
     HGLOBAL16 hDialogHeap;
+    INT       OriDefButID; /* the original DEFPUSHBUTTON */
 } DIALOGINFO;
 
 #define DF_END  0x0001
diff -urN oldwinedir/windows/defdlg.c newwinedir/windows/defdlg.c
--- oldwinedir/windows/defdlg.c	2004-04-20 06:02:35.000000000 +0200
+++ newwinedir/windows/defdlg.c	2004-07-15 14:07:12.000000000 +0200
@@ -135,13 +135,27 @@
 {
     DWORD dlgcode=0; /* initialize just to avoid a warning */
     HWND hwndNew = GetDlgItem(hwndDlg, wParam);
-
-    dlgInfo->idResult = wParam;
+    //more tests are necessary before save that id like a defpushbutton dlgInfo->idResult = wParam;
     if (hwndNew &&
         !((dlgcode=SendMessageW(hwndNew, WM_GETDLGCODE, 0, 0 ))
             & (DLGC_UNDEFPUSHBUTTON | DLGC_BUTTON)))
+	{
+	    //if destination is not a push button the original def push button is set like default
+	    if (dlgInfo->idResult)
+            {
+                HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
+                if (hwndOld && (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
+                    SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
+            }
+    	    dlgInfo->idResult = dlgInfo->OriDefButID; 
+	    hwndNew = GetDlgItem (hwndDlg,  dlgInfo->OriDefButID);
+	    if (hwndNew)
+                SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
         return FALSE;  /* Destination is not a push button */
+	}
 
+    if (dlgInfo->idResult == wParam)  //if new defbutton is the actual nothing change	
+	return TRUE;
     if (dlgInfo->idResult)  /* There's already a default pushbutton */
     {
         HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
@@ -150,8 +164,11 @@
     }
     if (hwndNew)
     {
-        if(dlgcode==DLGC_UNDEFPUSHBUTTON)
+        if(dlgcode & DLGC_UNDEFPUSHBUTTON)  //it is DLGC_UNDEFBUTTON && DLGC_BUTTON
+        {
             SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
+    	    dlgInfo->idResult = wParam; // now is correct to save the new def push button
+        }
     }
     return TRUE;
 }
diff -urN oldwinedir/windows/dialog.c newwinedir/windows/dialog.c
--- oldwinedir/windows/dialog.c	2004-05-18 22:45:22.000000000 +0200
+++ newwinedir/windows/dialog.c	2004-07-15 14:07:05.000000000 +0200
@@ -292,6 +292,7 @@
     DLG_CONTROL_INFO info;
     HWND hwndCtrl, hwndDefButton = 0;
     INT items = dlgTemplate->nbItems;
+    DWORD dlgcode=0;  //to have the control information
 
     TRACE(" BEGIN\n" );
     while (items--)
@@ -353,7 +354,8 @@
             /* Send initialisation messages to the control */
         if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
                                              (WPARAM)dlgInfo->hUserFont, 0 );
-        if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
+	dlgcode = SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0);  //save the result for future test
+	if (dlgcode & DLGC_DEFPUSHBUTTON)
         {
               /* If there's already a default push-button, set it back */
               /* to normal and use this one instead. */
@@ -361,7 +363,21 @@
                 SendMessageA( hwndDefButton, BM_SETSTYLE, BS_PUSHBUTTON, FALSE );
             hwndDefButton = hwndCtrl;
             dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
+            dlgInfo->OriDefButID = dlgInfo->idResult;  //save the ID like the original DEFPUSHBUTTON
         }
+	else
+	{
+                // if no defpushbutton is found and the control is a normal pushbutton
+                // this button is set like defpushbutton
+		if ((dlgInfo->idResult == 0) && (dlgcode & DLGC_UNDEFPUSHBUTTON))
+		{
+            		hwndDefButton = hwndCtrl;
+            		dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
+            		dlgInfo->OriDefButID = dlgInfo->idResult; 
+                	SendMessageA( hwndDefButton, BM_SETSTYLE, BS_DEFPUSHBUTTON, FALSE );
+		}
+		
+	}
     }
     TRACE(" END\n" );
     return TRUE;


More information about the wine-patches mailing list