In my Quickwin projects I usually create a child window using SETSIZEQQ, often followed by SETWINDOWCONFIG so that the visible and virtual window sizes are the same, and there are no scroll bars. In another part of the program (or even in a totally separate library routine), which is too separated to conveniently pass the window width and height, I need to inquire the window size. The natural way to do this is with GETWSIZEQQ. Unfortunately, this only returns the right width when the virtual window is larger and the visible window has scroll bars. If there are no scroll bars, the width returned is 2 or 3 columns smaller--it's as though GETWSIZEQQ always assumes there is a vertical scroll bar whether it's actually there or not.
The following program demonstrates this:
! Demonstration of opening, sizing, locating a child window in Quickwin
PROGRAM WindowDemo USE IFQWIN IMPLICIT NONE TYPE (QWINFO) :: winfo TYPE (WINDOWCONFIG) :: wc INTEGER(4) :: i4 LOGICAL(4) :: l4 CHARACTER(50) :: ruler ruler = '----+----1----+----2----+----3----+----4----+----5' ! Initialize window and set unit number.. OPEN (1, FILE='USER') ! Open a 40w x 20h visible window. winfo.X = 0 ! Starting column within project frame winfo.Y = 0 ! Starting row within project frame winfo.W = 50 ! Window width in characters winfo.H = 20 ! Window height in text rows winfo.TYPE = QWIN$SET i4 = SETWSIZEQQ (1, winfo) ! Can the correct width be inquired? i4 = GETWSIZEQQ (1, QWIN$SIZECURR, winfo) WRITE (1, *) 'Width reported by GETWSIZEQQ =', winfo.W ! Reports 50 - OK WRITE (1, '(A)') ruler(1:winfo.W) READ (1, *) ! Set width of virtual window same to eliminate scroll bars. ! (Note: this erases any text in the window.) wc.NUMTEXTCOLS = 50 wc.NUMTEXTROWS = 20 l4 = SETWINDOWCONFIG (wc) IF (.NOT.l4) l4 = SETWINDOWCONFIG (wc) !!WRITE (1, '(A)') ruler(1:wc.NUMTEXTCOLS) WRITE (1, *) 'Scroll bars are now gone' ! Can the correct width be inquired? i4 = GETWSIZEQQ (1, QWIN$SIZECURR, winfo) WRITE (1, *) 'Width reported by GETWSIZEQQ =', winfo.W ! WRITE (1, '(A)') ruler(1:winfo.W) READ (1, *) l4 = GETWINDOWCONFIG (wc) WRITE (1, *) 'Width reported by GETWINDOWCONFIG =', wc.NUMTEXTCOLS ! WRITE (1, '(A)') ruler(1:wc.NUMTEXTCOLS) READ (1, *) WRITE (1, *) 'Note GETWSIZEQQ should not be used to get window size' END PROGRAM WindowDemo
There may be a similar problem with the window height (I haven't investigated). GETWINDOWCONFIG can be used to inquire the window width as in the example above, but in general that is not useful because it returns the virtual window size, which may be different from the visible window size, and there is apparently no way to determine this. This turns out to be quite problematic. In fact, GWSIZEQQ seems to be pretty useless. Can it be fixed?