forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem getting a Window at MAXIMUM Useable Screen Size
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Thu Apr 23, 2015 8:41 pm    Post subject: Problem getting a Window at MAXIMUM Useable Screen Size Reply with quote

What are the units of the values returned by
CALL GET_WINDOW_LOCATION@ ?

I tried it and in one program the values I got returned are HUGE ! (much bigger than the screen pixel size).

Then I created the small test program below and the values coming from it are ... TINY (38x 16 !)

It's supposed to:

a) create a MAXIMISED Window.
b) obtain the dimensions of that window
then:-
c) destroy that window
d) create a new window of the same maximum dimensions.

I'm trying this because I couldn't find a direct way of creating a window which covers the WHOLE screen EXCEPT the TASK Bar !

Note - I tried the DESTROY_WINDOW command to delete the 1st window before creating the second. It doesn't work and I assume that's because it works on Clearwin windows only and not Clearwin+ windows.
Becuse the DESTROY doesn't work you have to first close that window.
Then, the second created window (top left ) is created (far too small, not even 38x16)
And also the window printing the dimensions obtained.

Note the h and w values are small and NEGATIVE ! Now, hy is THAT ?

Note also, the MAXIMISE option of %ww doesn't do what I'm looking for as I need to use %sz (%ch related) in the main code also, and the 2 seem incompatible for some reason.

Here ìs the test code

It's clear I'm doing something stupid or not understanding something fundamental.

Code:


! Test Routine to Get MAX Window size
!
Program MaxWinSize

WINAPP

USE CLRWIN

integer wd, ht
integer ii, X_maxwin, y_maxwin, W_maxwin,h_maxwin, hdl_maxwin

x_maxwin=0
y_maxmin=0
h_maxmin=0
w_maxwin=0

!__________________________________________________________________
! Create a window temporarily to get MAX Window SizeGet MAX Window Size
!  then Delete It !

ii=winio@("%ww[not_fixed_size,maximise]&")
ii=winio@("%hw",hdl_maxwin)

CALL GET_WINDOW_LOCATION@( hdl_maxwin, X_maxwin, y_maxwin, W_maxwin,h_maxwin)

print*,'hdl_maxwin = ', hdl_maxwin
print*,'x_maxwin = ', x_maxwin, 'y_maxwin = ', y_maxwin
print*,'h_maxwin = ', h_maxwin, 'w_maxwin = ', w_maxwin

Call DESTROY_WINDOW@(hdl_maxwin)

!_____________________________________________________
! Create a New window of Same size

wd = w_maxwin; ht = h_maxwin
print*,'h_maxwin = ', h_maxwin, 'w_maxwin = ', w_maxwin

ii=winio@("%sp&",0L,0L)
ii=winio@("%ww[not_fixed_size]&")


ii=winio@("%sz",wd,ht)

!__________________________________________________________________
End Program
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Apr 23, 2015 11:35 pm    Post subject: Reply with quote

John,

You don't get to the line after the last (second) WINIO@ call until you finish interacting with the window. By the time you get to GET_WINDOW_LOCATION the window has ceased to exist, so the call is meaningless. The DESTROY_WINDOW@ is superfluous too.

You need to put GET_WINDOW_LOCATION@ inside a callback function to a %cc closure control format code, thus:

Code:
 Test Routine to Get MAX Window size
!
WINAPP
Program MaxWinSize
USE CLRWIN
integer wd, ht
integer ii, X_maxwin, y_maxwin, W_maxwin,h_maxwin, hdl_maxwin
COMMON  ii, X_maxwin, y_maxwin, W_maxwin,h_maxwin, hdl_maxwin
integer, external:: closer
x_maxwin=0 ; y_maxmin=0 ; h_maxmin=0 ; w_maxwin=0
!__________________________________________________________________
! Create a window temporarily to get MAX Window SizeGet MAX Window Size
!  then Delete It !
ii=winio@("%ww[not_fixed_size,maximise]&")
ii = winio@('%cc&', closer)
ii=winio@("%hw",hdl_maxwin)
print*,'hdl_maxwin = ', hdl_maxwin
print*,'x_maxwin = ', x_maxwin, 'y_maxwin = ', y_maxwin
print*,'h_maxwin = ', h_maxwin, 'w_maxwin = ', w_maxwin
!Call DESTROY_WINDOW@(hdl_maxwin)
!_____________________________________________________
! Create a New window of Same size

