UnoControlDialogModel Resizable
UnoControlDialogModel Resizable
I see that "sizeable" is one of the properties of the UnoControlDialogModel. Is setting this property to TRUE supposed to give the user the ability to resize the dialog. I have a dialog with a calc spreadsheet embedded in it. I want to allow the user to resize the dialog. The dialog also has other controls as well.
Raymond
Solaris 10 x86 StarrOffice 9 - basis3.1
Solaris 10 x86 StarrOffice 9 - basis3.1
Re: UnoControlDialogModel Resizable
It can not be changed by the API. It looks dlg:window node support resizeable attribute in XDL file but it does not work with the dialog executed by the dialog provider.
Here is an example to make a dialog through general window creation mechanism. In the case, child controls should be created by code by it is troublesome so I embed the dialog created by the dialog editor as child window into the resizeable outer dialog. You need to resize and reposition child controls yourself.
Here is an example to make a dialog through general window creation mechanism. In the case, child controls should be created by code by it is troublesome so I embed the dialog created by the dialog editor as child window into the resizeable outer dialog. You need to resize and reposition child controls yourself.
Code: Select all
' This is an example to make resizable modal dialog.
' A dialog created by the dialog editor can be embedded
' to make easy to create dialog.
' This example requires Standard.Dialog in application dialog
' with list box named ListBox1.
Sub ResizableDialogTest11
' parent
oParent = ThisComponent.getCurrentController()._
getFrame().getContainerWindow()
' create base window as modal dialog
oBaseDialog = CreateBaseDialog(oParent)
' embed the dialog created by the dialog editor
sURL = "vnd.sun.star.script:Standard.Dialog1?location=application"
oDialog = CreateInnerDialog(oBaseDialog, sURL)
' to show the dialog, have to be done by the outer dialog
If oBaseDialog.execute() > 0 Then
msgbox "Do something..."
End If
oBaseDialog.dispose()
End Sub
' Create new base dialog.
' @param oParent parent window peer
' @return dialog window
Function CreateBaseDialog(oParent As Variant) As Variant
oToolkit = oParent.getToolkit()
WA = com.sun.star.awt.WindowAttribute
aRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
oDesc = CreateUnoStruct("com.sun.star.awt.WindowDescriptor")
With oDesc
.Type = com.sun.star.awt.WindowClass.SIMPLE
.WindowServiceName = "dialog"
.Parent = oParent
.ParentIndex = -1
.Bounds = aRect
.WindowAttributes = WA.CLOSEABLE OR WA.MOVEABLE OR WA.SIZEABLE OR WA.BORDER
End With
oDialog = oToolkit.createWindow(oDesc)
oDialog.addTopWindowListener(CreateUnoListener(_
"WindowListener_", "com.sun.star.awt.XTopWindowListener"))
oDialog.addWindowListener(CreateUnoListener(_
"WindowListener_", "com.sun.star.awt.XWindowListener"))
CreateBaseDialog = oDialog
End Function
' Create child dialog embedded
' @param oParent parent window
' @param sURL dialog URL, without toolbar
Function CreateInnerDialog(oParent As Variant, sURL As String) As Variant
PS = com.sun.star.awt.PosSize
oDP = CreateUnoService("com.sun.star.awt.ContainerWindowProvider")
oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
oChildDialog.setPosSize(0, 0, 0, 0, PS.POS)
oChildDialog.setVisible(True)
aSize = oChildDialog.getPosSize()
oParent.setPosSize(0, 0, aSize.Width, aSize.Height, PS.SIZE)
oChildDialog.addWindowListener(CreateUnoListener(_
"oDialogWindow_", "com.sun.star.awt.XWindowListener"))
CreateInnerDialog = oChildDialog
End Function
'
' XWindowListener
Sub oDialogWindow_windowResized(ev)
' this called indirect by resizeing of the outer dialog
aRect = ev.Source.getPosSize()
' dialog controls have to be repositioned and resized by hand
oListBox = ev.Source.getControl("ListBox1")
oListBox.setPosSize(aRect.Width - 10 - oListBox.getPosSize().Width, _
0, 0, 0, com.sun.star.awt.PosSize.X)
End Sub
Sub oDialogWindow_windowMoved(ev)
End Sub
Sub oDialogWindow_windowShown(ev)
End Sub
Sub oDialogWindow_windowHidden(ev)
End Sub
' Listeners for base dialog
' XTopWindowListener
Sub WindowListener_disposing(ev)
End Sub
Sub WindowListener_windowOpened(ev)
End Sub
Sub WindowListener_windowClosing(ev)
' helps to close the window by close button of the window
ev.Source.endExecute()
End Sub
Sub WindowListener_windowClosed(ev)
End Sub
Sub WindowListener_windowMinimized(ev)
End Sub
Sub WindowListener_windowNormalized(ev)
End Sub
Sub WindowListener_windowActivated(ev)
End Sub
Sub WindowListener_windowDeactivated(ev)
End Sub
' XWindowListener
Sub WindowListener_windowResized(ev)
' resize inner dialog as first child window
aSize = ev.Source.getSize()
ev.Source.Windows(0).setPosSize(0, 0, _
aSize.Width, aSize.Height, com.sun.star.awt.PosSize.SIZE)
End Sub
Sub WindowListener_windowMoved(ev)
End Sub
Sub WindowListener_windowShown(ev)
End Sub
Sub WindowListener_windowHidden(ev)
End Sub
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
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: UnoControlDialogModel Resizable
Hanya,
Thanks for the response. I will try to implement this as soon as I can. I got pulled in another direction for the time being. Hopefully, when I do try, you will be available for follow-up questions.
Thanks for the response. I will try to implement this as soon as I can. I got pulled in another direction for the time being. Hopefully, when I do try, you will be available for follow-up questions.
Raymond
Solaris 10 x86 StarrOffice 9 - basis3.1
Solaris 10 x86 StarrOffice 9 - basis3.1
Re: UnoControlDialogModel Resizable
Hi,
I've tried the ResizableDialogTest11 example and it doesn't work properly in LibreOffice 4.x : the inner child dialog is shown as a separate window (non resizable) and not embedded in the resizable parent.
Any idea on how to fix this?
Thanks a lot,
RB
I've tried the ResizableDialogTest11 example and it doesn't work properly in LibreOffice 4.x : the inner child dialog is shown as a separate window (non resizable) and not embedded in the resizable parent.
Any idea on how to fix this?
Thanks a lot,
RB
LibreOffice 7.5.x on Ubuntu
Re: UnoControlDialogModel Resizable
Set "With title bar" of the dialog to No to make it embedded in the parent dialog.
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
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: UnoControlDialogModel Resizable
Very nice! I couldn't think the answer was so simple...
Thanks a lot,
RB
Thanks a lot,
RB
LibreOffice 7.5.x on Ubuntu
Re: UnoControlDialogModel Resizable
Please, help
When a control is selected, a corresponding window with properties appears.
Error occured:
Function CreateInnerDialog(oParent As Variant, sURL As String) As Variant
PS = com.sun.star.awt.PosSize
oDP = CreateUnoService("com.sun.star.awt.ContainerWindowProvider")
oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
<...>
I am only mastering dialog boxes...
I cannot figure out how to do this. The properties of the dialog box are not available, I don't see them at all.hanya wrote:Set "With title bar" of the dialog to No to make it embedded in the parent dialog.
When a control is selected, a corresponding window with properties appears.
Error occured:
Function CreateInnerDialog(oParent As Variant, sURL As String) As Variant
PS = com.sun.star.awt.PosSize
oDP = CreateUnoService("com.sun.star.awt.ContainerWindowProvider")
oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
<...>
I am only mastering dialog boxes...
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
Right click on the dialog instead of a control.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
This is a great workaround... it works but I get crashes... which I can't figure out so I don't use it... its a shame - other people's mileage may vary.
If you're just starting to use dialogs I'd consider leaning the basics of the IDE before reaching for complicated workarounds in code.
The reason for your error is probably your URL or the parent you're passing to the function.
If you're just starting to use dialogs I'd consider leaning the basics of the IDE before reaching for complicated workarounds in code.
The reason for your error is probably your URL or the parent you're passing to the function.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
No, something is wrong here.JeJe wrote:Right click on the dialog instead of a control.
Right-clicking on the dialog brings up one item: "Paste". I have never seen the properties of a dialog box before and cannot get to them.
I'm in Basic IDE, just in case. Some devilry...
UPD
OK. Found
But the error remained on the same line.JeJe wrote:The reason for your error is probably your URL...
oChildDialog = oDP.createContainerWindow(sURL, "", oParent, nothing)
I cannot understand what is the matter. The dialog exists and the URL is correct.
sURL = "vnd.sun.star.script:Standard.Help?location=application"
"Help" is a name of my dialog that is placed in Standard lib of a document.
I use that code w/o additions (the post #2).hanya wrote:Here is an example to make a dialog through general window creation mechanism.
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
Your sURL is wrong, its got ?location=application instead of ?location=document
(I can't remember whether that code works with a dialog in a document or whether it needs to be in MyMacros ie location=application instead.)
(I can't remember whether that code works with a dialog in a document or whether it needs to be in MyMacros ie location=application instead.)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
' sURL = "vnd.sun.star.script:Standard.Help?language=Basic&location=document"JeJe wrote:Your sURL is wrong, its got ?location=application instead of ?location=document
sURL = "vnd.sun.star.script:Standard.Help?location=document"
Here it is, below
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
Try putting the dialog in mymacros somewhere and using location=application. As I said, it might not work for a dialog in a document.
The other one I linked to might do one in a document, I don't know.
The other one I linked to might do one in a document, I don't know.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
Moved the code and dialog to "My Macros & Dialogs". It works. Only this way and nothing else? I need to put a dialog in a document.
This is not a library dialogue, it is part of a document.
This is not a library dialogue, it is part of a document.
- Attachments
-
- Снимок экрана от 2021-03-10 07-01-14.png (10.21 KiB) Viewed 10552 times
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
It might have to be a non-resizable dialog if no-one else can solve that problem for a document url.
There's another way of creating dialogs... that's entirely with code and not with the IDE.. create a dialog from scratch, add windows for all the buttons etc, add listeners... but that's very complicated and time consuming and people use Basic to avoid that.
There are also any number of ways to resize a dialog without using the dialog borders with dialog.setpossize. eg. you could have a textbox to set the width, another for the height... clunky but its a way...
There's another way of creating dialogs... that's entirely with code and not with the IDE.. create a dialog from scratch, add windows for all the buttons etc, add listeners... but that's very complicated and time consuming and people use Basic to avoid that.
There are also any number of ways to resize a dialog without using the dialog borders with dialog.setpossize. eg. you could have a textbox to set the width, another for the height... clunky but its a way...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
@JeJe, could you modify this example and create a resizable dialog without a nested window, but adding one control programmatically on the fly. That very complicated and time-consuming method is right for me.
UPD
How to add a control to the base dialog?
oEdit1 = CreateCtr("Edit", 10, 10, 200, 100, Array("AutoVScroll", "MultiLine"), Array(True, True))
<?>.addControl("Edit1", oEdit1)
UPD
This code from @Villeroy helped me but can't figure it out. Help is still needed. This is my first time working with dialogues.
UPD
How to add a control to the base dialog?
oEdit1 = CreateCtr("Edit", 10, 10, 200, 100, Array("AutoVScroll", "MultiLine"), Array(True, True))
<?>.addControl("Edit1", oEdit1)
Code: Select all
Function CreateCtr(CtrType, nX, nY, nWidth, nHeight, sNames, vProps)
Dim oCtr As Object, oCtrModel As Object
oCtr = createUnoService("com.sun.star.awt.UnoControl" & CtrType )
oCtrModel = createUnoService("com.sun.star.awt.UnoControl" & CtrType & "Model")
oCtrModel.setPropertyValues(sNames, vProps)
With oCtr
.setModel(oCtrModel)
.setPosSize(nX, nY, nWidth, nHeight, com.sun.star.awt.PosSize.POSSIZE)
End With
CreateCtr() = oCtr 'model can be got from returned value
End Function
This code from @Villeroy helped me but can't figure it out. Help is still needed. This is my first time working with dialogues.
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
There's an example here of creating a resizable dialog with a grid control.
Edit: better link to same thread:
https://dev.api.openoffice.narkive.com/ ... -ooo-3-3-0
Edit: better link to same thread:
https://dev.api.openoffice.narkive.com/ ... -ooo-3-3-0
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
Thank you. I understood. So far, however, it is not entirely clear why these lines are needed. I did without them.
oFrame = createUnoService("com.sun.star.frame.Frame")
oFrame.initialize(oContWin)
StarDesktop.getFrames().append(oFrame)
oFrame.Name = "TestGridFrame"
oFrame.Title = "TestGridTitle"
oFrame = createUnoService("com.sun.star.frame.Frame")
oFrame.initialize(oContWin)
StarDesktop.getFrames().append(oFrame)
oFrame.Name = "TestGridFrame"
oFrame.Title = "TestGridTitle"
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
A half-way house would be to use the IDE to create a dialog as normal - and then use generic code to clone the controls onto a resizable dialog.
It needs a heap of work... but the attached is a start... See the module, the dialog it creates isn't the one in the IDE but a clone.
Edit: apart from adding the controls, largely based on roland65's Resizable dialog code linked to above.
It needs a heap of work... but the attached is a start... See the module, the dialog it creates isn't the one in the IDE but a clone.
Edit: apart from adding the controls, largely based on roland65's Resizable dialog code linked to above.
- Attachments
-
- clone dialog.odt
- (11.88 KiB) Downloaded 326 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
@JeJe, now everything is clear to me. Thank you for your time. Then I will continue myself...
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Re: UnoControlDialogModel Resizable
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlDialogModel Resizable
Thank you. This one works very well.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice