> Le 16/04/2012 09:10, Rolf-Werner Eilert a écrit :
>> This is Gambas 2, a very old project of mine and yet a program that runs
>> continuously on my desktop. Last week, I got a new monitor with a wider
>> resolution, and now there is something going wrong.
>> The program shows an overview of the rooms in the school with LTSP
>> terminals, which one is switched on and where someone has logged in.
>> When I programmed it, I used some frames to have an optical marking for
>> the rooms. Then I used labels to display the numbers of the terminals
>> and colors for their status.
>> The form is fixed. The frames are of a fixed size. All sizes are in
>> pixels, aren't they? Then I define the labels, for instance like this:
>> FOR i = 0 TO 26
>> ll = NEW Label(Form1)
>> lbl[i].Text = CStr(i)
>> lbl[i].BackColor = color.White
>> lbl[i].Width = 40
>> lbl[i].Height = 20
>> lbl[i].Alignment = align.Center
>> lbl[i].Font.Size = 11
>> lbl[i].Font.Bold = TRUE
>> SELECT CASE i
>> CASE 0
>> lbl[i].Visible = FALSE
>> CASE 1, 3, 5, 7, 9, 11, 13
>> lbl[i].X = 160
>> lbl[i].Y = 20 + (i * 14)
>> CASE 2, 4, 6, 8, 10, 12, 14
>> lbl[i].X = 220
>> lbl[i].Y = 20 + ((i - 1) * 14)
>> CASE 15, 17, 19, 21, 23, 25
>> lbl[i].X = 10
>> lbl[i].Y = 15 + ((i - 13) * 15)
>> CASE 16, 18, 20, 22, 24, 26
>> lbl[i].X = 70
>> lbl[i].Y = 15 + ((i - 14) * 15)
>> END SELECT
>> So all positions should be fixed. But with the higher screen resolution,
>> the labels land on wrong positions. The frames appear as if they were
>> slightly wider and higher now, and the labels land too much on the left
>> and too high. Before, I had 1280x1024, now it's 1600x1200.
>> Any explanation for this? I try to add a screenshot, hope the mailer
>> doesn't reject it.
> By default all controls have a relative position and size (except the
> one you create manually) that are proportional to the Desktop.Scale
> property. I.e. they use the MoveScaled() method and not the Move() method.
> Either set the (Scaled) form property to FALSE or do not use absolute
> positions when creating your controls.
Good morning Benoit,
After thinking this over and trying around a bit this morning, I guess I
finally understood (sometimes I'm somewhat slow :-) )
With the higher resolution the fonts are enlarged to keep everything
comfortable and readable. Then all elements in the form are enlarged by
the same factor to keep the form about the same real-world size it had
before. My labels, however, still refer to actual XY screen pixels.
I looked into another project this morning and found the same thing:
forms have been enlarged, fonts are wider, but not every graphic element
can follow (e. g. there is a photo shown, and it scales too small as the
frame is shown wider now).
Trying to set this form's (Scaled) to FALSE didn't help, everything
stays large. Do you have any idea what else I could try to keep
everything as large as it was created for SXGA?
On the other hand, I don't mind forms adapting to screen resolution, but
then I will need to somehow read their scaling factor (for such things
as the photo for instance). Is there any function for it?