wd = w_maxwin; ht = h_maxwin
print*,'h_maxwin = ', h_maxwin, 'w_maxwin = ', w_maxwin
ii=winio@("%sp&",0L,0L)
ii=winio@("%ww[not_fixed_size]&")
ii=winio@("%sz",wd,ht)
!__________________________________________________________________
End Program
INTEGER FUNCTION CLOSER ()
USE CLRWIN
integer wd, ht
integer ii, X_maxwin, y_maxwin, W_maxwin,h_maxwin, hdl_maxwin
COMMON  ii, X_maxwin, y_maxwin, W_maxwin,h_maxwin, hdl_maxwin
CALL GET_WINDOW_LOCATION@( hdl_maxwin, X_maxwin, y_maxwin, W_maxwin,h_maxwin) 
CLOSER = 0
End


Apologies it isn't all that neat, and uses COMMON.

Eddie
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Fri Apr 24, 2015 2:20 am    Post subject: Reply with quote

Eddie,

Thanks for your example; I played around with it, introduced %`cc and learnt a bit more about what is happening. I tried this on my 2-screen setup, where the second screen is on the left. This gives -ve Y and X values. I introduced MODULE and more reporting.

John

(Oh the frustrations of the post size limit ! What about a 10th birthday present? )

Code:
 ! Test Routine to Get MAX Window size
 !
 WINAPP
   module my_win_variables
     integer ii, X_maxwin, Y_maxwin, W_maxwin, H_maxwin, hdl_maxwin, wd, ht
   end module my_win_variables
   
 Program MaxWinSize
   USE CLRWIN
   use my_win_variables
   
   integer, external :: closer, closed, initial_location
   
   X_maxwin=0 ; Y_maxwin=0 ; H_maxwin=0 ; W_maxwin=0 ; wd=0 ; ht = 0
!__________________________________________________________________
! Create a window temporarily to get MAX Window SizeGet MAX Window Size
!  then Delete It !
   ii = winio@ ('%ca@&', 'First window - resize, move then close')
   ii = winio@ ('%ww[not_fixed_size,maximise]&')   ! set window position
   ii = winio@ ('%sc&', initial_location)          ! call initial_location function to remembre initial location
   ii = winio@ ('%cc&', closer)                    ! control window close : call closer before window is closed
   ii = winio@ ('%`cc&', closed)                   ! control window close : call closed after window is closed
   ii = winio@ ('%hw',  hdl_maxwin)                ! return handle for current window
!
   call report_location ( 'Location of first window when completed' )

!Call DESTROY_WINDOW@(hdl_maxwin)
!_____________________________________________________
! Create a New window of Same size

   print*, 'Retained window size for next window'
   print*, ' H_maxwin = ', wd
   print*, ' W_maxwin = ', ht
!   
   ii = winio@ ('%ca@&', 'Second window - same size? - resize, move then close')
   ii = winio@ ('%sp&', 0L,0L)                     ! set window position
   ii = winio@ ('%sz&', wd,ht)                     ! size window
   ii = winio@ ('%ww[not_fixed_size]&')            ! set window style
   ii = winio@ ('%sc&', initial_location)          ! call initial_location function to remembre initial location
   ii = winio@ ('%cc&', closer)                    ! control window close : call closer before window is closed
   ii = winio@ ('%`cc&', closed)                   ! control window close : call closed after window is closed
   ii = winio@ ('%hw',  hdl_maxwin)                ! return handle for current window
!
   call report_location ( 'Location of second window when completed')
!__________________________________________________________________
 End Program
 
 INTEGER FUNCTION CLOSER ()
  USE CLRWIN
  use my_win_variables
