Forum Navigation
You need to log in to create posts and topics.

Re: Size of a display

Posted by: fblistserve <fblistserve@...>



On Mar 4, 2022, at 8:01 AM, Peter Boyle <[email protected]> wrote:


Is there a way to find the size of a display (number of pixels) under program control, I have three displays all of different sizes, one isa  Retina display.


It's possible that getting the screen's dimensions is the wrong approach ( depending on your goals - which you haven't described ).

 To quote from Apple: "There are very few, if any, situations for which you need to use device coordinates directly. You should be able to accomplish any task that relates to drawing geometry by using the APIs described in this section.

In all cases it is best to rely on using one of the APIs that support high resolution rather than trying to manage values yourself." 

See their doc here for the quote.


If you simply want to consult the screen size ( or any attached display ), the NSScreen class has a 'frame' call which returns an NSRect containing the height/width. The class also has a 'depth' call for bit depth. 

FB's headers has the Screen.incl which lists the FB versions of the frame/depth calls. 


//--------------
local fn DoIt
  CGRect r = fn ScreenFrame( fn ScreenMainScreen )
  printf @"%.0f height, %.0f width", r.size.height, r.size.width
end fn

window 1

fn DoIt

HandleEvents
//--------------


--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/