October 30, 2025, 05:21:33 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Messagebox location

Started by Robert34, May 16, 2011, 08:33:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Robert34

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

LarryMc

May 16, 2011, 10:26:18 PM #1 Last Edit: May 16, 2011, 10:28:56 PM by LarryMc
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

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Robert34

Thanks very much, Larry.
This is very nice, just what I need.

-- Robert