From 69bf04ccaedec01f348f1cf896a666c5480b50fb Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Tue, 28 Sep 2010 15:19:43 +0300 Subject: Pass proper parent window handle to ODMRegisterApp Use short code snippet lifted from fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx to get a suitable window handle. Should fix bnc#398822. --- fpicker/source/odma/ODMAFilePicker.cxx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'fpicker') diff --git a/fpicker/source/odma/ODMAFilePicker.cxx b/fpicker/source/odma/ODMAFilePicker.cxx index 09eb01b737..2fe531015b 100644 --- a/fpicker/source/odma/ODMAFilePicker.cxx +++ b/fpicker/source/odma/ODMAFilePicker.cxx @@ -96,6 +96,21 @@ void SAL_CALL ODMAFilePicker::setTitle( const ::rtl::OUString& aTitle ) xExecutableDialog->setTitle( aTitle); } +inline bool is_current_process_window(HWND hwnd) +{ + DWORD pid; + GetWindowThreadProcessId(hwnd, &pid); + return (pid == GetCurrentProcessId()); +} + +HWND choose_parent_window() +{ + HWND hwnd_parent = GetForegroundWindow(); + if (!is_current_process_window(hwnd_parent)) + hwnd_parent = GetDesktopWindow(); + return hwnd_parent; +} + sal_Int16 SAL_CALL ODMAFilePicker::execute( ) throw (RuntimeException) { @@ -104,7 +119,7 @@ sal_Int16 SAL_CALL ODMAFilePicker::execute( ) WORD count = 0; DWORD flags; - status = NODMRegisterApp( &handle, ODM_API_VERSION, "sodma", (DWORD) GetActiveWindow( ), NULL ); + status = NODMRegisterApp( &handle, ODM_API_VERSION, "sodma", (DWORD) choose_parent_window( ), NULL ); if (status == ODM_SUCCESS) { if (m_nDialogKind == OPEN) -- cgit v1.2.3