PDA

View Full Version : Positionning Inputbox$ , MsgBox popup window



justin045
23-11-2024, 00:41
Hello everybody (second this day) :D



I wonder if there is a way to force the place of UI boxes in the screen, and to choose the screen when multiple displays are used ?
And also have a control of the size of font in the input box ?



Many thanks for help.


Justin

Petr Schreiber
27-11-2024, 11:45
Hi Justin,

thank you for your question!

I think you could re-use the following functions from TBGL module for the moment:

TBGL_DisplayGetCount()
TBGL_DisplayGetInfo( displayNumber, variableWidth, variableHeight [, variableDepth] )
TBGL_SendWindowToDisplay( windowHandle, displayNumber [, newX [, newY]] )
TBGL_GetWindowDisplay( hWnd )

I currently sadly do not have multi-display setup, so cannot test if it works correctly for UI module windows.

Let us know!


Petr

justin045
28-11-2024, 00:44
Hi Justin,

thank you for your question!

I think you could re-use the following functions from TBGL module for the moment:

TBGL_DisplayGetCount()
TBGL_DisplayGetInfo( displayNumber, variableWidth, variableHeight [, variableDepth] )
TBGL_SendWindowToDisplay( windowHandle, displayNumber [, newX [, newY]] )
TBGL_GetWindowDisplay( hWnd )

I currently sadly do not have multi-display setup, so cannot test if it works correctly for UI module windows.

Let us know!

Petr

Hi Petr,

Thanks for the answer.

But I don't see how to get the Handle for InputBox who returns a string, and when the window is created the script is suspended until the box is closed (with or without an answer) .
And MsgBox, as seen in TBGL_SendWindowToDisplay help page retuns a number, always '1' in all my tests.
I made this test script.


uses "console","tbgl"
Dim ConsoleHandle as DWord
ConsoleHandle = Console_GetHandle
printl " consolehandle = " , consolehandle
hwnd = consolehandle


Dim hWnd As DWord
Dim displaysFound, display, width, height, bitDepth As Long
dim retcode as long

'...


displaysFound = tbgl_DisplayGetCount()
retcode = MsgBox hWnd, "Found "+Format$(displaysFound)+" display(s), TBGL window is on no."+Format$(TBGL_GetWindowDisplay(hWnd) )
printl "phase1 " , retcode

For display = 1 To displaysFound
tbgl_DisplayGetInfo(display, width, height, bitDepth)

retcode = MsgBox hWnd, "Display "+Format$(display) + ": " + width + "x" + height + " " + bitDepth +"bit color"
printl "phase2 " , retcode
Next

If displaysFound = 1 Then
retcode = MsgBox hWnd, "Just one display found"
printl "phase3 ", retcode
Else
For display = 1 To displaysFound
printl " before sendwindow"
tbgl_SendWindowToDisplay(hWnd, display, display * 200, display * 10)
printl " after sendwindow"
retcode = MsgBox hWnd, "TBGL window sent to display no."+Format$(display)
printl "phase4" , retcode
Sleep 2000
Next
End If

printl "waitkey"
WaitKey(100)


This script opens a console window which is effectively moved around screens, but I still don't see how to get the 'hWnd' of InputBox$ and MsgBox.


Best regards

Justin

Petr Schreiber
28-11-2024, 20:36
Hi Justin,

I see, thank you for the clarification.

Based on the current design of InputBox$ and MsgBox you cannot retrieve their handles (they are blocking calls), however, you can try this "trick":
- create tiny dialog on desired display
- pass the handle of this tiny dialog as parent to inputBox or MsgBox (for both functions it is the optional hParent parameter)


Petr