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 Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
LitusSaxonicum



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

PostPosted: Sun Apr 26, 2015 11:46 am    Post subject: Reply with quote

John,

Logical dpi
This is worse. You may remember that a point is 1/72 of an inch. I've had printers with various resolutions in dots per inch (dpi): Epsons at 360, 720 and 1440; loads of others e.g. HP at 300, 600, 1200. Take the Epson at 720 dpi - each point was 10 dots (pixels). If I tell the printer my character size in points, it takes care of the resolution setting and I always get the same output. If I tell it in pixels, then the size print I get depends on the resolution setting. The dpi is a real thing.

There is a problem in doing this with a monitor, because Windows doesn't know how big it is. In the early days, monitors were much the same size, and the same aspect ratio (height to width), plus the dots weren't real, they were driven by frequencies in the firmware of the electron gun. With LCD/LED screens the dots are real, and the range of physical sizes, aspect ratios and resolutions is enormous.

At some stage, it became obvious that with those original monitors, the dot size was such that if Windows assumed that the monitor was 96 dpi and the pixels were square, everything panned out right with the scaling from points to pixels. This may even have come from the Mac (ya! boo! hiss!). And as long as monitors don't vary much in size or resolution (1024x768 anyone?), assuming that is just fine. At least, assuming a standard equivalent dpi lets Windows know if a monitor is widescreen.

But, monitors got higher and higher resolution. I bought a 15" laptop with 1680x1080 resolution. On a 24" monitor, the 96 dpi assumption would look fine, but on the laptop, you'd have difficulty reading anything. This was XP, and Windows was just beginning to address this issue. They had a vested interest in the ways things were done up to then, and hey ho - if you alter the dpi assumption things could scale back into the visibility range. At one stage, you could chose any dpi setting, but they have, in later versions of Windows, settled on 96, 120 and 144 settings, and they call these 'logical dpi' because they don't have any bearing on the 'physical dpi'. Logical means something different this side of the pond, but so what?

Note that 120 is 125% of 96, and 144 is 150%, so you see these percentages bandied about too as well as the terms standard, fine and ultra fine.

As you go through from XP to Vista to 7 to 8, the logical dpi thing gets more and more embedded. What's more, from Vista onwards, Windows will take some of the logical dpi settings and do the scaling for you, whereas in XP you had to cope all by yourself. Windows taking care of it means that your hard work in XP was wasted, and things got bollixed up.

Now, remember those character cells based on the average character size rounded up into n*m pixels? Well, when a non-standard logical dpi setting is in place, they don't scale linearly, because the 'into pixels' roundup is done at the end.

Plus, when there is an ultra-fine logical dpi setting in place, Windows doesn't want you to know what the real pixel resolution is, because if you work to that, and it scales the result you'll get a mess. So when Windows' logical dpi scaling is in effect, it lies about what the physical resolution is. All fine and dandy if you know, but not if you don't. And just when you thought you understood it - it only does it for some logical dpi settings.

You ought to get some help by declaring your application 'logical dpi aware' for which there is a standard function. But, MSDN tells you not to use it, and instead, to put it in your application manifest. If you know what that is, then I salute you.

Fortunately, most devices run in standard mode, and if you don't want to run on a Microsoft Surface or equivalent, or a physically tiny tablet - just ignore it (for now). But beware, if a user installs it on a device that needs a non-standard logical dpi, or the user selects such a setting - your program display windows will go out of alignment at best, or be completely garbled at worst.

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



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Sun Apr 26, 2015 12:47 pm    Post subject: Reply with quote

Whilst I'm now totally confused and never bother with dpi as I always initially scale the width of a %gr to be 100.0 units and the height in the ratio of the pixel resolutions.
Here are some useful functions:

Code:

      logical*4 ii
      integer*4 rc(4),SPI_GETWORKAREA
      SPI_GETWORKAREA = 48

      iXsizefull=GetSystemMetrics(SM_CXSCREEN)
      iYsizefull=GetSystemMetrics(SM_CYSCREEN)


      ii = SystemParametersInfo(SPI_GETWORKAREA, 0, rc, 0)
      iXsize=rc(3)
      iYsize=rc(4)




       INTEGER platformID, major, minor
       call get_os_ver@(platformID, major, minor)
       IFH = CLEARWIN_INFO@('SYSTEM_FONT_HEIGHT')