!
!  get location of window as closing
  CALL GET_WINDOW_LOCATION@ ( hdl_maxwin, X_maxwin, Y_maxwin, W_maxwin, H_maxwin) 
  call report_location ( 'Location of window prior to closing' )
  wd = W_maxwin; ht = H_maxwin    ! retain size
  CLOSER = 0
 End FUNCTION CLOSER

 INTEGER FUNCTION CLOSED ()
  USE CLRWIN
  use my_win_variables
!
!  get location of window after closing
  CALL GET_WINDOW_LOCATION@ ( hdl_maxwin, X_maxwin, Y_maxwin, W_maxwin, H_maxwin) 
  call report_location ( 'Location of window after closing' )
  CLOSED = 0
 End FUNCTION CLOSED

 INTEGER FUNCTION initial_location ()
  USE CLRWIN
  use my_win_variables
!
!  get location of window
   CALL GET_WINDOW_LOCATION@ ( hdl_maxwin, X_maxwin, Y_maxwin, W_maxwin, H_maxwin) 
   call report_location ( 'Location of window when first opened' )

  initial_location = 1
 End FUNCTION initial_location
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Fri Apr 24, 2015 2:24 am    Post subject: Reply with quote

Code:
 Subroutine report_location (message)
  use my_win_variables
  character message*(*)
!
   print*, ' '
   print*, message
   print*, 'hdl_maxwin = ', hdl_maxwin
   print*, ' X_maxwin  = ', X_maxwin
   print*, ' Y_maxwin  = ', Y_maxwin
   print*, ' H_maxwin  = ', H_maxwin
   print*, ' W_maxwin  = ', W_maxwin
   print*, ' '

 End Subroutine report_location
 


Eddie,

modules even work over multiple posts !!

John
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Apr 24, 2015 9:18 am    Post subject: Reply with quote

Useful addition. Should help comprehension.

I assume without testing that a window left open with %lw could be examined with GET_WINDOW_LOCATION@ in lines of code executed after the last WINIO@. In such a case, it would perhaps be desirable to first check that the window still exists, although I can't find a Clearwin+ function for that.

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Fri Apr 24, 2015 4:07 pm    Post subject: Reply with quote

Well Eddie & John C. - thank you.

That's got the fundamental sorted, I now got right ball park numbers.
However, as is usual, it brings up additional things:

Small erratum - John C , in your code : in PRINT* statements, wd, ht are reversed !!
(had me searching for a while when I saw the reversed numbers in the O/P window ! :O) - obviously a cunning observation test Wink )

1. When I run the 2 codes:-
Why do I get top left position of the window as -8,-8 ! ?
Window size is given as 1382 x 744 , whereasactual screen res. is 1366x768, i.e. there appears to be some kind of an 8 x 12 pix border all around at least part of which won't be visible ?
(odd that the 'origin' is offset 8,8 but the borders are 8 and 12 wide).

Why the difference ? Is it maybe because some of the physical pixels are actually hidden (behind the frame of the screen) ? but then how would windows know that.

Also, presumeably this needs to be defined for the creation of the 2nd window i.e. origin is -8,-8 , not 0,0 as at present ?

(b.t.w. what is the format '0L' what's the 'L' ? - I just copied it from somewhere I saw it like that in an example in the manual - I've never been able to find an explanation for that anywhere)
___________________________________-

2. My aim is NOT to actually display the first window, just 'create invisibly' to obtain the maximum dimensions possible then create the second one. Is that possible ?
(I was hoping that a reply was going to pop up: 'use function XXXXXX' but clearly there isn't one. Maybe somewhere obscured within a windows API.)

... After a bit of digging eventually I found the 'INVISIBLE' option for %ww, so I tried it.

In Eddie's code, substituting this:-

Code:
ii=winio@("%ww[not_fixed_size,maximise,invisible]&")



... results in 1st window not appearing - tick V.G.

but in John C's code, substituting this:-

Code:
ii = winio@ ('%ww[not_fixed_size,maximise,invisible]&')   ! set window position


... results in NEITHER window appearing !!!

________________________________________

3. Captions - %ca@
a) When I was testing the INVISIBLE option I tried to put captions on the windows in Eddie's code. I simply tried copying the same %ca lines from John C's code into Eddie's
- It didn't produce any caption on the window produced !!!
I have no idea why. Maybe related to the different call backs used by John C. ?

