Kaydet (Commit) 4438b99e authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Tor Lillqvist

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.
üst 024a388c
......@@ -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)
......
......@@ -79,11 +79,26 @@ ContentProvider::~ContentProvider()
}
}
// -----------------------------------------------------------------------------
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;
}
ODMHANDLE ContentProvider::getHandle()
{
if(!m_aOdmHandle)
{
ODMSTATUS odm = NODMRegisterApp(&m_aOdmHandle,ODM_API_VERSION,ODMA_ODMA_REGNAME,NULL,NULL);
ODMSTATUS odm = NODMRegisterApp(&m_aOdmHandle,ODM_API_VERSION,ODMA_ODMA_REGNAME,(DWORD) choose_parent_window( ),NULL);
switch(odm)
{
case ODM_SUCCESS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment