When I open a Messagebox, it pops up in the center of the window.
Sometimes this covers up something I want to see in the center.
Is it possible to specify where the message box will be positioned when it opens?
Thanks,
Robert
The messagebox centers on its parent.
If you set the parent to 0 it will center on the screen(but it won't be modal)
otherwise, what ever you set the parent to(like w1) it will center on that window where ever it is located. That is the normal way and the messagebox is modal.
I played with it a minute and had w1 as the main window centered on the screen with a button.
I created a second window w2 as a @hidden 10x10 window off to the side.
when I pressed the button on w1 it opened a mb with w2 as the parent so the messagebox appear over on the side.
The drawback is that you don't have to close the message box to keep working with w1
but you could get around that by disabling w1 until the messagebox is cleared
Might be a more "pro" way of doing it but this is my quick example.
If you position the hidden window off screen the messagebox will not leave the screen.
In the example I'm forcinb the messagebox to the upper right corner of the screen.
AutoDefine "off"
DECLARE IMPORT,EnableWindow(hwnd as UINT,bEnable as INT),INT
window w1,w2
openwindow w1,0,0,300,300,@size,0,"Test...",&hnd
CONTROL w1,@button,"Test",4,100,50,20,0,10
openwindow w2,5000,0,10,10,@hidden,0,"",&hnd2
waituntil w1.hwnd=0
end
sub hnd
select @class
case @idclosewindow
closewindow w2
closewindow w1
case @IdCreate
centerwindow w1
case @IDCONTROL
select @CONTROLID
case 10
if @notifycode=0
EnableWindow(w1.hwnd,0)
MESSAGEBOX(w2,"Can't read file","error")
EnableWindow(w1.hwnd,1)
endif
endselect
endselect
return
endsub
sub hnd2
select @class
case @idclosewindow
closewindow w2
case @IdCreate
endselect
return
endsub
Hope this helps
LarryMc
Thanks very much, Larry.
This is very nice, just what I need.
-- Robert