Silverfrost Forums

Welcome to our forums

negative values for GET_WINDOW_LOCATION@ ?

12 Nov 2013 9:08 #13311

I have some problems with the positioning of windows using the %sp command with multiple screens, when the left screen is not the primary screen. In this case the command GET_WINDOW_LOCATION@ returns positive x-values for windows on the primary screen, starting with '0' on the left border on the primary screen, but for windows on the secondary screen it returns always '0' instead of negative values. Is there a way to get the correct (i.e. negative) postion of those windows?

Regards

Ralf

20 Dec 2014 10:12 #15238

As of this writing, that is not the case, and negative values are returned for a screen that is secondary and logically on the right side of the main screen.

21 Dec 2014 2:59 #15239

Ralf, A couple of programs which may help:

      winapp
      STDCALL GETSYSTEMMETRICS 'GetSystemMetrics' (VAL):INTEGER*4

      integer*4 SM_CXSCREEN , SM_CYSCREEN, SM_XVIRTUALSCREEN,              &
                SM_YVIRTUALSCREEN, SM_CXVIRTUALSCREEN,                     &
                SM_CYVIRTUALSCREEN, SM_CMONITORS, SM_SAMEDISPLAYFORMAT


      SM_CXSCREEN          =  0
      SM_CYSCREEN          =  1
      SM_XVIRTUALSCREEN    = 76
      SM_YVIRTUALSCREEN    = 77
      SM_CXVIRTUALSCREEN   = 78
      SM_CYVIRTUALSCREEN   = 79
      SM_CMONITORS         = 80
      SM_SAMEDISPLAYFORMAT = 81

      Print*,'Number of monitors'
      print *,GetSystemMetrics(SM_CMONITORS)
      print *,'Same display format'
      print *,GetSystemMetrics(SM_SAMEDISPLAYFORMAT)
      print *,'Coordinates of left and top of virtual screen'
      print *,GetSystemMetrics(SM_XVIRTUALSCREEN)
      print *,GetSystemMetrics(SM_YVIRTUALSCREEN)
      print *,'Width and height of virtual screen'
      print *,GetSystemMetrics(SM_CXVIRTUALSCREEN)
      print *,GetSystemMetrics(SM_CYVIRTUALSCREEN)
      print *,'Width and height of primary monitor'
      print *,GetSystemMetrics(SM_CXSCREEN)
      print *,GetSystemMetrics(SM_CYSCREEN)

      end

For my computer with twin screens (Primary = 1920 x 1080 and secondary 1280 x 1024), this returns: Number of monitors 2 Same display format 1 Coordinates of left and top of virtual screen 0 0 Width and height of virtual screen 3200 1080 Width and height of primary monitor 1920 1080

Second program places two windows, one on each screen and determines their size and position. Which matches the requested information. The second screen is derived from the above program.

      winapp
      include <windows.ins>
      ix1 = 200
      iy1 = 100
      icontrol1 = 1
      i=winio@('%ww%ca[Window1]%sz&',ix1,iy1)
      i=winio@('%sp%hw%lw',0,0,ihandle1,icontrol1)
      ix2 = 400
      iy2 = 100
      icontrol2 = 1
      i=winio@('%ww%ca[Window2]%sz&',ix2,iy2)
      i=winio@('%sp%hw%lw',1921,10,ihandle2,icontrol2)
      call get_window_location@(ihandle1,iposx1,iposy1,iwidth1,iheight1)
      call get_window_location@(ihandle2,iposx2,iposy2,iwidth2,iheight2)
      print *,'Position and size of window 1'
      print *,iposx1,iposy1,iwidth1,iheight1
      print *,'Position and size of window 2'
      print *,iposx2,iposy2,iwidth2,iheight2

      end

Hope this helps. Note when get_window_location@ and move_window@ are used on individual controls, the positions are within the window, not screen position, but one refers to the top corner of the outer edge of the window and the other to the top corner of the available window space underneath any menu which may be used and some trickery is required to harmonise the two. See this post https://forums.silverfrost.com/Forum/Topic/2316&highlight=movewindow

See this link for the explanation of the GetSystemMetrics function http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385 Ian

Please login to reply.