b) this %ca@ option is not very well explained in the ftn95 on-line help.
In fact it's explained there that a variable can be used, but your code John has it as a fixed string (just seperate not defined in [] ). Is there a specific reason for using that way of defining it ? It's not actually clear to me from the description in the manual that you can use it like that, but clearly you can.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Apr 24, 2015 4:59 pm    Post subject: Reply with quote

L means make the constant a long integer, i.e. INTEGER*4 even if the default is set otherwise. You could set that in the FTN95 cfg config file, or by including OPTIONS(INTL).

With a %ca@ you need to follow it with a string constant (like JC did) or a string variable. If you use a string constant it's the same as %ca[ ] because it is unchangeable. If you use a string variable then at some later point you can change the contents of the string and call WINDOW_UPDATE@ (name_of_variable).

If you want your application to be universal, you may find yourself getting lots of parameters about the screen and other environmental settings:

Code:
       CALL GET_OS_VER@ (ID_Platform, Major, Minor)
       iHDC = getdc (0)
        ixdpi = GetDeviceCaps(iHDC, LOGPIXELSX)
        iydpi = GetDeviceCaps(iHDC, LOGPIXELSY)
       IX=GetSystemMetrics(SM_CXSCREEN)
       IY=GetSystemMetrics(SM_CYSCREEN)


GetDeviceCaps and GetSystemMetrics are documented online in MSDN.

I don't know about your reported width & height, but heightwise allow for the bar at the bottom of the screen. If you use 'RulerByGeorge' it enables you to measure pixels on the screen (http://www.svet-soft.com/ruler.shtml). It never occurred to me to use GET_WINDOW_LOCATION@ in this context because GetSystemMetrics is better. Maybe there are foibles associated with a maximised window: I noticed in some old code of mine I have:

Code:
      IA = WINIO@('%sy[no_border]&')


so maybe that helps with your missing pixels. I forgot what the difference between the frame and the border is, but there are options in %ww for no_frame and _no_border or naked (which is both).
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 1:04 am    Post subject: Reply with quote

Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 1:19 am    Post subject: Reply with quote

Strange behaviour !
I tried to post this above and it produced the BLANK post shown !
There was one URL (to another post), I'll omit it here and try again below ............
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 1:20 am    Post subject: Reply with quote

Thanks again Eddie.

Since I posted I did find a post in the forums from Nov 2013 (which I remember crossing paths with before), discussing negative co-ordinates on dual-monitor setups, which talks about getting SYSTEM METRICS (with example codes kindly posted by Ian Lambley) so I'm already trying (slowly) to read up about all that stuff. Here's the link for ref. ,

URL Here DELIBERATELY OMITTED (as a test because with it the post as shown above was BLANK !)

I've already seen that in SYSTEM Metrics there are other options for obtaining the maximum screen rectangle omitting the taskbar and also other application toolbars which may be present too.
see:- SM_CXFULLSCREEN, SM_CYFULLSCREEN

I'll have to try them, but it seems that is what I want is in there somewhere on 'planet Zog' Wink. I'll need a translator to get through the hyroglyphics but at least I know what I'm looking for is there !

