BBC BASIC for Windows
Programming >> Graphics and Games >> Calling Michael Hutton
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1441558691

Calling Michael Hutton
Post by KenDown on Sep 6th, 2015, 4:58pm

I've been playing around with your "SplashScreen" program - can't remember where I got it from and can't find it on the Wiki or here - and have managed to get rid of the annoying blank between effects by having two dialog boxes and switching between them.

However in the REMs in the program you mention that you have managed to get it to work on more than one monitor - but that's the bit I can't work out. Can you give me any pointers, please?
Re: Calling Michael Hutton
Post by Michael Hutton on Sep 11th, 2015, 10:02pm

grin I've never been called by a topic in a forum before! Sorry, Ken I am a very infrequent visitor to this site.

I will take a look at it and see what I was saying. I think I do remember something about just pushing the position of the window beyond (left or right) the border of the screen but I may be wrong there. Let me check and I'll get back to you.

Michael

Re: Calling Michael Hutton
Post by Michael Hutton on Sep 11th, 2015, 10:35pm

Ah Ken, I remember now.... you can't set it to work on a specific monitor but it will default to open up on the same monitor that you open the program up in. Sorry about that.... I presume you want to control it..

I also presume you will have to mess around with this bit of code...
Code:
      REM RECT and MONITORINFO Structures
      _MONITOR_DEFAULTTONEAREST = &2
      DIM rc{ Left%, Top%, Right%, Bottom% }
      DIM mi{cbSize%, rcMonitor{} = rc{}, rcWork{} = rc{}, \
      \ dwFlags%, szDevice&(31)}
      mi.cbSize%=DIM(mi{})
      
      REM WINDOWPLACEMENT structure for use with "GetWindowPlacement"
      DIM wp{length%, flags%, showcmd%, minpos{x%,y%}, \
      \      maxpos{x%,y%}, normal{l%,t%,r%,b%}}
      wp.length% = DIM(wp{})
      
      REM Get the monitor info
            REM Calculate where to place the picture in dialog box units
      REM Works with different DPI values
      SYS "GetWindowPlacement", @hwnd%, wp{}
      wxpos% = wp.normal.l%
      wypos% = wp.normal.t%
      
      $$device%=mi.szDevice&()
      monitor$=$$device%
      monitor%=VAL(RIGHT$(monitor$,1))
      
      REM Calculate the position of the dialog
      IF monitor%=1 THEN
        IF wxpos%<(mi.rcMonitor.Right%-mi.rcMonitor.Left%)/2 THEN
          dxpos%=(mi.rcMonitor.Right%-mi.rcMonitor.Left%)/2-(wxpos%+xsize%/2)
        ELSE
          dxpos%=-(wxpos%-((mi.rcMonitor.Right%-mi.rcMonitor.Left%)-xsize%)/2)
        ENDIF
        IF wypos%<(mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)/2 THEN
          dypos%=(mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)/2-(wypos%+ysize%/2)
        ELSE
          dypos%=-(wypos%-((mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)-ysize%)/2)
        ENDIFSYS "MonitorFromWindow",@hwnd%,_MONITOR_DEFAULTTONEAREST \
      \ TO hMonitor%
      SYS "GetMonitorInfo", hMonitor%, mi{} TO ret%
      IF ret%=0 ERROR 100,"GetMonitorInfo failed"
      

      ELSE
        IF wxpos%<(mi.rcMonitor.Right%-mi.rcMonitor.Left%)/2+mi.rcMonitor.Left% THEN
          dxpos%=(mi.rcMonitor.Right%-mi.rcMonitor.Left%)/2+mi.rcMonitor.Left%-(wxpos%+xsize%/2)
        ELSE
          dxpos%=-(wxpos%-((mi.rcMonitor.Right%-mi.rcMonitor.Left%)+mi.rcMonitor.Left%-xsize%)/2)
        ENDIF
        IF wypos%<(mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)/2 THEN
          dypos%=(mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)/2-(wypos%+ysize%/2)
        ELSE
          dypos%=-(wypos%-((mi.rcMonitor.Bottom%-mi.rcMonitor.Top%)-ysize%)/2)
        ENDIF
      ENDIF
 


you could try messing with
Code:
SYS "MonitorFromWindow",@hwnd%,_MONITOR_DEFAULTTONEAREST \
      \ TO hMonitor%
      SYS "GetMonitorInfo", hMonitor%, mi{} TO ret%
      IF ret%=0 ERROR 100,"GetMonitorInfo failed"
      
 


I hope that helps a little bit. I hope I get what you are trying to do.

Michael

Re: Calling Michael Hutton
Post by KenDown on Sep 12th, 2015, 06:49am

Thanks, Michael. I'll investigate that code. Your reply is appreciated.