Dialog reposition/resize in named frame

Keyboard macros or custom scripts

Dialog reposition/resize in named frame

Postby ElFlamencoLoco » Wed Apr 19, 2017 3:35 pm

Context
Writing a set of OOBasic-macros, embedded in a document template (.ott), I need a lot of different dialog boxes, all created in the OOBASIC IDE.

Problem allready solved
At any moment, I want to retrieve the active dialog box, using StarDeskTop.FindFrame. This function, however, expects each dialog box running in a named Frame:
Code: Select all   Expand viewCollapse view
'Named frame allready exists?
oFrame=StarDesktop.findFrame("ActiveDialog", _
  com.sun.star.frame.FrameSearchFlag.GLOBAL)

'No, so create it.
IF isNull(oFrame) THEN
  oFrame=CreateUnoService("com.sun.star.frame.Frame")
  oFrame.Initialize(StarDesktop.ActiveFrame.ContainerWindow)
  oFrame.Name="ActiveDialog"
  StarDesktop.Frames.append(oFrame)
END IF

'Link dialog to named frame.
oFrame.setComponent(oDialog,null)
This works fine.

Retrieving the dialog is now quite easy, anytime, anywhere:
Code: Select all   Expand viewCollapse view
oFrame=StarDesktop.findFrame("ActiveDialog", _
  com.sun.star.frame.FrameSearchFlag.GLOBAL)
oDialog=oFrame.ComponentWindow
This also works perfect. Now the actual problem.

Problem to solve
Running the dialog:
Code: Select all   Expand viewCollapse view
oDialog.Execute
The dialog works fine, but...

... covers (almost) the entire screen!

My approach, before calling .Execute:
Code: Select all   Expand viewCollapse view
'The values are arbitrary - only for testing purposes.
WITH Dia.Model
  .Width=400
  .Height=300
  .PositionX=20
  .PositionY=20
END WITH
This does not work; the dialog still covers the entire screen.

My request
I would be grateful if anybody knows how to reposition/resize the dialog window, or how to maintain the values set while creating the dialog in the OOBASIC IDE.
Windows 10
OpenOffice 4.1.2
ElFlamencoLoco
 
Posts: 16
Joined: Mon Dec 28, 2015 8:45 pm

Re: Dialog reposition/resize in named frame

Postby UnklDonald418 » Wed Apr 19, 2017 4:48 pm

Rather than changing the values in the Dialog's Model I believe you need to use the setPosSize() method available in the View.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 516
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Dialog reposition/resize in named frame

Postby ElFlamencoLoco » Wed Apr 19, 2017 5:36 pm

So, I've tried both...
Code: Select all   Expand viewCollapse view
oDia.setPosSize(30,30,400,300,15)
oDia.Execute
... and...
Code: Select all   Expand viewCollapse view
oDia.View.setPosSize(30,30,400,300,15)
oDia.Execute
But... no avail! Nevertheless, thanks for your quick reply.

Other suggestions?
Windows 10
OpenOffice 4.1.2
ElFlamencoLoco
 
Posts: 16
Joined: Mon Dec 28, 2015 8:45 pm

Re: Dialog reposition/resize in named frame

Postby RoryOF » Wed Apr 19, 2017 6:10 pm

Any messages when these are used?
Apache OpenOffice 4.1.3 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 24755
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Dialog reposition/resize in named frame

Postby ElFlamencoLoco » Wed Apr 19, 2017 6:20 pm

Forgive me, but I do not understand your request?
Windows 10
OpenOffice 4.1.2
ElFlamencoLoco
 
Posts: 16
Joined: Mon Dec 28, 2015 8:45 pm

Re: Dialog reposition/resize in named frame

Postby RoryOF » Wed Apr 19, 2017 6:26 pm

Any error message when the macro code using these structures is run?
Apache OpenOffice 4.1.3 on Xubuntu 16.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 24755
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Dialog reposition/resize in named frame

Postby UnklDonald418 » Wed Apr 19, 2017 10:16 pm

