Как закрыть не модальное диалоговое окно?

Автор cyberbob, 2 декабря 2020, 17:49

0 Пользователи и 1 гость просматривают эту тему.

cyberbob

Добрый день

Есть не модальное диалоговое окно FormFind, которое выводится на эран с помощью SetVisible(True).
В этом окне есть кнопка BtnCancel, которая окно закрывает.

Dim fDialog As Object
Dim fdShown As Boolean

Sub BtnFind_Click()
  If Not fdShown Then
    fdShown = True
    DialogLibraries.LoadLibrary("Standard")
    fDialog = CreateUnoDialog(DialogLibraries.Standard.FormFind)
'    fDialog.Execute()
    fDialog.SetVisible(True)
    Do While fdShown
      Wait(20)
    Loop
  End If
End Sub

Sub BtnCancel_Click()
  fdShown = False
  fDialog.Dispose()
End Sub


Как сделать, чтобы диалоговое окно закрывалось, также, и при нажатии на крестик в правом верхнем углу?
Какое событие наступает при нажатии на этот самый крестик?

rami

Цитата: cyberbob от  2 декабря 2020, 17:49Какое событие наступает при нажатии на этот самый крестик?
windowClosing


Dim fDialog As Object
Dim fdShown As Boolean

Sub BtnFind_Click()
Dim oLis
  If Not fdShown Then
    fdShown = True
    DialogLibraries.LoadLibrary("Standard")
    fDialog = CreateUnoDialog(DialogLibraries.Standard.FormFind)

'Слушатель окна
oLis = CreateUnoListener("Lis_", "com.sun.star.awt.XTopWindowListener")
fDialog.addTopWindowListener(oLis)

'    fDialog.Execute()
    fDialog.SetVisible(True)
    Do While fdShown
      Wait(20)
    Loop
  End If
End Sub

Sub BtnCancel_Click()
  fdShown = False
  fDialog.Dispose()
End Sub

Sub BtnAct_Click()
  MsgBox "Hello, World!!"
End Sub


'Методы слушателя:
Sub Lis_windowOpened(oEvent)
End Sub

Sub Lis_windowClosing(oEvent)
fdShown = False
oEvent.Source.Dispose()
'fDialog.Dispose()
End Sub

Sub Lis_windowClosed(oEvent)
End Sub

Sub Lis_windowMinimized(oEvent)
End Sub

Sub Lis_windowActivated(oEvent)
End Sub

Sub Lis_windowDeactivated(oEvent)
End Sub

Sub Lis_windowNormalized(oEvent)
End Sub

Sub Lis_disposing(oEvent)
End Sub

eeigor

cyberbob, выполните код от А.Питоньяка.
Sub InspectListenerMethods()
Dim sPrefix$
Dim sService$
Dim vService

sPrefix = "Lis_"

sService = "com.sun.star.awt.XTopWindowListener"  '<<<

vService = CreateUnoListener(sPrefix, sService)
Call DisplayDbgInfoStr(vService.dbg_methods, ";", 35, "Methods")
End Sub

Sub DisplayDbgInfoStr(sInfo$, sSep$, nChunks%, sHeading$)
Dim aInfo()  'array to hold each string
Dim i As Integer  'index vaEvent Listeners & Handlers - Backupriable
Dim j As Integer  'junk integer variable for temporary values
Dim s As String  'holds the portion that is not completed

s = sInfo
j = InStr(s, ":")  'initial colon
' Remove portion up to the initial colon.
If j > 0 Then Mid(s, 1, j, "")
Do
' Split string based on delimiter.
' NOTE: The optional argument nChunks limits the number of strings returned.
aInfo() = Split(s, sSep, nChunks)
' Grab the last piece.
s = aInfo(UBound(aInfo()))  'contains the rest if there were too many
' If there were not, then clear s.
If InStr(s, sSep) < 1 Then
s = ""
Else
'If there was a delimiter then change array dimension to remove the extra last piece.
ReDim Preserve aInfo(nChunks - 2)
End If

' Look at each piece to remove leading and trailing spaces.
For i = LBound(aInfo()) To UBound(aInfo())
aInfo(i) = Trim(aInfo(i))
' Some have an extra new line that should be removed.
j = InStr(aInfo(i), Chr$(10))
If j > 0 Then Mid(aInfo(i), j, 1, "")
Next
MsgBox Join(aInfo(), Chr$(10)), 0, sHeading
Loop Until Len(s) = 0
End Sub

Ubuntu 18.04 LTS • LibreOffice 7.5.1.2 Community

cyberbob