How to customize base for window size

I’ve searched the web, documentations, fiddled with ~/config/libreoffice/4/user/registrymodifications.xcu entries, but could not figure out how to customize a form window geometry. I was able to change the window size in design mode, although the View options of normal/web is confusing to me, but the form in user mode still has a geometry of 1251x718 or close to it.
Is there a way to save the resized form geometry so that the next time I use the form it opens up to the saved window size?

The reason for this is to save real estate on screen and show only the usable area of the form, not a full, preset canvas with a smaller picture on it.

Operating system?

Linux (xubuntu 20.04)

Maybe you can use the macro, but it is not so cosy. To the array pozice put the names of your forms and your sizes for ones.

Sub SetWindowSizeForSomeForms
	Dim o, oDb, oForms, oForm, i%, j%, pozice()
	rem array with the formNames, X, Y, width, height
	pozice=array( array("Form1",100,100,600,600), array("Form2",720,100,600,600) )
	oDb=thisComponent 'base dokument
	oDb.currentController.connect() 'connect with db
	oForms=oDb.getFormDocuments() 'forms db
	if NOT oForms.hasElements() then exit sub 'forms aren't in the db then exit
	for i=0 to oForms.count-1 'iterate the forms
		oForm=oForms.getByIndex(i) 'current form
		for j=lbound(pozice()) to ubound(pozice()) 'is current form in the array?
			if oForm.name=pozice(j)(0) then 'form is in the array
				o=oForm.open() 'open the form
				o.currentController.frame.ContainerWindow.setPosSize(pozice(j)(1),pozice(j)(2),pozice(j)(3),pozice(j)(4),com.sun.star.awt.PosSize.POSSIZE) 'set sizes to the window of the form
			end if
		next j
	next i
End Sub

Sorry for the stupid question: where would I put the macro? (I think I understand how it works, and will try it) - Thx

OK, I put it in Tools, Macro… etc. and ran it in My Macros / …/ Modules1 / , and it does open the forms in custom programmed size. Is there a way to make it link to the Forms section of the “foo.odb - LibreOfficeBase” window? Obviously it would not be a posice() array, but separate macros for each form that I click to open. Presently when I click any of those they open in the same factory default window size - my initial question.

Hello,

You can set each form to a different size using macros. It is fairly simple. See the answer in this post → Adjust size and placement of a form in Base

Edit 2021-06-28:

As it appears you are having a most difficult time with this, have attached a sample with three different forms using three different sizes and positions.

Sample ---- FormSizes.odb

Hi, trying to make your solution work. Bear with me, I’m not an experienced macro user and programmer. In your linked post: “This second sub is then attached to the Open Document event of the form.” How?
The “setYOURFORM” should be named to the form listed in the opening window Forms section (without the “set” prefix)?

Btw, what is the 5th item, the constant 15 in the statement argument that is repeated twice, and why is it repeated?

@jankom,

You should probably review the LO documentation as macros are not intuitive. They do require some background and understanding of terminology. See:

Customize Events

And the LibreOffice documentation found here → Documentation/Publications. Chapter 13 of the Getting started Guide will help you start with macros and Chapter 9 of the Base guide deals more specifically with Base macros. Both will help you understand a bit more.

cont:

setYOURFORM is a sub routine name. It is unique in ways and can be of any legal name ( certain characters not permitted). So each for can have its own set of parameters for form sizing and positioning. So you could have:

Sub setForm1
    Resize(850,1330,295,0)
End Sub

to be one size and position, and

Sub setForm2
    Resize(400,900,20,10)
End Sub

to be different. You can do this for each form. There are many methods to do this.

The 5th item 15 is same as com.sun.star.awt.PosSize.POSSIZE. See → com::sun::star::awt::PosSize Constant Group Reference.

As for duplicate lines, this was explained in the other linked answer. It was because of bugs and most recent versions of LO may be starting to fix these issues. For now I would be cautious in removing them.

Thx and appreciate your help and patience. One of the problem is that the Tools / Customize window (Dialogue box?) in my case is fixed size and the bottom part (Help Reset Cancel OK) is missing. The window is only correct if I open the LibreOffice overall access screen that has all the component selections (Writer, Calc, etc.). If I open it while in an .odb file then the Customize window is missing the bottom part. On the oherhand, If I open the Customize window in the overall access screen then there is no selection to assign a macro to an .odb file, just to LibreOffice.
Doing the Tool / … / Assign… steps in the LibreOffice overall access screen your solution works. Yes, it took some TLC. Is it a bug though that the Customize window accessed in any of the LibreOffice components cannot be adjusted vertically, that is missing he OK (confirm the action) button?

@jancom,

Have used similar in past:

The grab and move key
By default, this key is Alt. When you press the key and drag the window with the left mouse button, you can move the window. When you press the key and drag the window from a corner with the right mouse button, you can resize the window

If I recall correctly, once moved, resize from top or bottom.

May be reported already. Search → Bugzilla

I totally forgot the Alt key method because I typically resize an active window with left mouse button. Yes, bug is already reported, I found it: link text. Back to the main issue: OK, macros and assign work, but…
In my foo.odb file I have three forms. No matter what name I give to the macro that calls the resize macro the form is resized regardless which one is opened. Is there a way to tell LibreOffice (with a macro or something) to resize a particular macro. More generally stated: can a form window size be defined/set during the design phase? No big deal, I’m OK with your solution as is and I realize this is an open source (“free”) software, but can it be improved with user’s input and consensus?

@jankom,

Three forms then three sub’s - this has already been noted multiple times. Each sub will have different dimensions and each is attached to the Open Document event of the form (this also has been noted).

As for the setting in design mode and improved with user’s input, it appears you have not read all the links noted already. This issue is a result of a number of bugs. If the bugs were corrected there would not be this issue and you would not need any macros.

I have created two macros to call the resize sub. The calling macros are:
sub MACRO1 - one window geometry
sub MACRO2 - a different window geometry
These names, MACRO1 or MACRO2 are the same as the names of the form to be resized when the event Open Document happens. The problem is that I can assign only one macro to the Open Document event. If I assign the other then it replaces the first assignment. This happens regardless if the form is previously highlighted or not. Also, LibreOffice does not seem to identify or match the form name with the sub name. In fact, I could call the sub name as
sub foo
it would still resize my all three forms.
I have read again carefully Chapter 13, yet the question remains: how to assign a specific macro to a specific form?
But, as noted before, I’m OK with the present situation.

@jancom,

You are at the wrong place for entering events for forms. You are on the main Base screen. You need to be on the form.

Right click for name to modify and select Edit. Then on that screen go to customize and use that events tab for the Open Document event. Each form has its’ own set of events.

Look at the sample provided in my answer.

@Ratslinger,
Got it and thank you again. Case closed, problem solved!
(Alt key to move Customize window to see everything; do it in Form Design mode)