The work area is the available pixel width and height for the screen, so if your task bar is always visible the height will be smaller than if you have auto-hide set for the task bar. If the task bar is hidden then you may find you have to reduce the pixel height by one or two pixels as using the full value will cover the residual taskbar totally and hovering your cursor at the bottom will not pick up the height. I have menus and icons at the top of the screen and a status text line at the bottom and when choosing the height of the %gr area, I have to reduce the height in accordance with the font height and any borders which may occur. Lots of experimentation but no changes to the code since XP days.
The existence of the task bar and be deduced form the iysize and iysizefull, but I have never catered for the people who like their task bar anywhere else but the bottom.

When a printer is opened, functions already exist to get the pixel resolution and the physical dimensions.

I hope this helps and I'm not being too simplistic.
Ian
PS

SystemParametersInfo description from
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx

SPI_GETWORKAREA 0x0030
Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in virtual screen coordinates.

To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.

RECT structure definition here
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



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

PostPosted: Sun Apr 26, 2015 4:39 pm    Post subject: Reply with quote

Ian,

You'll never need to bother with logical dpi as long as your users keep on using the standard setting. When one of them does, you'll know the answer as to why the display is messed up! I've only really come across it once, and that was with an XP laptop of my own.

There are some useful additional functions here, and now I'll look up SystemParametersInfo.

I've found oddities with %gr and an initially maximised window where the %gr doesn't fill the remaining client rectangle after the toolbars are taken into consideration. My workaround has been to get the available screen width and height then take off the frames etc, but not knowing your function I've taken off the system taskbar.

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



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

PostPosted: Mon Apr 27, 2015 2:27 am    Post subject: Reply with quote

Eddie, thanks very much for those explanations it'll help very much in (eventually) understanding the workings of all those concepts.
Back to top
View user's profile Send private message
John-Silver



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

PostPosted: Mon Apr 27, 2015 2:48 am    Post subject: Reply with quote

Ian, thanks for those code snippets. I'd been struggling all day Sunday trying to decipher the hyroglyphics of the C++ explanations of :

SystemParametersInfo Structure, as per :
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947%28v=vs.85%29.aspx

i.e.

BOOL WINAPI SystemParametersInfo(
_In_ UINT uiAction,
_In_ UINT uiParam,
_Inout_ PVOID pvParam,
_In_ UINT fWinIni
);

and the associated referenced RECT structure (as per your link above)

i.e.

typedef struct _RECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT;


... and more importantly how they 'translate' into fortran syntax.
Too many BOOLs, typedefs etc.... for a one lingo man like me to cope with.
... maybe all those are taken care of via Use MSWIN ???

Why on earth they can't also write " the top left and bottom right corner co-ordinates can be passed via a DP array of length 4" , I have no idea !!!
.. .and no clear explanation of the input parameters either.

I was also struggling with the Hexa values provided in the above link for GETWORKAREA and how I might have to define them in the fortran, until completely by chance I found at the bottom of the page in the 'Community Section' a listing of all 'real' numbers associated with each command !!!
(just search for GETWORKAREAon the page and ta down till you come to them)
... which explains your '48' in your code snippet !
Other pages of API commands have the integer values quoted !

All that's C++ for you I suppose, a very 'flowery' language ('French'-like, why use 3 words when you can use 10 sort of approach) in my opinion, compared to the solid understandable and logical 'English' of Fortran.

You're example code is a simple example , which explains clearly. Thank You very much.

Are there no Fortran versions of these MS documents do you know, or do we have to DIY 'interpret' each time ?
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 490
Location: Sunderland

PostPosted: Mon Apr 27, 2015 7:01 am    Post subject: Reply with quote

John,
I am glad that I am not alone in hating C, C+ C++, or any other snobby language that generally looks down of the excellence that is Fortran.

These structures are just like the Fortran user type definitions (or "record" statement from VAX Fortran77), which I always seem to forget to use until I am a long way into a program. Just remember:
Code:

byte   = Integer*1
int    = Integer*2
long   = Integer*4
float  = Real*4
double = Real*8
bool   = logical*?

As I say, just the same but without the consistency, logic and simplicity.
I was programming something in C++ for the Arduino microprocessor thing which uses a subset of C++ (C-- i think!). Painful! Especially formatted i/o. Fortunately I was just doing it for the "learning" and not to support my family.
They seem to have needed to change the names of everything we once held dear and understood.
I feel sorry for the younger generation at college who have to specialise in the semantics of the modern languages before using them as a tool to solve the problem that they are really there to learn.
Ian
PS
Did I go too far?
Back to top
View user's profile Send private message Send e-mail
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Apr 27, 2015 11:58 pm    Post subject: Reply with quote

Ian,

I don't think you went too far and I also agree with you. The problem we have is that those who are controlling the direction of Fortran do not appear to agree with us.
I have done courses in Fortran and C and much prefer the approach that Fortran offers. Complex coding structures are a recipe for lots of bugs and that is the direction that Fortran is heading. Holding up a sign saying go back is mostly ridiculed and not fully appreciated.

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



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

