LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

get screen rosolution

Hello ,

           My panel would be out of range in other computer.How can I make it adjusts its size base on computer screen resolution? How to get screen resolution?

            Any solution would be appreciate.

0 Kudos
Message 1 of 8
(4,491 Views)

If you have the FDS of CVI you can use the Win32 API and the function GetSystemMetrics ();

0 Kudos
Message 2 of 8
(4,490 Views)

To get screen resolution you can use GetScreenSize ()

Adjusting panel aspect to screen resolution cn be obtained automatically by setting Resolution Adjustment attribute in advanced panel settings. It can be set as a general system attribute: see here.



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 3 of 8
(4,481 Views)

My favorite way out of the issue of different screen sizes is to use a multi-window GUI, where the largest panel will fit on the smallest required screen size (typically 1024 x 768). Somehow I am not so much convinced from the beauty of automatic resolution adjustment.

0 Kudos
Message 4 of 8
(4,474 Views)

I totally agree with you! Automatic resolution adjustment gives poor results: graphic objects tend to deformate and texts are resized graphically, not applying a larger font.

 

I tend to add to the panels two hidden splitters to which I attach UI objects: normally I set splitters to simply move texts, numerics and so on, while I let them enlarge graphs and all other graphic objects.

 

If I understand correctly, you have in your UIR file several versions of one panel, each for different screen resolution, and choose which one to use depending on the screen size, correct? Isn't it a bit complicated? I mean, supposing your panel for 1024x768 is called PANEL and one indicator on it is PANEL_NUMERIC. For a different screen resolution you have a different panel, say PANEL2, so the respective numeric will be PANEL2_NUMERIC. Now, every time you need to SetCtrlVal for the numeric you must switch on screen resolution to address the correct control.



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 5 of 8
(4,468 Views)

Check this code which adress some issues i have found (titlebar height, desktop usable size(without windows Start menu bar),panel frame thickness)

(I am simplify code a little, so it is not fully tested)

 

	int monitorID;
	int mh,mw;//monitor height and width (only usable area - without windows start menu bar)
	int ph,pw;//panel height and width
	int th;//panel titlebar thicknes
	double kx,ky;//
	double k;
	int FrameWidth,FrameHeight;
GetMonitorFromPanel (panel, &monitorID); GetMonitorAttribute(monitorID,ATTR_HEIGHT,&mh); GetMonitorAttribute(monitorID,ATTR_WIDTH,&mw); GetPanelAttribute(panel,ATTR_HEIGHT,&ph); GetPanelAttribute(panel,ATTR_WIDTH,&pw); GetPanelAttribute (panel, ATTR_TITLEBAR_ACTUAL_THICKNESS, &th); GetPanelAttribute (panel, ATTR_FRAME_ACTUAL_WIDTH ,&FrameWidth);FrameWidth*=2; //*2 because of left and right side frame GetPanelAttribute (panel, ATTR_FRAME_ACTUAL_HEIGHT ,&FrameHeight);FrameHeight*=2;//*2 because of top and down side frame kx=(double)(mw-FrameWidth)/(pw); ky=(double)(mh-FrameHeight-th)/(ph); ; if (kx<ky)k=kx;else k=ky;//respect height and width ratio of panel - chose smallest ratio if (k>1.0)//only growing is allowed { SetPanelSize(panel,ph*k,pw*k); }

 

Message 6 of 8
(4,467 Views)

@RobertoBozzolo wrote:

 

If I understand correctly, you have in your UIR file several versions of one panel, each for different screen resolution, and choose which one to use depending on the screen size, correct?



Hello Roberto,

 

I am not sure if this comment was addresed to me, but let's assume so...

 

No, I meant something different, sorry for the bad explanation:

 

Usually, during the evolution of a given software, the number of features grows - and thus usually also the panel size in order to fit the added controls etc. This works until you realize that the panel may be too large for some screen sizes...

 

Here using tab panels helps tremendously, but since tabs should only group related controls/indicators this approach isn't always sufficient.

 

Hence I transfer a group of controls (say instrument specific settings) to a new panel which can be displayed or not, depending on the current need - and positioned by the user according to his liking and the available screen size. If a screen is too small, panels can be displayed on top of each other allowing the usual Windows Alt-Tab game. If the user has a sufficiently large screen all panels can be arranged side by side. So I have just one panel for all resolutions but leave the visual arrangement to the user.

 

In this context the Ini_ driver is very useful, allowing to save and restore all panel positions.

0 Kudos
Message 7 of 8
(4,462 Views)

@wolfgang

my comment was effectively referred to your post, and once explained your solution appears neat and functional.

I am often facing a different problem, that is the need to display my application full screen to see diagrams at best. In this case splitters are the best solution as they permit to manipulate controls with minimum coding effort.

I will made some test on the solution offered by OVR_CZ: since it preserves aspect ratio the, effect with automatic resolution adjustment should not be that bad.



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 8 of 8
(4,447 Views)