Code: Select all   Expand viewCollapse view
oDia.setPosSize(30,30,400,300,15)
oDia.Execute

should generate an exception because a Dialog does not have a setPosSize() method
But in my tests
Code: Select all   Expand viewCollapse view
oDia.View.setPosSize(30,30,400,300,com.sun.star.awt.PosSize.POSSIZE)
oDia.Execute

resizes and relocates the Dialog immediately on opening.
Also in my tests
Code: Select all   Expand viewCollapse view
oDia.setPosSize(30,30,400,300,com.sun.star.awt.PosSize.POSSIZE)

works in an event handler while the dialog is active.
Be aware that changing the size doesn't shrink or grow the Dialog, it only adjusts the area on the screen to display the Dialog. If the Dialog is designed to be larger than the size in your macro code then part of the Dialog will not display.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 516
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Dialog reposition/resize in named frame

Postby ElFlamencoLoco » Thu Apr 20, 2017 12:27 am

RoryOF wrote:Any error message when the macro code using these structures is run?
O sorry, no idea you're mentioning error messages. ;)

Not at all, the code runs cleanly, exept the repositioning/resizing.
Windows 10
OpenOffice 4.1.2
ElFlamencoLoco
 
Posts: 16
Joined: Mon Dec 28, 2015 8:45 pm

Re: Dialog reposition/resize in named frame

Postby ElFlamencoLoco » Thu Apr 20, 2017 12:49 am

UnklDonald418 wrote:...in my tests
Code: Select all   Expand viewCollapse view
oDia.View.setPosSize(30,30,400,300,com.sun.star.awt.PosSize.POSSIZE)
oDia.Execute

resizes and relocates the Dialog immediately on opening.
Also in my tests
Code: Select all   Expand viewCollapse view
oDia.setPosSize(30,30,400,300,com.sun.star.awt.PosSize.POSSIZE)

works in an event handler while the dialog is active.
Be aware that changing the size doesn't shrink or grow the Dialog, it only adjusts the area on the screen to display the Dialog. If the Dialog is designed to be larger than the size in your macro code then part of the Dialog will not display.
The problem might be caused by the alternative technique I use to create the dialog. The standard technique:
Code: Select all   Expand viewCollapse view
oDialog=CreateUNODialog(DialogLibraries.Name_of_lib.Name_of_dialog)
The technique I prefer:
Code: Select all   Expand viewCollapse view
oDoc.DialogLibraries.loadLibrary(Name_of_lib)
oLib=oDoc.DialogLibraries.getByName(Name_of_lib)
oDiaScript=oLib.getByName(Name_of_dialog)
oDialog=createUnoDialog(oDiaScript)
This technique allows writing a function "createMyDialog" with parameters:
  • the component's URL (the application existing of several .ott-files)
  • the name of the library
  • the name of the dialog
By searching the URL in the StarDesktop, retrieving the component is easy. A call might look like this:
Code: Select all   Expand viewCollapse view
oDialog=createMyDialog(URL_of_service_module,StatisticLib,SyntheseDia)

Anybody an idea?
Windows 10
OpenOffice 4.1.2
ElFlamencoLoco
 
Posts: 16
Joined: Mon Dec 28, 2015 8:45 pm

Re: Dialog reposition/resize in named frame

Postby UnklDonald418 » Thu Apr 20, 2017 4:56 am

The problem might be caused by the alternative technique I use to create the dialog.

I don't think that is the problem because when I use
Code: Select all   Expand viewCollapse view
oDoc.DialogLibraries.loadLibrary(Name_of_lib)
oLib=oDoc.DialogLibraries.getByName(Name_of_lib)
oDiaScript=oLib.getByName(Name_of_dialog)
oDialog=createUnoDialog(oDiaScript)
oDialog.View.setPosSize(30,30,400,300,com.sun.star.awt.PosSize.POSSIZE)
oDialog.Execute


on my test dialog, it opens at the specified size and position
Perhaps the problem is with the Dialog. Have you tried more than one?
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the subject line
Apache OpenOffice 4.1.3 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 516
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 7 guests