I finally found a way to trigger a scheduled notification in the LibreOffice project that cannot be closed by clicking the X button.
REM ***** BASIC *****
Global bSetBox As Boolean
Sub TestMessage
ShowMessage 1, "Very important notification"
End Sub
Sub ShowMessage(choice As Integer, msgstr As String)
If bSetBox Then Exit Sub
If Not bSetBox Then bSetBox = True
Dim oToolkit As Object, oParent As Object
Dim oWinDesc As New com.sun.star.awt.WindowDescriptor
Dim oWindow As Object
oToolkit = CreateUnoService("com.sun.star.awt.Toolkit")
oParent = ThisComponent.CurrentController.Frame.ContainerWindow
Dim oCC As Object, oPosSize As Object
Dim boxW As Long, boxH As Long
Dim centerX As Long, centerY As Long
oCC = ThisComponent.getCurrentController()
oPosSize = oCC.ComponentWindow.getPosSize()
boxW = 250
boxH = 50
centerX = (oPosSize.Width - boxW) / 2
centerY = (oPosSize.Height - boxH) / 2
With oWinDesc
.Type = com.sun.star.awt.WindowClass.SIMPLE
.WindowServiceName = "floatingwindow"
.ParentIndex = -1
.Parent = oParent
.Bounds = CreateUnoStruct("com.sun.star.awt.Rectangle")
.Bounds.X = centerX
.Bounds.Y = centerY
.Bounds.Width = boxW
.Bounds.Height = boxH
.WindowAttributes = com.sun.star.awt.WindowAttribute.SHOW
End With
oWindow = oToolkit.createWindow(oWinDesc)
oWindow.setBackground(&HFFFFFF)
Dim oTextDesc As New com.sun.star.awt.WindowDescriptor
Dim oTextWindow As Object
With oTextDesc
.Type = com.sun.star.awt.WindowClass.SIMPLE
.WindowServiceName = "fixedtext"
.ParentIndex = -1
.Parent = oWindow
.Bounds = CreateUnoStruct("com.sun.star.awt.Rectangle")
.Bounds.X = 0
.Bounds.Y = (boxH - 26) / 2
.Bounds.Width = boxW
.Bounds.Height = 26
.WindowAttributes = 1 + 4
End With
oTextWindow = oToolkit.createWindow(oTextDesc)
oTextWindow.setText(msgstr)
Dim oFontDesc As New com.sun.star.awt.FontDescriptor
With oFontDesc
.Name = "Arial"
.Height = 12
.Weight = com.sun.star.awt.FontWeight.BOLD
End With
oTextWindow.setProperty("FontDescriptor", oFontDesc)
Select Case choice
Case 0
oTextWindow.setProperty("TextColor", RGB(0, 0, 0))
Case 1
oTextWindow.setProperty("TextColor", RGB(255, 0, 0))
Case 2
oTextWindow.setProperty("TextColor", RGB(0, 255, 0))
'Case etc
Case Else
End Select
oTextWindow.setProperty("Align", 1)
oWindow.setVisible(True)
oTextWindow.setVisible(True)
Dim startTicks : startTicks = getSystemTicks
Do While getSystemTicks < startTicks + 3000 : Loop
oTextWindow.dispose
oWindow.dispose()
bSetBox = False
End Sub
Sub OnClose
ThisComponent.setModified(False)
end Sub
MessageWindow.odt (15.2 KB)