LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

get desktop pixel dimensions?

Solved!
Go to solution

How can I query the system to findout the desktop dimensions of the screen the program is running on?

 

I need to popup a borderless fullscreen window, up to now I've had control of the hardware so I know the screen resolution (1920x1200) but there is interest in making the system "just an application" so I'd have to deal appropriately with different (likely smaller) maximum pixel resolutions.

 

This window is basically a tile of canvas controls created programatically so the only real issue is getting the screen size at run time and creating the tiles or printing an error message if the screen is too small to use (i.e. 800x600)

 

--wally.

0 Kudos
Message 1 of 10
(6,891 Views)
You can use  GetScreenSize (&screenHeight, &screenWidth);


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 10
(6,890 Views)

Thanks this is the answer I was looking for.  The CVI help index came up empty when I typed screen or desktop, I should have been clever enough to put a "get" in front of them 😞

 

Any experience with this function behavior in a multi-monitor setup?  The CVI help for it is pretty sparse.

 

Thanks!

 

--wally.

 

0 Kudos
Message 3 of 10
(6,888 Views)

Quick test on my development system (three 1280x1024 displays) suggests GetScreenSize() is oblivious to multi-monitor setups since it returned h=1024, w=1280.

 

Is  there any CVI support for trying to figure out the configuration of a multi-monitor setup at run time?  Obviously this can be pretty complicated, expecially if all displays are not the same size or in a line.

 

--wally.

 

 

0 Kudos
Message 4 of 10
(6,883 Views)
Solution
Accepted by rolfk

Hi wally,

I have no actual experience on multi-monitor environment, but I have found this thread that can give you some sources where to find the informations that you need.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 10
(6,879 Views)

Thanks, I'd just found it using the search funtion.  GetMonitorAttribute() seems to be the way, but the key will be how clear the documentation for the various monitor attributes is.

 

--wally.

 

0 Kudos
Message 6 of 10
(6,875 Views)

Hey Wally - 

 

You could also try the following bit of code using the Win32 API.  I think it should get you what you need. 

 

#include <windows.h>
#include <ansi_c.h>

int main (int argc, char *argv[])
{
    int i;
    DISPLAY_DEVICE display;
    DEVMODE displayInfo;

    display.cb = sizeof (DISPLAY_DEVICE);

    for (i = 0; EnumDisplayDevices (NULL, i, &display, 0); i++)
    {
        if (display.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
        {
            EnumDisplaySettings (display.DeviceName,
                ENUM_CURRENT_SETTINGS, &displayInfo);
            printf ("Display %d has resolution %dx%d\n", i,
                displayInfo.dmPelsWidth, displayInfo.dmPelsHeight);
        }
    }

    return 0;
}

 

 

See the documentation for some of this here and here.

 

NickB

National Instruments  

 

Message Edited by nickb on 09-22-2009 04:00 PM
Message Edited by nickb on 09-22-2009 04:01 PM
Message 7 of 10
(6,866 Views)
Solution
Accepted by topic author wally_666

int i, w[9]={0},h[9]={0}, Nmonitors, primary, first, monitor[10]={0}, top[9]={0},left[9]={0}; GetSystemAttribute (ATTR_NUM_MONITORS, &Nmonitors); GetSystemAttribute (ATTR_PRIMARY_MONITOR, &primary); GetSystemAttribute (ATTR_FIRST_MONITOR, &first); monitor[0]=first; for(i=0;i<Nmonitors;i++){ GetMonitorAttribute(monitor[i], ATTR_NEXT_MONITOR, &monitor[i+1]); GetMonitorAttribute(monitor[i], ATTR_HEIGHT, &h[i]); GetMonitorAttribute(monitor[i], ATTR_WIDTH, &w[i]); GetMonitorAttribute(monitor[i], ATTR_TOP, &top[i]); GetMonitorAttribute(monitor[i], ATTR_LEFT, &left[i]); }

 

Thanks, the code snippet above seems to get all the info I require using only CVI calls.  I usually mix CVI and Win32 calls anyways, but this saves having to dig up the documentation on the Win32 structure typedefs.

 

Thanks for the Win32 multi-monitor documentation links.

 

--wally.

 

 

Message 8 of 10
(6,854 Views)

Hi wally,

 

The "solution" to your question is what Nick provided, not your final post.

For the sake of healthy forum statistics mark the "answer" that solves your problem, not your own messages.

 

Take care, 😉

Message Edited by ebalci on 09-23-2009 01:23 PM
S. Eren BALCI
IMESTEK
0 Kudos
Message 9 of 10
(6,810 Views)

Since this is a CVI forum I consider the pure CVI solution the most appropiate.  All the posts above quickly focused my search on the proper terms to find out the needed function names and their usage and was the help I needed.

 

I was planning to mark two solutions but the option when away after I clicked the first one.

 

--wally.

 

0 Kudos
Message 10 of 10
(6,801 Views)