Form does not respect Location set manually

Asked

Viewed 24 times

0

I have this code to open one form which has the size 324x172.

I’m doing this way to open as per resolution:

FormLembreteCheque aviso = new FormLembreteCheque();
int c = Screen.PrimaryScreen.BitsPerPixel;
int w = Screen.PrimaryScreen.Bounds.Width;
int h = Screen.PrimaryScreen.Bounds.Height;

switch (w)
{
    case 800:
        switch (h)
        {
            case 600:
                aviso.Location = new Point(476, 428);
                break;
        }
        break;

    case 1024:
        switch (h)
        {
            case 768:
                aviso.Location = new Point(700, 596);
                break;
        }
        break;

    case 1366:
        switch (h)
        {
            case 768:
                aviso.Location = new Point(1042, 596);
                break;
        }
        break;

    case 1440:
        switch (h)
        {
            case 900:
                aviso.Location = new Point(1116, 728);
                break;
            case 1050:
                aviso.Location = new Point(1116, 878);
                break;
        }
        break;
}

But every hour he opens in a place. He does not follow the rule.

EDIT

Just to help, whoever does it and doesn’t want to do it case, to optimize the code, I did it this way:

aviso.Location = new Point((w - 324),(h - 200));
  • Be more specific. What is aviso?

  • @LINQ n had been selected and was missing, is the form, already edited.

1 answer

1


Missing "warn" that you are setting the position manually.

aviso.StartPosition = FormStartPosition.Manual;
  • That’s right, thank you, I even edited with an optimization of the code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.