[Solved] Bring to front the main window

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

[Solved] Bring to front the main window

Post by HCL »

How to show a Calc or Writer main window to most front?

If VB.net, like BringToFront or TopMost.
Last edited by robleyd on Sat Jul 24, 2021 3:14 am, edited 2 times in total.
Reason: Add green tick
OpenOffice 3.1 on Windows 10
FJCC
Moderator
Posts: 9270
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Bring to front the main window

Post by FJCC »

Maybe using setFocus() will do what you want

Code: Select all

CurrControl = ThisComponent.CurrentController
CompWin = CurrControl.ComponentWindow
CompWin.setFocus()
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: Bring to front the main window

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

[Solved]

Post by HCL »

Thank you for your reply.

I failed to bring to front a document by using "XTopWindow".

===================================
Sorry, but I noticed that my XSpreadsheetDocument go behind by another reason.
A XSpreadsheetDocument went behind when I closed a jframe form.
So I resolved that by changing process order.
OpenOffice 3.1 on Windows 10
JeJe
Volunteer
Posts: 2777
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Bring to front the main window

Post by JeJe »

Code: Select all

	vFrames = StarDesktop.getFrames() 
	For i = 1 To vFrames.getCount()
	with vFrames.getByIndex(i-1)
	msgbox .title
	.containerwindow.tofront
	end with
	Next

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
HCL
Posts: 22
Joined: Thu Jul 22, 2021 3:55 am

Re: [Solved] Bring to front the main window

Post by HCL »

Thank you for your answer.

I could see that a window went to front by below codes.

================================

Code: Select all

		XSpreadsheetDocument xdoc;
		XModel model = UnoRuntime.queryInterface(XModel.class, xdoc);
		XTopWindow top_window = UnoRuntime.queryInterface(XTopWindow.class, model.getCurrentController().getFrame().getContainerWindow());
		top_window.toFront();
================================
But I've known that my problem is occurred by showing JFrame form.
When close this form, a book window go behind of other window and prevent "toFront".

I resolved this by changing code order.
OpenOffice 3.1 on Windows 10
Post Reply