Silverfrost Forums

Welcome to our forums

closing a ClearWin window

1 Feb 2010 3:17 #5848

I open a ClearWin window using

    nTHandle = Create_Window@ ( Caption,
 1                               n_TextW_posnX, n_TextW_posnY,
 2                               n_TextW_szeX, n_TextW_szeY )

The created window has the usual minimise, resize and close buttons at the top right.

I close the window using 'call Destroy_Window@ ( nTHandle )', in response to a user command.

However, the user can also close the window using the 'close' button.

Does your compiler set or change a flag somewhere that I can interrogate to check whether the window has been closed in this way? Or do I have to use %cw and %cc and set my own flag?

Norm Campbell

1 Feb 2010 8:28 #5850

There is no flag a such.

One way to see if a window is still open is to use the value returned by create_window@ (which is the Windows handle HWND for the window).

FindWindow('SalfordClass', 0) will return this handle if the window is still open otherwise it will return zero. This assumes you only have one ClearWin window open at a time otherwise you will need to use FindWindowEx. FindWindow and FindWindowEx are Windows API functions.

1 Feb 2010 12:33 #5852

Thanks, Paul, for the prompt reply.

You'll see from the code that I've pasted below that I'm a very old-fashioned programmer (a statistician who still writes Fortran code) -- I even occasionally use 'go to's when I'm coding, if I think that it makes the logic easier to follow -- and I don't have any experience with accessing Windows API functions (not explicitly, anyway).

Is it asking too much to have you spend a couple of minutes to make the specific changes that are needed -- eg the appropriate 'include' statement; any 'external' statement; and the form of the call to FindWindow at statement 200 -- so that the code will run.

Many thanks

Norm

  subroutine v3D_query_example (  )
  
  use mod_1_control

  include <windows.ins> 
              
  integer*2 n_TextW_szeX, n_TextW_szeY, n_TextW_posnX, n_TextW_posnY

  n_TextW_szeX = 215     
  n_TextW_szeY = 150

  n_TextW_posnX = m_wndw_1_width
  
  n_TextW_posnY = m_wndw_1_height
                   

c m_wndw_1_width, *.height, wndw_Caption set in mod_1_control

  nTHandle = Create_Window@ ( wndw_Caption,
 1                            n_TextW_posnX, n_TextW_posnY,
 2                            n_TextW_szeX, n_TextW_szeY )

  call Open_to_Window@ ( 8, nTHandle ) 

c motionpassive ( mouse_X, mouse_Y ) used to update mouse X,Y

  nCmse_X = mouse_X
  nCmse_Y = mouse_Y

100 call yield_program_control@ ( y_temporarily )

  nmse_X = mouse_X
  nmse_Y = mouse_Y
   
  if ( nmse_X .ne. nCmse_X .or. nmse_Y .ne. nCmse_Y ) go to 200

  nCmse_X = nmse_X
  nCmse_Y = nmse_Y

  go to 100          

200 if ( nmse_X .ge. m_wndw_1_width - 15 .and. nmse_Y .le. 15 ) 1 go to 300

c exit loop if mouse in top-right corner -- pseudo close button

c want to change code to monitor window status to 'go to 300' if nTHandle window is closed

  nCmse_X = nmse_X
  nCmse_Y = nmse_Y

  X_val = nmse_X 

  Y_val = nmse_Y 

  call Clear_Window@ ( nTHandle )
  
  write ( 8, '( a, '' : '', i8 )' ) 'X value', nmse_X
  
  write ( 8, '( a, '' : '', i8 )' ) 'Y value', nmse_Y

  go to 100

300 call Destroy_Window@ ( nTHandle )

  nTHandle = 0

  return
  end
1 Feb 2010 8:15 #5853
WINAPP
INCLUDE <windows.ins> 
STDCALL MyFindWindow 'FindWindowA' (STRING,VAL):INTEGER*4
nTHandle = Create_Window@('Caption',0,0,200,200)
CALL Open_to_Window@(8,nTHandle)
!Peocessing goes here
IF(MyFindWindow('SalfordClass', 0) == nTHandle) WRITE(8,*) 'This window is still open'
END
1 Feb 2010 11:44 #5854

Many thanks yet again, Paul.

There is no way that I could ever have worked that out by myself.

Norm

Please login to reply.