Getting the screen resolution

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
MarkusK
Posts: 53
Joined: Thu Oct 22, 2020 9:11 am

Getting the screen resolution

Post by MarkusK »

Does VSTGUI provide a function the returns the current screen resolution?

Thank you,
Markus

Arne Scheffler
Posts: 417
Joined: Mon Jun 20, 2016 7:53 am

Re: Getting the screen resolution

Post by Arne Scheffler »

No. Why do you need to know this?

MarkusK
Posts: 53
Joined: Thu Oct 22, 2020 9:11 am

Re: Getting the screen resolution

Post by MarkusK »

1) The user should not be able to select a GUI size for the plugin which is larger than the screen resolution

2) When the plugin is loaded it automatically sets a size which is comfortable for the user as a default

Arne Scheffler
Posts: 417
Joined: Mon Jun 20, 2016 7:53 am

Re: Getting the screen resolution

Post by Arne Scheffler »

I would choose a default which works everywhere and let the user choose whatever the user likes, even if it is bigger than the screen resolution of one screen.
VSTGUI has no solution because it is too complex for a plug-in to get right. Just think of the HiDPI mess on Windows with multiple screens. Do you really want to take care of this in your plug-in?

MarkusK
Posts: 53
Joined: Thu Oct 22, 2020 9:11 am

Re: Getting the screen resolution

Post by MarkusK »

I agree that HiDPI has not been solved well by Microsoft.

Here is the code that i use on Windows. Maybe it helps:

Code: Select all

char size = 1;//default  100%
                long maxx = (int)GetSystemMetrics(SM_CXSCREEN);
                long maxy = (int)GetSystemMetrics(SM_CYSCREEN);
                
                HDC screen = GetDC(0);
                int dpiX = GetDeviceCaps(screen, LOGPIXELSX);
                float scaleX = (float)(dpiX) / 96.f;//desktop skaliering auslesen
                int dpiY = GetDeviceCaps(screen, LOGPIXELSY);
                float scaleY = (float)(dpiY) / 96.f;
                ReleaseDC(0, screen);
                
                if ((scaleX != 0) && (scaleY != 0))
                {
                    float guix = 1008;
                    float guiy = 522;
     
                    if (((float)(maxx) / scaleX > guix * 2) && ((float)(maxy) / scaleY > guiy * 2)) size = 5;// 200%
                   
                    return size;
                }

Post Reply