summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-08-16 05:04:23 +0000
committerTino Rachui <tra@openoffice.org>2001-08-16 05:04:23 +0000
commit21296b60520e06eb214c9475c19f0593c669fa0b (patch)
treee930cb3c68a994c72e15a814bc0e471766c707de /fpicker
parentd17b16bc27d9d7e561628edbadbb022c12589b33 (diff)
#89239#center the dialog position to its parent
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/FileOpenDlg.cxx70
-rw-r--r--fpicker/source/win32/filepicker/FileOpenDlg.hxx8
2 files changed, 71 insertions, 7 deletions
diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.cxx b/fpicker/source/win32/filepicker/FileOpenDlg.cxx
index 2e6cedeced89..aec99e00a6ab 100644
--- a/fpicker/source/win32/filepicker/FileOpenDlg.cxx
+++ b/fpicker/source/win32/filepicker/FileOpenDlg.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FileOpenDlg.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-08-10 12:12:37 $
+ * last change: $Author: tra $ $Date: 2001-08-16 06:04:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -559,6 +559,7 @@ void SAL_CALL CFileOpenDialog::onHelp( )
void SAL_CALL CFileOpenDialog::onInitDone()
{
+ centerPositionToParent( );
}
//------------------------------------------------------------------------
@@ -583,7 +584,6 @@ void SAL_CALL CFileOpenDialog::onTypeChanged( sal_uInt32 nFilterIndex )
void SAL_CALL CFileOpenDialog::onInitDialog( HWND hwndDlg, HWND hwndChild )
{
-
}
//------------------------------------------------------------------------
@@ -748,9 +748,71 @@ unsigned int CALLBACK CFileOpenDialog::BaseDlgProc(
//
//------------------------------------------------------------------------
-CFileOpenDialog* CFileOpenDialog::getCurrentInstance( HWND hwnd )
+CFileOpenDialog* SAL_CALL CFileOpenDialog::getCurrentInstance( HWND hwnd )
{
OSL_ASSERT( IsWindow( hwnd ) );
return reinterpret_cast< CFileOpenDialog* >(
GetPropA( hwnd, CURRENT_INSTANCE ) );
+}
+
+//------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------
+
+void SAL_CALL CFileOpenDialog::centerPositionToParent( ) const
+{
+ OSL_PRECOND( IsWindow( m_hwndFileOpenDlg ), "no dialog window, call method only after or in onInitDone" );
+
+ HDC hdc = GetDC( m_hwndFileOpenDlg );
+
+ HWND hwndParent = m_ofn.hwndOwner;
+
+ if ( !IsWindow( hwndParent ) )
+ hwndParent = GetDesktopWindow( );
+
+ OSL_ASSERT( IsWindow( hwndParent ) );
+
+ RECT rcParent;
+ GetWindowRect( hwndParent, &rcParent );
+
+ RECT rcDialog;
+ GetWindowRect( m_hwndFileOpenDlg, &rcDialog );
+
+ LONG lParentWidth = rcParent.right - rcParent.left;
+ LONG lParentHeight = rcParent.bottom - rcParent.top;
+
+ LONG lDialogWidth = rcDialog.right - rcDialog.left;
+ LONG lDialogHeight = rcDialog.bottom - rcDialog.top;
+
+ int xParentMid = rcParent.left + (lParentWidth / 2);
+ int yParentMid = rcParent.top + (lParentHeight / 2);
+
+ int x = xParentMid - (lDialogWidth / 2);
+ int y = yParentMid - (lDialogHeight / 2);
+
+ int xScreen = GetDeviceCaps( hdc, HORZRES );
+ int yScreen = GetDeviceCaps( hdc, VERTRES );
+
+ if ( x < 0 )
+ x = 0;
+
+ if ( y < 0 )
+ y = 0;
+
+ if ( (x + lDialogWidth) > xScreen )
+ x = xScreen - lDialogWidth;
+
+ if ( (y + lDialogHeight) > yScreen )
+ y = yScreen - lDialogHeight;
+
+ SetWindowPos(
+ m_hwndFileOpenDlg,
+ NULL,
+ x,
+ y,
+ 0,
+ 0,
+ SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE );
+
+ ReleaseDC( m_hwndFileOpenDlg, hdc );
} \ No newline at end of file
diff --git a/fpicker/source/win32/filepicker/FileOpenDlg.hxx b/fpicker/source/win32/filepicker/FileOpenDlg.hxx
index 02ba251f79da..ca8108d4bf4c 100644
--- a/fpicker/source/win32/filepicker/FileOpenDlg.hxx
+++ b/fpicker/source/win32/filepicker/FileOpenDlg.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FileOpenDlg.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-08-10 12:12:37 $
+ * last change: $Author: tra $ $Date: 2001-08-16 06:04:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -313,7 +313,9 @@ protected:
// we connect the instance with the dialog window using
// SetProp, with this function we can reconnect from
// callback functions to this instance
- static CFileOpenDialog* getCurrentInstance( HWND hwnd );
+ static CFileOpenDialog* SAL_CALL getCurrentInstance( HWND hwnd );
+
+ void SAL_CALL centerPositionToParent( ) const;
private:
// FileOpen or FileSaveDialog