Open a Base Form in a window

When ever I open a form, regardless of the dimension of the actual data displayed it always opens in a window that occupies most of the screen. Is there any way that I can specify the “page size” that is displayed on screen? i.e. if the table I am displaying is only 2" wide and 3" high then all I really want is a window that will encompass that, not one that encompasses almost the entire screen.

Running LibreOffice Base in Linux

Edit 2019-10-03 By @Ratslinger (Comments moved here to enhance question and improve readability):

That works great with my Main Form, however, whenever I call another form (I have buttons that close the main form and open a new one via macro) the newly opened form throws a “BASIC runtime error. Object variable not set” message. Yet, when I close the new form and return to the Main one (again via macro) it works fine.

open form designer opens the secondary form which fails. OpenAllForm opens the master form and works as intended CloseAllForm closes the Master in preparation for opening the designer. All the extra code in all of this is just so I can return to the last record I was viewing.

Sub OpenFormDesigner
    CloseAllForm
    ThisDatabaseDocument.FormDocuments.getbyname("frmDESIGNER").open
    Resize(100,200,500,1000)                
End Sub

Sub CloseFormDesigner
    Dim oForm
    oForm = ThisComponent.DrawPage.Forms.getByIndex(0)
    oForm.updateRow()
    oForm.First()
    ThisDatabaseDocument.FormDocuments.getbyname("COUNTRY").open
    ThisDatabaseDocument.FormDocuments.getbyname("frmDESIGNER").close
End Sub

Sub OpenAllForm
    Dim oForm       'Reference to the primary record.
    Dim oSubForm    
    Dim CurrRecord  'Record Number saved 
    Dim lFlag, mFlag
    ' CurrRec = stored value  
    Resize(710,465,940,560)
    oForm = ThisComponent.DrawPage.Forms.getByIndex(0)    ' Main Form
    oForm.Absolute(9)    'takes me to a specific record number
    WAIT 200
    oSubForm = oForm.GetByName("Stamp") 'SubForm Name
    WAIT 100
    lFlag = oSubForm.findColumn("SM_FLAG")
    mFlag = oSubForm.getString(lFlag)
    CurrRecord = oSubForm.getRow()      ' returns the current record number
    oSubForm.updateString(lFlag, CurrRecord)
End

Sub CloseAllForm
    Dim CurrRecord 'Current record number
    Dim oForm      'Reference to the form containing the primary record.
    Dim oSubForm   'Reference to the subform containing the data
    Dim CurrRec    'Record Number saved when form was last closed
    Dim lFlag
    oForm = ThisComponent.DrawPage.Forms.getByIndex(0)  'Main Form
    oSubForm = oForm.GetByName("Stamp")                 'SubForm Name
'       oSubForm.updaterow()
    WAIT(200)               
    CurrRecord = oSubForm.getRow()                      'returns the current record number
    oSubForm.first()                                    'Return to start
    lFlag = oSubForm.findColumn("SM_FLAG")            
    oSubForm.updateString(lFlag, CurrRecord)
    oSubForm.updaterow()
    WAIT(200)   
    oForm.parent.parent.CurrentController.Frame.close(true)
End Sub

@LSemmens,

Had no ides you had posted those. Either update your original question as I did for you or respond under the answer using add a comment so the person you are responding is notified. Otherwise unless I had commented under the question I don’t get any notification.

Now it appears you have a question here? Seems you cant resize after closing one form then opening another form? If so the problem is since you are still in code started from closed form, to do something there you need to re-establish a connection to it.

Is this your problem/question/situation? Why not do as stated in the answer - In Open Document event of the form call a sub -

Sub SetFormA
    Resize(50,100,400,500)
End Sub

Sorry Ratslinger, I’m still coming to grips with the correct procedure for responding to questions here. I apologise. Thank you for your time and help. Am I responding correctly, now? I hadn’t considered the open document event, that sounds like it should be what I need. Thanks again.

Just been and had a play, thank you again, It looks like you’ve solved my problem.

Apologies not needed. Just want you be aware of how the site works. Without knowing, your comments may go unnoticed for some time.

Glad all is working now.

Hello,

There are a number of bugs concerning this.

A form is simply a Writer document. In the past, and as Writer documents still are, a form would open with its’ last saved size and screen position. Somewhere in the v5.x series this stopped working. It was further compounded in the early v6.x releases - watching closely before final display the form resizes a few times.

This can be adjusted by using a macro which can set length, width and position on the screen. Unfortunately, recently another bug was introduced in the Vertical positioning of the screen. Fortunately have figured out another workaround for this.

You can do this with one macro, but it is probably best to use two - a universal routine to actually set the settings and another to call with the preferred dimensions. This way you can set all form sizes and positions.

Main routine:

Sub Resize(iXaxis, iYaxis, iWidth, iHeight)
    Wait 300
	If IsNull(thisComponent.currentController.Frame) then exit sub
	thisComponent.currentController.Frame.ContainerWindow.setPosSize(iXaxis, iYaxis, iWidth, iHeight, 15)
    Wait 300
	thisComponent.currentController.Frame.ContainerWindow.setPosSize(iXaxis, iYaxis, iWidth, iHeight, 15)
End Sub

The first ‘Wait’ is to allow the internal opening of the screen to complete. The second ‘Wait’ is to allow for the initial setting to complete. The second execution of setting (after the second ‘Wait’) is the workaround for the Vertical bug problem.

You would call this by setting the form ‘Open Document’ event to a macro such as:

Sub SetFormA
    Resize(50,100,400,500)
End Sub

of course with the values for your form size and position wanted. With this you can set all your forms differently. Also be aware this is also applied when editing the form so it may need to be resized simply because of additional toolbars and such. Probably can adjust with more code, but since this can vary don’t see it as a big deal.

Just in case I responded in the wrong spot, Thank you for your time and effort.

A Word of Warning with this code! It works as intended, PROVIDED, the form was not in Full Screen first. Otherwise the form is “resized” and also in Full Screen.