[Closed] Set messagebox position
whats your solution?
Tried UIAssesor I reelaize that I can get only handle not dialog itself.
Is there a way to get dialog from handle for setDialogPos?
the mxs built-in message box is a modal window (not a rollout dialog). so you should use Win API (or its mxs partial implementation – windows struct) to move and place window. As mentioned above – windows.setwindowpos
windows prevent other processes from obtaining instances , you can only get instance of created by yourself
there’s a dotnet project to break through this limitation on GitHub
if you want to set pos only , you can use ‘windows.setWindowPos ’
fn ShowMB msg pos: title: =
(
if pos == unsupplied then
(
messageBox msg title:title
)
else
(
struct TMP
(
pos,
fn OnWindow =
(
local hwnd = DialogMonitorOPS.GetWindowHandle()
if hwnd != undefined do
(
local data = windows.getHWNDData hwnd
if data[4] == "#32770" do
(
local prev_pos = windows.getWindowPos hwnd
try
(
windows.setWindowPos hwnd pos.x pos.y prev_pos.w prev_pos.h true
) catch()
)
)
true
)
)
t = TMP pos:pos
DialogMonitorOPS.RegisterNotification t.OnWindow id:#customMsgBox
DialogMonitorOPS.Enabled = true
messageBox msg title:title
DialogMonitorOPS.Enabled = false
DialogMonitorOPS.UnRegisterNotification id:#customMsgBox
)
)
ShowMB "hellow" pos:[150,0 ] title:"world"
THanks! it worked like charm.
But, I don’t understand how put function in try/catch make it work.
It isn’t the try catch block that make it work.
In order to move messagebox you need to provide window handle of messagebox to windows.setwindowpos function. And the simplest way to obtain that handle is to use DialogMonitorOps.