Getting windows zoom level with macros

Is there any way to get the Windows zoom level with macros?
I want it to adjust the libreoffice (base) zoom to a default view, indepently of the windows zoom level. Somehow the windows zoom level totally mess positioning of many things, like items on base (sometimes) or popups

If that’s not possible, it would be possible to get some similar indicator? For example for getting the resolution of the screen I set the macro to maximize a window and get the heght.

Here is a complete solution for forms in Base. Comments are written in German …

REM +++ Hierdurch wird mehr Platz auf dem Bildschirm erreicht. Nur die notwendigen Symbolleisten bleiben erhalten.
REM +++ Die Prozedur wird über Extras → Anpassen → Ereignisse → Dokument öffnen in das jeweilige Formulardokument eingebunden.
SUB ToolbarsHide(oEvent AS OBJECT)
	DIM oFrame AS OBJECT, oWin AS OBJECT, oLayoutMng AS OBJECT
	DIM inx AS INTEGER, iny AS INTEGER, inDpiX AS INTEGER, inDpiY AS INTEGER, inWidth AS INTEGER, inHeight AS INTEGER, inZoom AS INTEGER, i AS INTEGER
	DIM arElements()		
	REM Die Standardwerte geben den Ausschnitt mit allen Elementen des Formulars von der linken oberen Ecke aus gemessen (incl. Navigationsleiste) in Pixeln wieder.
	REM Ausgangspunkt ist eine Messung unter Linux mit Normalbildschirm (Zoom 100% und Auflösung 96 dpi). Wird ein höherer Zoom gewählt (für HDPI), so steigt die Auflösung.
	REM Ohne Berücksichtigung der Ausflösung würde also das Bild bei einer Zoomeinstellung des Systems von über 100% zu groß werden.
	inWidth = 1360
	inHeight = 750
	
	oFrame = oEvent.Source.CurrentController.Frame
	oFrame.setTitle(oEvent.Source.Title)
	oWin = oFrame.getContainerWindow()
	oWin.IsMaximized = true' (ohne zu maximieren wird immer die letzte Fenstereinstellung genommen)
	oLayoutMng = oFrame.LayoutManager
	arElements = oLayoutMng.getElements()
	FOR i = LBound(arElements) TO UBound(arElements)
		IF arElements(i).ResourceURL = "private:resource/toolbar/formsnavigationbar" THEN
		ELSE
			oLayoutMng.hideElement(arElements(i).ResourceURL)
		END IF
	NEXT
	inDpiX = Int(1440 \ TwipsPerPixelX())
	inDpiY = Int(1440 \ TwipsPerPixelY())
	inx = Int(oWin.Size.Width * 100 * 96 / (inWidth * inDpiX))
	iny = Int(oWin.Size.Height * 100 * 96 / (inHeight * inDpiY))
	IF inx < iny THEN
		inZoom = inx
	ELSE
		inZoom = iny
	END IF
	ThisComponent.CurrentController.Sidebar.Visible = False
	ThisComponent.CurrentController.ViewSettings.ZoomValue = inZoom
	ThisComponent.CurrentController.ViewSettings.ShowRulers = False
	ThisComponent.CurrentController.ViewSettings.ShowParaBreaks = False
END SUB

In Base I search for the form, which needs the biggest width and biggest height when zoom in 100 %.
Then I set this variables in inWidth and inHeight. All Forms will be set by this values and max width / max height of the screen to the same zoom factor.

1 Like

Thanks a lot! I have to tweak a bit the formula but the fuction TwipsPerPixelX and TwipsPerPixelY is definitively what I was looking for!