Create a Dialog from the program

Hello to all

I would like to create a basic programmatic Dialog, with a text or label control.

On this site I found this example:

REM  *****  BASIC  ******************************************************************************

Sub Example_Dialog
	dim oFrmLesson, dlg, window, ctlmdl as object
	oFrmLesson  = createunoservice("com.sun.star.awt.UnoControlDialogModel")
	with oFrmLesson 
		.name = "checkwriter"
		.title = "Check Writer"
		.positionx = 170
		.positiony = 70
		.width = 300
		.height = 100
	end with

	dlg = CreateUnoService("com.sun.star.awt.UnoControlDialog")
	dlg.setModel(oFrmLesson )
	window = CreateUnoService("com.sun.star.awt.Toolkit")
	dlg.createPeer(window, null)

	ctlmdl = oFrmLesson.createinstance("com.sun.star.awt.UnoControlFixedTextModel")
	with ctlmdl
		.name = "HI"
		.label = "HI"
		.positionx = 10
		.positiony = 10
		.width = 20
		.height = 20
	end with

	oFrmLesson.insertbyname("HI", ctlmdl)

	' insert about 30 more controls...
	' resize dialog as appropriate (varies)...

	dlg.execute()	

End Sub

It works.
But, when I hover my mouse on the windows taskbar and I’m over the document that contains this macro, it shows the dialog.
What can I do?
Greetings to all

Could you upload a file with the specified effect?

You have to click on the button at least once, then you can see the effect
Yes here it is
Dialog_20_230821.ods (10.1 KB)

Checked in configuration Win 10, LO 7.2.0.4. I don’t see any unusual behavior.
The dialog in your example is launched as a modal window. It will remain on the screen until you close it (in this case, by clicking on the “cross” at the top right of the window or Alt + F4).

I don’t know the English language well. It can be difficult to make myself understood

  1. Open and then close the dialog box;
  2. go with the mouse pointer on the windows taskbar;
  3. pause with the mouse over the Calc file icon “Dialog_20_230821.ods”
  4. The dialog box is displayed as long as the mouse is above the system tray icon

Hello
and thanks

The reason probably is you use the Null in the dlg.createPeer(window, null). The Null in this command means: peer dialog to the Desktop and no to the ThisComponent window.
For peer to the ThisComponent window it is: dlg.createPeer(window, ThisComponent.CurrentController.Frame.ContainerWindow).
It is described in the example. There is also centered dialog to the ThisComponent window. And also listeners for the dialog window and one action button.
centered-dialog-with-listeners.ods (11.3 kB)

As far as I know, Oxford University Press employees are not the majority of the participants in this forum. :smile:

I can now reproduce your effect. Interestingly, the same applies to the dynamic dialog called by the Inspect macro from A. Pitonyak’s book OOME_4_0.odt.