msi 2: Store and use the center point of the dialog window in between dialogs

James Hawkins truiken at gmail.com
Wed Aug 30 16:08:55 CDT 2006


Hi,

I had to use floats because we lose precision with integer types if
the width or height of the dialog is odd causing the dialogs to
'float' downward or forward even if you just press next and back, next
and back, etc.

Changelog:
* Store and use the center point of the dialog window in between dialogs.

 dlls/msi/dialog.c  |   31 +++++++++++++++++++++++++++----
 dlls/msi/msipriv.h |    2 ++
 2 files changed, 29 insertions(+), 4 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c
index 114b4be..00861b8 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -85,6 +85,7 @@ struct msi_dialog_tag
     BOOL finished;
     INT scale;
     DWORD attributes;
+    SIZE size;
     HWND hwnd;
     LPWSTR default_font;
     msi_font *font_list;
@@ -2358,10 +2359,27 @@ static void msi_dialog_adjust_dialog_pos
     center.y = MulDiv( center.y, yres, 100 );
 
     /* turn the client pos into the window rectangle */
-    pos->left = center.x - sz.cx/2;
-    pos->right = pos->left + sz.cx;
-    pos->top = center.y - sz.cy/2;
-    pos->bottom = pos->top + sz.cy;
+    if (dialog->package->center_x && dialog->package->center_y)
+    {
+        pos->left = dialog->package->center_x - sz.cx / 2.0;
+        pos->right = pos->left + sz.cx;
+        pos->top = dialog->package->center_y - sz.cy / 2.0;
+        pos->bottom = pos->top + sz.cy;
+    }
+    else
+    {
+        pos->left = center.x - sz.cx/2;
+        pos->right = pos->left + sz.cx;
+        pos->top = center.y - sz.cy/2;
+        pos->bottom = pos->top + sz.cy;
+
+        /* save the center */
+        dialog->package->center_x = center.x;
+        dialog->package->center_y = center.y;
+    }
+
+    dialog->size.cx = sz.cx;
+    dialog->size.cy = sz.cy;
 
     TRACE("%lu %lu %lu %lu\n", pos->left, pos->top, pos->right, pos->bottom);
 
@@ -2694,6 +2712,11 @@ static LRESULT WINAPI MSIDialog_WndProc(
 
     switch (msg)
     {
+    case WM_MOVE:
+        dialog->package->center_x = LOWORD(lParam) + dialog->size.cx / 2.0;
+        dialog->package->center_y = HIWORD(lParam) + dialog->size.cy / 2.0;
+        break;
+        
     case WM_CREATE:
         return msi_dialog_oncreate( hwnd, (LPCREATESTRUCTW)lParam );
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 991c11c..c90926e 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -231,6 +231,8 @@ typedef struct tagMSIPACKAGE
     UINT CurrentInstallState;
     msi_dialog *dialog;
     LPWSTR next_dialog;
+    float center_x;
+    float center_y;
 
     UINT WordCount;
 
-- 
1.4.2


More information about the wine-patches mailing list