Silverfrost Forums

Welcome to our forums

Size of child window

9 Apr 2013 11:18 #11999

From my main window a second window is opened to display the graphical output. Using the GET_WINDOW_LOCATION to determine the size results in WIDTH and HEIGHT being negative. Below is some test code.

Until now the application was a single window. Adding a main window to the application is new to me.

Question: 1.) Why is the result negative for the size? 2.) %hw gives strange numbers for the handle - is the correct?

Jacques

winapp 
program enum 
   use mswin 
   implicit none 
   integer :: i,ctrl,ou
   EXTERNAL :: cb_func
   ctrl = -1
   ou = 6
   i=winio@('%ca[Child window size]&') 
   i=winio@('%sy[thin_border]&')
   i=winio@('%bg[BTNFACE]&')
   i=winio@('%ob[depressed]%40.20cw[vscroll]%cb&',0)
   i=winio@('%lw%ff%nl&',ctrl)
   i=winio@('%^bt[Show plot]',cb_func)
end program enum

integer function cb_func()
  implicit none
  INCLUDE 'clearwin.ins'
  integer :: ou
  integer*4 WIDTH, HEIGHT,X ,Y, handle
  INTEGER*4 I,J
  integer*4 isdepth,iswidth,ixcentre,iycentre
  integer*4 ix(10000),iy(10000),colour
  real*8     fac,xc,yc, xr, yr
!
!     get graphics window dimensions
  i = winio@('%ww&')
  i = winio@('%sy[3d_depressed]&')
  i = winio@('%ca[Slot mmf]&')
  i = winio@('%gr&',800,600)
  i = winio@('%hw',handle)
  call GET_WINDOW_LOCATION@(handle,X,Y,WIDTH, HEIGHT)
  write(*,*) handle,WIDTH, HEIGHT

  cb_func = 1
  return
end
9 Apr 2013 12:18 #12000

The handle looks OK to me. The reason for the strange results is that the window has already closed by the time you call get_window_location@. So the handle is no longer valid.

You could use %lw or make the call in a %sc callback.

9 Apr 2013 12:59 #12001

If I understood you correctly I can try to use %lw.

I tried the %lw and still get invalid dimensions. I also tried get_graphics_resolution. I think I miss the concept of the window closing before it get to the size command. The last command is the OK button.

How should I use the %lw command?

winapp
program enum 
   use mswin 
   implicit none 
   integer :: i,ctrl
   EXTERNAL :: cb_func
   i=winio@('%ca[Child window size]&') 
   i=winio@('%sy[thin_border]&')
   i=winio@('%bg[BTNFACE]&')
   i=winio@('%ob[depressed]%40.20cw[vscroll]%cb&',0)
   i=winio@('%lw%ff%nl&',ctrl)
   i=winio@('%^bt[Show plot]',cb_func)
end program enum

integer function cb_func()
  implicit none
  INCLUDE 'clearwin.ins'
  integer :: crtl,i
  integer*4 WIDTH, HEIGHT,X ,Y, handle
!
!     get graphics window dimensions
  i = winio@('%ww&')
  i = winio@('%sy[3d_depressed]&')
  i = winio@('%ca[Slot mmf]&')
  i = winio@('%hw&',handle)
  i = winio@('%`gr%lw&',800,600,handle,crtl)
  call GET_WINDOW_LOCATION@(handle,X,Y,WIDTH, HEIGHT)
  call DRAW_filled_RECTANGLE@(0,0,20,20,RGB@(255,0,0))
  i=winio@('%ff%cn%tt[OK]')
  cb_func = 1
  return
end
9 Apr 2013 2:31 #12002

The %cw window displays the results...

winapp 
program enum 
   use mswin 
   implicit none 
   integer :: i,ctrl,ou 
   EXTERNAL :: cb_func 
   ctrl = -1 
   ou = 6 
   i=winio@('%ca[Child window size]&') 
   i=winio@('%sy[thin_border]&') 
   i=winio@('%bg[BTNFACE]&') 
   i=winio@('%ob[depressed]%40.20cw[vscroll]%cb&',0) 
   i=winio@('%lw%ff%nl&',ctrl) 
   i=winio@('%^bt[Show plot]',cb_func) 
end program enum 

integer function cb_func() 
  implicit none 
  INCLUDE 'clearwin.ins' 
  integer :: ou 
  integer*4 WIDTH, HEIGHT,X ,Y, handle 
  INTEGER*4 I,J,ctrl 
  integer*4 isdepth,iswidth,ixcentre,iycentre 
  integer*4 ix(10000),iy(10000),colour 
  real*8     fac,xc,yc, xr, yr 
! 
!     get graphics window dimensions 
  i = winio@('%ww&') 
  i = winio@('%sy[3d_depressed]&') 
  i = winio@('%ca[Slot mmf]&') 
  i = winio@('%gr&',800,600) 
  i = winio@('%hw%lw',handle,ctrl) 
  call GET_WINDOW_LOCATION@(handle,X,Y,WIDTH, HEIGHT) 
  write(*,*) handle,WIDTH, HEIGHT 

  cb_func = 1 
  return 
end
9 Apr 2013 3:14 #12005

Thanks Paul!

As usual the detail...

Anyway, the application now works. I can scale the output to the graphics area.

[URL=http://imageshack.us/photo/my-images/10/slotmmf.jpg/]http://img10.imageshack.us/img10/7019/slotmmf.jpg[/URL]

11 Apr 2013 6:20 #12038

I am always amazed by the possibilities of ClearWin. I used the export_image function to save plots at different time instants. The steps to make an animated gif can be done online.

[URL=http://imageshack.us/photo/my-images/849/outputwznkva.gif/]http://img849.imageshack.us/img849/8167/outputwznkva.gif[/URL]

Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]

Please login to reply.