Bring OpenOffice MainWindow to front (C++, Windows)

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Bring OpenOffice MainWindow to front (C++, Windows)

Post 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 :D
OpenOffice 4.1 on Windows
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post by hanya »

Call toFront method on the container window of the document frame:
http://www.openoffice.org/api/docs/comm ... ml#toFront
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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.
OpenOffice 4.1 on Windows
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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?
OpenOffice 4.1 on Windows
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post by zack »

@RoryOF
This is the same link again, to a function which requires as input a processID, which I don't have.
OpenOffice 4.1 on Windows
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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! :)
OpenOffice 4.1 on Windows
zack
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post 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?
OpenOffice 4.1 on Windows
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Bring OpenOffice MainWindow to front (C++, Windows)

Post by RoryOF »

The soffice.bin in taskmanager indicates that the OpenOffice suite is running.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply