* Getting Display Resolution

For plugin authors to discuss plugin programming
Post Reply
avatar
Normie
Diamond
Posts: 77
Joined: 02 Mar 2019 18:28
Family Historian: V7

Getting Display Resolution

Post by Normie »

I can easily get the size of a dialog, but have not yet identified how to get the corresponding size of the display itself.

Does anyone know how to get the display size (preferably in pixels) and what is the maximum safe size for the design of a dialog screen.
Norman Martin
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Getting Display Resolution

Post by ColeValleyGirl »

Why not let IUP do the work? From the Attributes for a Dialog:
SIZE (non inheritable): Dialog’s size. Additionally the following values can also be defined for width and/or height:

"FULL": Defines the dialog’s width (or height) equal to the screen's width (or height)
"HALF": Defines the dialog’s width (or height) equal to half the screen's width (or height)
"THIRD": Defines the dialog’s width (or height) equal to 1/3 the screen's width (or height)
"QUARTER": Defines the dialog’s width (or height) equal to 1/4 of the screen's width (or height)
"EIGHTH": Defines the dialog’s width (or height) equal to 1/8 of the screen's width (or height)
avatar
Normie
Diamond
Posts: 77
Joined: 02 Mar 2019 18:28
Family Historian: V7

Re: Getting Display Resolution

Post by Normie »

I thought of that, but it seems that you have to set the dialog to 'FULLxFULL' and then apply that setting to get the screen resolution.

I then have to reset the dialog size to a smaller value, if that is all I need. That gives a flickering dialog form.

However, it does work. I thought there might be a way to avoid sizing the dialog to full screen to see if the native size of the dialog will display safely on the screen.

Sort of hoping there may be either a Display.Size attribute in IUP or something in fhutils.
Norman Martin
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Getting Display Resolution

Post by ColeValleyGirl »

I usually set the size of a Dialog to HALF x HALF, knowing that will fit on the screen, and have scrollbars where needed, plus the ability to resize the dialog.

However, if you look in the IUP documentation and Attributes > Global > Screen information, you'll find (if you haven't already found it)
FULLSIZE (read-only)
Returns the full screen size in pixels.

String in the "widthxheight" format.

SCREENSIZE (read-only)
Returns the screen size in pixels available for dialogs, i.e. not including menu bars, task bars, etc. In Motif has the same value as the FULLSIZE attribute. The main screen size does not include additional monitors.

String in the "widthxheight" format.
User avatar
Mark1834
Megastar
Posts: 2534
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Getting Display Resolution

Post by Mark1834 »

Can’t remember the exact syntax as I’m away from the computer, but dialog:map() places all the elements in the form without actually drawing it. Does that help?
Mark Draper
avatar
Normie
Diamond
Posts: 77
Joined: 02 Mar 2019 18:28
Family Historian: V7

Re: Getting Display Resolution

Post by Normie »

Thanks

Getting the SCREENSIZE attribute finds the information perfectly. I can do that when the plugin first starts so that I can adjust the dialog to be displayed at the appropriate size (or to say that the resolution is too low to support the dialog).

The information had to be somewhere, I just could not find it.
Norman Martin
User avatar
ColeValleyGirl
Megastar
Posts: 5520
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Getting Display Resolution

Post by ColeValleyGirl »

Normie wrote: 15 Apr 2024 10:46 The information had to be somewhere, I just could not find it.


Says everyone who has ever used IUP...

I am increasingly resorting to ChatGPT:
In Lua, using the IUP library, you can get the size of the display in pixels by utilizing the iup.GetScreenSize() function. Here's how you can do it:

lua

Code: Select all

require("iuplua")

-- Get the screen size
local width, height = iup.GetScreenSize()

-- Print the screen size in pixels
print("Screen width:", width, "height:", height)
This script simply retrieves the screen size using the iup.GetScreenSize() function and then prints out the width and height in pixels.
avatar
Normie
Diamond
Posts: 77
Joined: 02 Mar 2019 18:28
Family Historian: V7

Re: Getting Display Resolution

Post by Normie »

Thanks to your help, I have managed to write a function to automatically resize a dialog to be within the size of the screen.

A little more challenging than I had hoped (and careful reading of the IUP documentation) , but with using a scrollbox in the dialog have managed to scale a reasonable size dialog into a 800 by 600 display.

Thanks a lot

Norman
Norman Martin
Post Reply