Topic: Behaviour of SetCurrentWindow() in Appgraphics
I'm trying to restore an application from the past millennium, which includes handling input/output on a console, as well as intermittent plotting. In other words, it is necessary to switch back and forth (changing focus) between console and plot windows several times.
Unfortunately, the SetCurrentWindow() subroutine does not seem to work quite as described in the documentation, as can be seen from the example below. Upon initiation, the graphic window becomes active as expected, but after having intermittently activated the console by clicking on it, a subsequent call to SetCurrentWindow() will NOT give full focus back to the graphical window. Although the window accepts output, the title bar remains gray and a call to Getch() to read input does not work, without clicking it. Am I missing something here?
Also, it would be nice if there was a call to give focus back to the console, without clicking on the window.
! Testing windowing functions
INTEGER :: GraphID,PlotWidth,PlotHeight,PXpos,PYpos,IOWait
CHARACTER :: GraphHeader*18
LOGICAL :: CloseFlag
DATA GraphHeader/' * Plot window * '/
DATA PlotWidth/800/,PlotHeight/600/,PXpos/600/,PYpos/50/ ! Size and location in pix
DATA CloseFlag/.FALSE./ ! I want to close myself
! Ext. console selected in project options. Write something.
! Now open plot window and plot something
GraphID = InitWindow(PlotWidth, PlotHeight, GraphHeader,PXpos,PYpos,Closeflag)
! Now I would want to bring ext. console to front again and write ID of plot window
! CALL SetCurrentWindow(How?)
WRITE (*,2000) GraphID
! Userwait in ext. console
CALL SetCurrentWindow(GraphID) ! Re-focus, bring plot window to front and plot some more
! Use Getch for Userwait in plot window
CALL OutTextXY(300,500,' Hit a key to close this window ')
READ(*,*) ! To ensure pause when run as executable
1000 FORMAT(//,20X,' Hello world!',///)
2000 FORMAT( 20X,' GraphID = ',I3,' Hit a key...')
END PROGRAM AGtest