PostPosted: Thu Apr 30, 2015 4:00 pm    Post subject: Reply with quote

Going back to my original 'provblem',
I'm still struggling with getting a maximised window straight from the off..

In my 2nd post in this thread I said:-
Quote:
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).


Now, I've opened a window no problem sizing it as 1366x728 and placing it at (0.0). This corresponds to a window of the max window size of 1382x744 with the pix border (2x8) removed on each side.

Here's the window I get:-



Last edited by John-Silver on Mon May 04, 2015 3:12 am; edited 15 times in total
Back to top
View user's profile Send private message
John-Silver



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

PostPosted: Mon May 04, 2015 2:13 am    Post subject: Reply with quote

HOWEVER, when I then try a window 1382x744 with origin -8,-8 (position as given by ) i.e. what MAXIMISED window side should be :-

a) I get a window like this with the CAption right at the upper edge of the screen/window and the minimize/maximize/Exit buttons on top right are cut-off



... another still to come
Back to top
View user's profile Send private message
John-Silver



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

PostPosted: Mon May 04, 2015 3:17 am    Post subject: Reply with quote

b) If I then subsequently click on the maximise buttonI get this:-



- where the window has been re-sized to fit the total available screen area BUT NOTE that theCAption and buttons centralise in the Caption bar !!! - whilst there is no apparent change to the window size !!!!!!

What's going on ?

I've tried to find a detailed explanation of how exactly Windows goes about MAXimising a window, with no luck.
Clearly there's something subtle going on that I'm missing.
Back to top
View user's profile Send private message
John-Silver



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

PostPosted: Mon May 04, 2015 3:21 am    Post subject: Reply with quote

I've put a summary together from the 3 images above, taking just locally the upper left and upper right corners of the windows created, which shows the differences



What I want is to go straight to the rh result (without using MAXIMISE, neither the button, nor the 'MAXIMISE' option of %ww (since it doesn't work when specifying %sz) , just by setting the initial window parameters ! (.. .that's if if its possible, which it surely must be) )
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon May 04, 2015 6:57 am    Post subject: Reply with quote

I have not followed the detail in this thread and I may be missing the point but the following works fine for me...

Code:
winapp
program main
integer i,winio@
character(len=1024) buff
character(len=80) status
buff = " "
status = "OK"
i = winio@("%ww[maximise]&")
i = winio@("%ca[My Caption]&")
i = winio@("%30.20re&",buff)
i = winio@("%ob[status]%80st%cb",status)
end
Back to top
View user's profile Send private message AIM Address
John-Silver



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

PostPosted: Mon May 04, 2015 11:34 am    Post subject: Reply with quote

Hi Paul, yes I know your code will work but I'm looking to simply define the required window size via %sz and NOT with MAXIMISE !

This is so as to be able to use %ch with scroll bars as explained in :
http://silverfrost.com/ftn95-help/clearwinp/formats/_ch.aspx

where it requires %sz to be used.
Everything started with Dan's ps sheet problem which I couldn't see on the screen.
As an exercise (not linked to Dan's problem) just for my own curiosity I got that working with scroll bars first.
Then I wondered about setting up a main window on my own machine with scroll bars and everything snowballed from there.
So, the point is I can't use MAXIMISE and %sz together (well I tried of course bìut it doesn't work).

Hence the things I tried above.
The thing I'm missing really is an explanation of exactly how the window MAXIMISE button works exactly (I can't find a description anywhere) and how to 'simulate it ' without pressing it !
It seems to me that there must be some subtle detail somewhere as I've got the maximised window origin and size but when I try it it gives th e strange anomaly in the CAption bar.
I do remember seeing a comment somewhere in the API documentation which mentione 'padding' (I think it was§) of the CAption bar but I can't for the life of me find it again. It might (or might not) be related.
Back to top
View user's profile Send private message
John-Silver



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

PostPosted: Wed May 06, 2015 9:05 am    Post subject: Reply with quote

... I guess it would be useful to know what MAXIMISE in the context of FTN95 %ww option actually does in terms of calling API's internally in order to understand the problem I'm encountering and to help work out exactly what sequence of API calls are needed to do it seperately within the context I explained above.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed May 06, 2015 10:44 am    Post subject: Reply with quote

The result is a call to ShowWindow(hwnd, SW_SHOWMAXIMIZED) where hwnd is the Windows handle for the main window.

Maybe you need a similar call for the child window that contains the controls and scroll bars.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 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