[Gambas-user] Screen positions vary with resolution

Benoît Minisini gambas at ...1...
Mon Apr 16 13:05:27 CEST 2012


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.Add(ll)
> 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
> NEXT
>
> 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.
>
> Regards
>
> Rolf
>

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.

Regards,

-- 
Benoît Minisini




More information about the User mailing list