From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to adjust Dialog size to screen resolution?

Greetings,

 

I'm having trouble to adjust the width/heigth of my DIAdem dialogs in different screen resolutions, i've been playing around with the commands MapYPixelToDlu, MapYDluToPixel...,but still, totally lost.  First, i don't really understant what the "dialog units are", are they a kind of rate pixels/screen resolution? 

 

for example, I ran this code trying to adjust it to the size of the monitor with no luck, 

 

x=Dialog.Width
y=Dialog.Height
Dim xDlu: xDlu = Dialog.MapXPixelToDlu(a)
Dim yDlu: yDlu = Dialog.MapYPixelToDlu(b)
Dialog.Width=xDlu
Dialog.Height=yDlu

 

How do you guys handle this? Is out there any example I can have a look?

 

Thanks

 

Regards,

 

Javier

0 Kudos
Message 1 of 5
(6,458 Views)

Tafalla,

 

First, Dialog Units are a unit of measurement related to the size of a font character in the box. Here's a DIAdem Help page about them: http://zone.ni.com/reference/en-XX/help/370858K-01/sudref/objects/sud_dialogboxunit/

 

As for setting the size of the dialog, you should be able to do this in a DIAdem script using the Height and Width properties that you mentioned. To clarify, are you trying to do this command in a SUD dialog script, or in a script on the DIAdem SCRIPT pane? That might change the process a bit. 

 

FInally, when you say there's no luck, are you simply not seeing the size of the dialog being updated? It's possible that you will need to refresh the dialog by hiding it and then showing it again, or making sure you set the size before displaying the dialog.

0 Kudos
Message 2 of 5
(6,432 Views)

Hey Daniel thanks for replying,

 

 

well, I was totally lost in the meaning of the dlgunits meaning, I guess they have nothing to do with my question.

 

Let's see if I can explain myself a little better.The thing is, i'd like to be able to change the size (in pixels) of my SUD modal dlgbox according to the screen resolution. I was thinking in making it throught the SUD script console. Here is an example of the "problem", in my computer everything looks good since I did all the dialogs using my monitor as a reference, size, fonts...perfect. However if I plug my computer in a proyector, the resolution changes and all them get messed-up, some of them don't fit in the screen. The same migth happen when I try to run the program in others computer, the dialog might or might not fit perfectly in the screen depending of their resolution.

 

So I guess my question was, is there any way to get the size of the main screen in pixels and then adjust the dialogs proportionally? Or in other words, how can I create a SUD which always takes up the 50% of the screen regardless of the  screen resolution?

 

If somehow I can get the main screen dimensions I could then adjust the dialog by using dialog.left,dialog.rigth ....

 

Correct me if I wrong but  when the properties Height, width are defined.. , those values are pixels aren't they?

 

Thanks,

 

Javier

 

0 Kudos
Message 3 of 5
(6,419 Views)

Hi Tafalla

 

That is not so easy. First you have define a default font for the dialog box, when you create it. Then you have to modify this font while you initialize the dialog box. Getting the screen resolution is an other problem. I found a solution and it works on my computer but I am not sure if it will work everywhere. The size of the dialog and all default fonts will be adjusted automatically.

 

So have a look at the attached file.

This is the code in the SUD:

Sub Dialog_EventInitFinalize(ByRef This) 'Erzeugter Event-Handler
Dim OldFont, OldFontSize, iPos, NewFontSize, NewFont, intWidth, intHeight
RefResulution = 1024
OldFont = this.Font
msgbox OldFont
iPos = Instr(1,OldFont,",")
OldFontSize = Left(OldFont,iPos-1)
Call DlgRes(intWidth, intHeight)
NewFontSize = str(OldFontSize*intHeight/RefResulution,"d.d")
NewFont = NewFontSize & Mid(OldFont,iPos)
msgbox NewFont
this.Font = NewFont

End Sub

Sub DlgRes(intWidth, IntHeight)
Dim objWMIService, colItems, objItem
Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0)
For Each objItem in colItems
    intWidth = objItem.ScreenWidth
    intHeight = objItem.ScreenHeight
Next
End Sub

You may adjust you RefResultion.

 

Hope this helps

 

Winfried

 

Message 4 of 5
(6,415 Views)

Hey Winfried

 

Great job, thanks so much for sharing  it with me, 

 

Your code it's a perfect start point for what I was looking for. 

 

Having your code to readjust the fonts and now that I know how to get the screen resolution I'll only need to re-define the dialog width and heigth and...Smiley Happy

 

Thanks again,

 

Regards,

 

Javier 

0 Kudos
Message 5 of 5
(6,376 Views)