Ask Your Question

Base: How to define a form's exact size?

asked 2018-01-06 15:41:24 +0100

johnh009 gravatar image

How can the exact size of an individual form be defined? My DB form sizes will vary, as some have much data, and some very little. Of the two suggestions in the post below, the first doesn't work at all, and the second only works approximately, i.e. specifying the form size, via page setup (in edit mode), doesn't work at all, but resizing by dragging the form borders does, but is difficult to guess, as I'm using a macro to hide all menus & tool bars.

I guess the solution will involve the use of a basic macro, which seems excessive, when page setup (in edit mode) should be sufficient.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-01-06 19:00:42 +0100

Ratslinger gravatar image

updated 2018-01-07 01:46:47 +0100


I will not be able to give you a precise formula for what you want. I can present a couple of methods to give you consistency.

With Base forms the are two sizes to consider. The View area and the Frame. The View area is recorded in the .odb form settings.xml file when the form is saved in Edit mode. This setting is used when the form is opened. However it can be affected by toolbars & menus. In form edit mode, you can re-size the form with more precision using the keyboard. Start with Alt + F8. Then using the up/down or left/right arrow keys while holding the Ctrl or Alt keys (different precision) you can adjust the screen size.

You can control the Frame size with a macro. I use this method because of, as you mention, turning off menus & toolbars.
Here is the macro:

Sub Resize(iWidth,iHeight)
'Set the width & height of the form to be displayed
'Used because the tool bars are turned off elsewhere
'This cleans up the dead space
    Dim vRect as Object
    Dim intHeight as Integer
    Dim intWidth  as Integer
    Dim intXPos as Integer
    Dim intYPos as Integer
'With very slight modification, the routing may be altered for 
're-positioning the window.
    If IsNull(thisComponent.currentController.Frame) then exit sub
    vRect = thisComponent.currentController.Frame.ContainerWindow.PosSize
    intHeight=(iHeight * 1.00)
    intWidth=(iWidth * 1.00)
    thisComponent.currentController.Frame.ContainerWindow.setPosSize(intXPos, intYPos, intWidth, intHeight, 15)
End Sub

You then just perform a call to the routine:

    Resize(WIDTH, HEIGHT)

Now this is where I have a problem with exactness. I once found this measurement some time back but can't seem to find it currently. It seems to relate to characters per inch/cm. My searching today shows approximately 48 = 1 inch or 2.54 cm so Resize(48, 48) would then be a 1" X 1" or 2.54 X 2.54 cm window.

The only reference I can give is the XWindow interface.

edit flag offensive delete link more


Thank you very much for your prompt response. Initial thoughts to your suggestions are as follows:

Alt +F8 is just an alternative to dragging the borders with the same results, i.e. generally unsatisfactory. Ctrl with arrow keys does nothing, while Alt with arrow keys only works on components/objects withing the form and not the form itself.

To be continued . . . .

johnh009 gravatar imagejohnh009 ( 2018-01-06 23:12:28 +0100 )edit

. . . . continued

Which leads to the macro. As the 'hide menus & tool bars' is tagged to the 'Open Form' event - I'm presuming that you can't tag more then one macro to an event - to where should your macro be tagged; my initial thought is to the 'Document loading finished' event.

Please excuse my ignorance here; while I understand your macro and the need to call the routine (with different WIDTH & HEIGHT values for each form), I don't know how this is done. Could you explain please - thanks.

johnh009 gravatar imagejohnh009 ( 2018-01-06 23:21:55 +0100 )edit

Not meaning to be pedantic, but for the sake of accuracy and clarity for those not so familiar with the 2 sytems: 1 inch = 2.54cm/25.4mm

johnh009 gravatar imagejohnh009 ( 2018-01-06 23:26:52 +0100 )edit

Thanks for correction - have changed answer to reflect correct decimal. The Alt + F8 works great on Linux Mint 18.3 with Ctrl & arrows being a finer adjustment than Alt & arrows and either a lot better than dragging.

As for the macro, it's just another subroutine called by the one line and from wherever and not "tagged" to anything. You already have a subroutine in a module. Just add the "Resize" subroutine to the same module. The call to the sub is made by the one line of code.

Ratslinger gravatar imageRatslinger ( 2018-01-07 02:01:40 +0100 )edit

Now where this line of code goes depends upon your needs. In a one form setup it could go into your existing "hide menus" sub at the very end. If using multiple forms you may want to resize each form differently. In this case point the 'Open Document' event to a new sub:

    HideMenus             ' your existing routine
    Resize(640,480)     ' size for this form
End Sub

Each form can then have a different size. If multiple forms have the same same size use same sub.

Ratslinger gravatar imageRatslinger ( 2018-01-07 02:10:18 +0100 )edit

As usual, a brilliant solution. Thank you very much. Re: specifying the size (Dots Per Inch - DPI), after a few trials & errors, I found that it works out at 96 DPI (37.8 - 38 is probably close enough - per cm). I wasn't very clear re: Alt + F8 and Ctrl + arrow keys. They all work well enough, but on reopening the form (with the HideAllMenuToolbars macro working), the form doesn't then correspond to the previously set size, hence the requirement for a more definitive solution. Thanks again.

johnh009 gravatar imagejohnh009 ( 2018-01-07 12:43:45 +0100 )edit

Further info that someone may find useful: As some know, when a Write doc is saved, any other Write doc that is the opened has the zoom value of the previously closed doc. In order to have my forms open at my desired zoom value - 100% - I have added the following 2 lines of code to @Ratslinger 's macro (immediately after the 'If' statement) . . .

johnh009 gravatar imagejohnh009 ( 2018-03-05 17:22:32 +0100 )edit

. . . .

'Document zoom type as a
Thiscomponent.currentController.ViewSettings.ZoomType =
Thiscomponent.currentController.ViewSettings.ZoomValue = 100
johnh009 gravatar imagejohnh009 ( 2018-03-05 17:22:53 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-01-06 15:41:24 +0100

Seen: 395 times

Last updated: Jan 07 '18