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

Java, C++, C#, Delphi, ??? - Using the UNO bridges

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

Postby zack » Tue Feb 03, 2015 7:21 pm

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
zack
 
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

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

Postby hanya » Tue Feb 03, 2015 7:40 pm

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
hanya
Volunteer
 
Posts: 884
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby zack » Wed Feb 04, 2015 10:55 am

I am very new to the OpenOffice SDK, so I do it like this:
Is this the right way?
Code: Select all   Expand viewCollapse view
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
zack
 
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

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

Postby hanya » Wed Feb 04, 2015 11:16 am

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
hanya
Volunteer
 
Posts: 884
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby zack » Wed Feb 04, 2015 11:26 am

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
zack
 
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

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

Postby RoryOF » Wed Feb 04, 2015 11:28 am

Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28912
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

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

Postby zack » Wed Feb 04, 2015 11:34 am

@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
zack
 
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

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

Postby hanya » Wed Feb 04, 2015 12:01 pm

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
hanya
Volunteer
 
Posts: 884
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby zack » Wed Feb 04, 2015 12:37 pm

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/ref/names/o-process.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)

Postby zack » Fri Feb 06, 2015 3:57 pm

I was able to bring the window to front with using, with using the getWindowHandle method.
Code: Select all   Expand viewCollapse view
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
zack
 
Posts: 9
Joined: Fri Jan 30, 2015 3:50 pm

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

Postby RoryOF » Fri Feb 06, 2015 4:16 pm

The soffice.bin in taskmanager indicates that the OpenOffice suite is running.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28912
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests