Dialog box Decoration property setting has no effect at runtime

As far as I’ve understood, when you set the property value With Title Bar to No the Title Bar (nor the X) shouldn’t appear when loading the Dialog. If you select No in design mode the Dialog is seen without the bar, but it seems that the setting is ignored at runtime as well as if you check it in the preview window.

This has no affect either:

    With myMsgDialog.Model
        .PositionX = (factor * oWindowPosSize.Width - .Width) / 2
        .PositionY = (factor * oWindowPosSize.Height - .Height) / 2
        .setPropertyValue("Decoration", False) 'Switching between False/True has no affect 
    End With

I don’t care if X works or not, I’m looking for a way to completely avoid the Title Bar from appearing.

Please upload ODT with example dialog and macro.

TestMsgDialog.odt (11.5 KB)

Unfortunately I didn’t discover the solution :-(.
Maybe the Popup window could help sometimes:

Sub showPopupWindow
	dim oDoc as object, oWindow as object, oVCur as object
	dim aRect as new com.sun.star.awt.Rectangle, oPopup as object, n&, c&
	oDoc=ThisComponent
	oWindow=oDoc.CurrentController.Frame.ComponentWindow
	oVCur=oDoc.CurrentController.ViewCursor 'view cursor

	aRect.X=400
	aRect.Y=100
	
	oPopup=CreateUnoService("stardiv.vcl.PopupMenu") 'or com.sun.star.awt.PopupMenu
	c=1
	oPopup.insertItem(c, "blabla 1", 0, c)
	oPopup.setCommand(c, "item" & c)
	c=2
	oPopup.insertItem(c, "blabla 2", 0, c)
	oPopup.setCommand(c, "item" & c)	

	n=oPopup.execute(oWindow, aRect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)
	if n>0 then 
		msgbox oPopup.getCommand(n)
	end if
End Sub

@KamilLanda

Thank you for your answer.
The PopupWindow you suggested would be perfect if I could handle it the same way I do with my Dialog, i.e. I could show the box without executing and then hide and destroy it when the Wait time has elapsed.

myMsgDialog.setVisible(True)
Wait 2000
myMsgDialog.setVisible(False)
myMsgDialog.Dispose()
ThisComponent.setModified(False)

Works fine under Windows!
Sans titre

@LibreOfficiant
Yes it works when using a Standard Dialog, but you can’t hide the Title Bar, at least I can’t do it (at least yet)

Would something such as the InfoBar suit you?
https://wiki.documentfoundation.org/ReleaseNotes/6.3#Core_.2F_General

IIRC you can close it past some elapsed time

@LibreOfficiant

Thx for your tip. I’ll look into it and see what it can offer me.

But from one thing to another. I did study possibilties to set event listeners to controls placed on the Pages of my MultiPage (I don’t set my Dialog to execute but only make it visible). I came to a conclusion that you can’t set keyEvent listener to controls because it affects directly to topWindow event listener I set. When firing a keyEvent it has such an effect that the key event firing tries to unactivate the topWindow eventhandler (i.e. it crashes, because it doesn’t recognize parameter it catches). Instead, you can set listeners/event handlers to e.g. TextBox text change and to ComboBox item change events. It’s a “bit” tricky of course, but you can make it work quite seamlessly. Here’s a simple demo:
Simple.odt (16.8 KB)
with just a dialog box, a text box, and a combo box, but you’ll easily get the idea.

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)

1 Like