Auto adjust Modal window depending on screen resolution

My requirement is that a modal window will extend (or reduce, although unlikely) to the systems screen resolution.

A fixed text display will adjust accordingly, ie. dependant on the users set screen resolution.

So, depending on the resolution, the point size of the text needs to adjust to fit.

I’m ok with the conditional side of the programming, ie. If then else, Select Case etc. I think I can work that part out. But I haven’t come across a way to extract the users screen resolution.

Advice much appreciated.

just an idea

  modalwin.Width = Screen(0).AvailableWidth / 4
  modalwin.Height = Screen(0).AvailableHeight / 5
  modalwin.Top = Screen(0).AvailableHeight /2 - modalwin.Height / 2
  modalwin.Left = Screen(0).AvailableWidth /2 - modalwin.Width / 2
  modalwin.Label1.TextSize = floor(Screen(0).AvailableWidth / 100)

Thanks Axel, appreciated. A bit hard for me to understand.

What parts are pseudo-code, or real code, I can only guess.

mymodalwin.etc, I can understand. Screen(0) reminds me of what you had to do in quickbasic. “.Available” I’m thinking that when called, will supply the current screen width(x) and height(y). Does Screen(0) mean “This Current Screen”?

“modalwin.Label1.TextSize = floor(Screen(0).AvailableWidth / 100)” . . . Oh. . . “The Humanity!!”

Too many answers and not enough questions.

it all real code… check out the Language Reference for more information

Will do.

the first screen of your computer

Screen(0).AvailableWidth / 4

the width of this screen divided by 4
if screen width is 1280 then modalwin width = 1280 / 4 (320)

modalwin.Label1.TextSize = floor(Screen(0).AvailableWidth / 100)

Label Text Size = the width of the screen divided by 100 (12.8), rounded down to 12

Thanks for pointing me in the right direction Axel.

The modal window is drawn to extents. Also the text is fixed, ie. 7 numeric characters wide for a digital like display.

This is what I ended up with.

[code] dim sX, sY as integer



btnClose.Left = sX-150
btnClose.Top = sY-50


//Autosize number to the width
lblNumbers.TextSize = (sX*.24)

//Adjust for Optical Centre

The TextSize multiplier (.24) was worked out by trial and error. I checked it on a PC and Mac at work and on my home pc - works perfectly.