Making the file dialog resizable(implementing OFN_ENABLESIZING)

2009-01-26 Thread Diaa Sami
Hi,
The attached patch fixes the bug at 
http://bugs.winehq.org/show_bug.cgi?id=10394 , can you have a look at it.

It's pretty much done except for some nasty bug and the repainting problem.

-- 
Regards,
Diaa Sami
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index a2826c8..bdfe5fa 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -37,7 +37,7 @@
  * FIXME: add to recent docs
  *
  * FIXME: flags not implemented: OFN_DONTADDTORECENT,
- * OFN_ENABLEINCLUDENOTIFY, OFN_ENABLESIZING,
+ * OFN_ENABLEINCLUDENOTIFY,
  * OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
  * OFN_NOTESTFILECREATE, OFN_USEMONIKERS
  *
@@ -83,7 +83,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
 #define UNIMPLEMENTED_FLAGS \
 (OFN_DONTADDTORECENT |\
-OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING |\
+OFN_ENABLEINCLUDENOTIFY |\
 OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
 OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
 
@@ -979,6 +979,84 @@ static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM
 return TRUE;
 }
 
+static BOOL ScreenToClientR(HWND hwnd, LPRECT r)
+{
+POINT tl = {r-left, r-top};
+POINT br = {r-right, r-bottom};
+
+const BOOL success1 = ScreenToClient(hwnd, tl);
+const BOOL success2 = ScreenToClient(hwnd, br);
+
+if (!success1 || !success2)
+return FALSE;
+
+r-left = tl.x;
+r-right = br.x;
+r-top = tl.y;
+r-bottom = br.y;
+
+return TRUE;
+}
+
+/* Resizing flags, similar in functionality to .NET anchors */
+static const UINT32 PIN_LEFT  = (2  0);
+static const UINT32 PIN_RIGHT = (2  1);
+static const UINT32 PIN_TOP   = (2  2);
+static const UINT32 PIN_BOTTOM= (2  3);
+
+static void Resize(HWND hwnd, HWND parent, const POINT *sizeDifference, UINT flags)
+{
+RECT curRect;
+RECT newRect;
+
+TRACE(Resizing %x with parent %x\n, hwnd, parent);
+
+GetWindowRect(hwnd, curRect);
+TRACE(curRect(screen) is %d %d %d %d\n, curRect.left, curRect.top, curRect.right, curRect.bottom);
+ScreenToClientR(parent, curRect);
+TRACE(curRect(client) is %d %d %d %d\n, curRect.left, curRect.top, curRect.right, curRect.bottom);
+
+newRect = curRect;
+
+if ((flags  PIN_RIGHT)  (flags  PIN_LEFT))
+{
+newRect.right += sizeDifference-x;
+}
+else
+{
+if (flags  PIN_RIGHT)
+{
+newRect.right += sizeDifference-x;
+newRect.left += sizeDifference-x;
+}
+
+if (flags  PIN_LEFT)
+{
+}
+}
+
+if ((flags  PIN_TOP)  (flags  PIN_BOTTOM))
+{
+newRect.bottom += sizeDifference-y;
+}
+else
+{
+if (flags  PIN_BOTTOM)
+{
+newRect.bottom += sizeDifference-y;
+newRect.top += sizeDifference-y;
+}
+
+if (flags  PIN_TOP)
+{
+}
+}
+
+TRACE(newRect is %d %d %d %d\n, newRect.left, newRect.top, newRect.right, newRect.bottom);
+
+MoveWindow(hwnd, newRect.left, newRect.top, newRect.right - newRect.left, newRect.bottom - newRect.top, TRUE);
+}
+
 /***
  *  FileOpenDlgProc95
  *
@@ -995,6 +1073,12 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
 case WM_INITDIALOG:
   {
  FileOpenDlgInfos * fodInfos = (FileOpenDlgInfos *)lParam;
+ 
+ if (fodInfos-ofnInfos-Flags  OFN_ENABLESIZING)
+ {
+ SetWindowLongW(hwnd, GWL_STYLE, GetWindowLongW(hwnd, GWL_STYLE) | WS_SIZEBOX);
+ FIXME(Draw the grip which indicates that the file dialog is resizable\n);
+ }
 
 	 /* Adds the FileOpenDlgInfos in the property list of the dialog
 so it will be easily accessible through a GetPropA(...) */
@@ -1011,6 +1095,19 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
  SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
  SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
  SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
+ 
+ if (fodInfos-DlgInfos.currentClientSize.x == 0 ||
+ fodInfos-DlgInfos.currentClientSize.y == 0)
+ {
+ RECT r;
+ GetClientRect(hwnd, r);
+ 
+ fodInfos-DlgInfos.currentClientSize.x = r.right;
+ fodInfos-DlgInfos.currentClientSize.y = r.bottom;
+ 
+ TRACE(Initial size is %d %d\n, fodInfos-DlgInfos.currentClientSize.y, fodInfos-DlgInfos.currentClientSize.x);
+ }
+
  return 0;
}
 case WM_COMMAND:
@@ -1072,6 +1169,68 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
 	}
 return FALSE;
 }
+
+case WM_SIZE:
+{
+FileOpenDlgInfos *const fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+const POINT prevDlgClientSize = 

Making the file dialog resizable(implementing OFN_ENABLESIZING)

2009-01-26 Thread Diaa Sami
Hi,
Can you please have a look at the patch at 
http://bugs.winehq.org/show_bug.cgi?id=10394 ?

It's pretty much done except for some nasty bug and the repainting problem.

-- 
Regards,
Diaa Sami





Making the file dialog resizable(implementing OFN_ENABLESIZING)

2009-01-26 Thread Diaa Sami
Hi,
Can you please have a look at the patch at 
http://bugs.winehq.org/show_bug.cgi?id=10394 ?

It's pretty much done except for some nasty bug and the repainting problem.

-- 
Regards,
Diaa Sami





Re: Making the file dialog resizable(implementing OFN_ENABLESIZING)

2009-01-26 Thread Diaa Sami

Sorry for the multiple posts, happened by mistake.