Page 1 of 1
Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Tue Feb 03, 2015 7:21 pm
by zack
I need to bring the OpenOffice window to front, when it is already open.
At the moment I have a XWindow instance, there I can use
setFocus, but this will not bring the application to front.
1)
Is there some other API call to bring the OpenOffice window to front, instead of blinking.
2)
I know how to do this when I have the processID. Is there a way to retrieve the processID directly via an API call?
3)
When there I no direct way to retrieve the processID via SDK, then I know how to do this when I could change the Caption of the OpenOffice MainWindow.
What is the API call to change the caption of a window?
1,2 or 3
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Tue Feb 03, 2015 7:40 pm
by hanya
Call toFront method on the container window of the document frame:
http://www.openoffice.org/api/docs/comm ... ml#toFront
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 10:55 am
by zack
I am very new to the OpenOffice SDK, so I do it like this:
Is this the right way?
Code: Select all
Reference <XModel> xModel(xOfficeDocument_, UNO_QUERY );
auto xContainerWindow_ = xModel->getCurrentController()->getFrame()->getContainerWindow();
auto xContainerWindow_->setVisible(sal_True);
// to activate
Reference<XTopWindow > xParentWindowTop(xContainerWindow_, UNO_QUERY);
xParentWindowTop->toFront();
The window is unfortunately not put to front.
Is this the right way to create/retrieve a XTopWindow?
When this is the correct code, then it doesn't work. Then I would need to get the process ID, there I have some code to put a process in front.
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 11:16 am
by hanya
I'm not sure why toFront method is not working on Windows environment.
When this is the correct code, then it doesn't work. Then I would need to get the process ID, there I have some code to put a process in front.
See:
http://www.openoffice.org/api/docs/comm ... wPeer.html
You can find the interface on the container window. In general, the container window is system child window.
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 11:26 am
by zack
The window is just blinking. A common issue on windows.
The link you have provided mention a function called sal_getGlobalProcessId
But I don't find a link to the description of this function, so that I can now which included it needs and how to call it?
Do you have a code snippet for me, please?
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 11:28 am
by RoryOF
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 11:34 am
by zack
@RoryOF
This is the same link again, to a function which requires as input a processID, which I don't have.
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 12:01 pm
by hanya
zack wrote:The window is just blinking. A common issue on windows.
The link you have provided mention a function called sal_getGlobalProcessId
But I don't find a link to the description of this function, so that I can now which included it needs and how to call it?
Do you have a code snippet for me, please?
Currently, the first argument is ignored. Pass empty sequence.
It seems sal_getGlobalProcessId is renamed to rtl_getGlobalProcessId.
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Wed Feb 04, 2015 12:37 pm
by zack
I have a problem reading/understanding the documentation.
What header do I have to include to use
getWindowHandle?
What header to I have to include to use
rtl_getGlobalProcessId?
I found this:
https://www.openoffice.org/api/docs/cpp ... ess.h.html but where is this process.h file?
The function seems to do not the right thing, because I need the processID from one specific instance of OpenOffice.
So I guess there must be a second argument for this instance...
Some small code snippet would help me a lot here. Thanks!
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Fri Feb 06, 2015 3:57 pm
by zack
I was able to bring the window to front with using, with using the
getWindowHandle method.
Code: Select all
Reference<XSystemDependentWindowPeer> system = Reference<XSystemDependentWindowPeer>(window, UNO_QUERY);
Any hwnd = system->getWindowHandle(Sequence<sal_Int8>(0), com::sun::star::lang::SystemDependent::SYSTEM_WIN32);
sal_Int32 handle = hwnd.get<sal_Int32>();
DWORD processID = 0;
GetWindowThreadProcessId( (HWND)(LONG_PTR)(handle ), &processID);
1)
My question is, there is always an soffice.bin in the taskmanager, what is this?
2)
For every window I create there is not a new instance created. Is it somehow possible to create for every new swriter application a new instance?
Re: Bring OpenOffice MainWindow to front (C++, Windows)
Posted: Fri Feb 06, 2015 4:16 pm
by RoryOF
The soffice.bin in taskmanager indicates that the OpenOffice suite is running.