It gets slightly more complicated with dual screens ! (John C might be interested in the above link for that reason.

I'm surprised there isn't an option (yet Smile ) to create a window full screen (minus taskbar, and optionally other toolbars) somewhere in Clearwin+ (maybe as an option in %ww). Maybe Paul will add it to his mega-list for investigation(implementation post-64bit activities.

I shall have a dig around too regarding the border,etc... which may be an explanation of the top left positioned negatively.
It may possibly be that this is the explanation, we'll see.

Eddie, Did you get negative origin values too when you ran your code you posted ?

Has anyone else tried Eddie's code ? If so, what did you get ?

John
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 1:21 am    Post subject: Reply with quote

Odd indeed, so, it was the URL causing the problem, here it is on its own, without the [URL] beginning and end :-

http://forums.silverfrost.com/viewtopic.php?t=2688&highlight=dual+screen
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 1:24 am    Post subject: Reply with quote

well, that's VERY ODD INDEED, it posts as a hyperlink when I DIDN'T include the '[url]' and '[/url]'
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Apr 25, 2015 1:22 pm    Post subject: Reply with quote

John,

It's complicated in more ways than one, because the widths of frames etc are different between different versions of Windows, and the character cell which gives you a lot of the layout in Windows as well as Clearwin+ (but not all, because some is done in pixels) varies with the system font, the version of windows in use, the size of the taskbar and the logical dpi setting - plus, what you want to display in the way of toolbars may depend on the space available.

The trad method is to show the window at a nominal size and let the user maximise it. This doesn't work well in Win8 because that seems to like the newly launched window to be max sized initially.

My applications normally have a master window with the whole client area taken up only by toolbars and a maximum size %gr. I struggle to get the %gr area to fill the remainder of the client area after allowing for the toolbars, and I have experimented with not using Clearwin+ toolbars but running my own, made up from icons, and managing their states myself, but mostly I've used Clearwin's toolbars. Every release of Windows causes my scheme to malfunction, and my study is full of threats of violence to the cannabis-smokers at M$ until I've got it sorted.

The whole logical dpi thing is a nonesensical solution to knowing how many pixels there are, but not knowing the physical size of the screen.

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Apr 25, 2015 9:43 pm    Post subject: Reply with quote

Eddie,
My thinking was the reverse, which is what got me started on this.
I usually expect a program to open full window size (I think statistically that's the case).
As for Win 8.1 .... bleep bleep bleep it'll probably go the way of Vista.
Win 7 is the best I've ever used.

I shall have to research the widths of frames etc..., thanks for pointing that out.

character cell ?
logical dpi setting ?
you mean memory 'space available' ?

I shall have to look into all these things to become familiar with them.

I guess what's missing in understanding all this MS stuff is some kind of 'pictorial description' of screen layout with all the various parameters represented showing their inter-relationships.
(I mean the simple kind which can be found in the Simpleplot manuals for example, where there's an explanation of all the various borders, margins, graphical areas etc...)

logical dpi thing is a nonesensical solution to knowing how many pixels there are ? - what's all that about ?
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sun Apr 26, 2015 10:47 am    Post subject: Reply with quote

Hi John,

Character cell:
Imagine yourself back in the DOS world of 80 characters wide x 25 rows high. If you had a CGA screen of 640x200, the characters would be 8 pixels wide and 8 high, and were all monospaced. If you moved to VGA, which was 640x480, it was possible to have more pixels vertically, or with some graphics cards, to get more rows in. Note that CGA's pixels weren't 'square' - but from VGA onwards they were, and the resolution options blossomed with time.

In Windows, apart from the first few versions maybe, the system font isn't monospaced. Hence, the height of a character cell may be fixed, but its width isn't. So something called the average character cell width is used, which you get by writing out the whole alphabet, and taking the number of pixels divided by the number of letters, then rounding it (up?) you get the average width. The height is simple in comparison: room for ascenders and descenders (up and down bits like bdhl and gjy have etc) and some space top and bottom. Characters always look better with more pixels, and always better with more vertically than horizontally.

Clearwin+ lays out the controls in a window on the basis of a regular grid of these character cells. There's even a format code %gd that draws the grid for you. But, a cell has to be an integer number of pixels wide and high. The upside of this is that it is simple, the downsides are that when things jump to the next cell it is a large jump, exact positioning is difficult (although you do have %ap and %rp) and sometimes text doesn't fit even though the number of characters allowed for is bigger than the number you have (may depend on which characters are involved, where iiiii takes less room than mmmmm). Sometimes you enlarge the font and nothing changes on screen, because original or enlarged, it fits in the same character cell!

The size of an average character cell depends on the font used, which in turn depends on the version of Windows and user selections, so what looks good in 7 may not in 8. It also affects the row spacing, so changes to the number of pixels high of the default font (which is user selectable in Windows) can make things go haywire too. If your user hasn't made any customisation to his Windows, this basically comes down to which version of Windows is he using.

Eddie


Last edited by LitusSaxonicum on Sun Apr 26, 2015 11:48 am; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group