Dialog property

Hello everyone

I would like to know how to change the size of a dialog in basic program step.
i tried this:

sub Show_Topic(sCellString as string, sTopic as string)
	Dim vTextfield As Variant
 	REM error handling
 	On Error GoTo ErrorMsgBox
	DialogLibraries.LoadLibrary("Standard")
	dlgFrmLesson = CreateUnoDialog(DialogLibraries.Standard.frmLesson)
	'** these two properties don't work. Why?
	dlgFrmLesson.Width = 300
	dlgFrmLesson.Height = 300
	'*****************************************
	dlgFrmLesson.Title = sCellString
	vTextfield = dlgFrmLesson.getControl("txtLesson")
	vTextfield.Text = sTopic
	dlgFrmLesson.execute()
	exit sub
	ErrorMsgBox:
    MsgBox "Errore - Show_Topic"
    Resume next	
end sub

Why don’t the properties: width and height work?
Thank you

You must set the object OutputSize (or maybe Size) with the properties Width and Height

Sub exampleDialogWidthHeight
	dim o as object, oSize as new com.sun.star.awt.Size
	GlobalScope.DialogLibraries.LoadLibrary("Tools")
	o=CreateUnoDialog(GlobalScope.DialogLibraries.Tools.DlgOverwriteAll)
	with oSize
		.Width=150
		.Height=50
	end with
	o.OutputSize=oSize
	o.Visible=true
	msgbox o.isVisible
End Sub
1 Like

Hello
I am a beginner, I don’t understand what it is: o = CreateUnoDialog (GlobalScope.DialogLibraries.Tools.DlgOverwriteAll)

Dialog has already been created, I just want to change the size before running it.
DialogLibraries.LoadLibrary (“Tools”) is causing me an error

sub Show_Topic(sCellString as string, sTopic as string)
	dim vTextfield As Variant
	dim vSize as new com.sun.star.awt.Size
 	REM error handling
 	On Error GoTo ErrorMsgBox
	' using "Tools" creates an error
	DialogLibraries.LoadLibrary("Tools")
	dlgFrmLesson = CreateUnoDialog(DialogLibraries.Standard.frmLesson)
	'** these two properties don't work. Why?
	vSize.Width = 150
	vSize.Height = 50
	'*****************************************
	dlgFrmLesson.Title = sCellString
	vTextfield = dlgFrmLesson.getControl("txtLesson")
	vTextfield.Text = sTopic
	dlgFrmLesson.execute()
	exit sub
	ErrorMsgBox:
    MsgBox "Errore - Show_Topic"
    Resume next	
end sub

Try add to your example: dlgFrmLesson.OutputSize=vSize (or maybe dlgFrmLesson.Size=vSize)


o = CreateUnoDialog (GlobalScope.DialogLibraries.Tools.DlgOverwriteAll)
is the example dialog from the LibreOffice Macros & Dialogs :slight_smile:


There must be GlobalScope.DialogLibraries…
GlobalScope.DialogLibraries.LoadLibrary("Tools")

1 Like

Hello
I tried the example and it works.
Load the example dialog “DlgOverwriteAll” as shown in the image you uploaded.

Thank you

Hello,

Can also set directly:

dlgFrmLesson.setPosSize( parameters here )

For parameters see → setPosSize()

This works for dialogs as well as other windows.

1 Like

Does not work.
maybe I have to refer to some object?

I read the link web page, but I still don’t understand the Libre Office object hierarchy.

Sub exampleDialogWidthHeight
	dim vTextfield as variant
	dim oFrmLesson as object
	DialogLibraries.LoadLibrary("Standard")
	oFrmLesson=CreateUnoDialog(DialogLibraries.Standard.frmDialog)
	vTextfield = oFrmLesson.getControl("txtTesto")
	oFrmLesson.setPosSize(100, 100, 50, 100, 1)
	oFrmLesson.execute()
End Sub

The last parameter in the example means setting only the X-coordinate. Use 15.

1 Like

It works!
Thank you

I want to thank Ratslinger, this method also works for controls.
That’s what I need