2

I'm very new to creating windows mobile applications. I have a button called 'Settings'- i want this to open a small popup that overlaps the current window with purely a textbox asking for a password. How would I go about this? Do I have to create a new form, but size the form accoringly?

I've created a new form and sized it much smaller, but when it opens, it is full screen.

Any help appreaciated

Lock
  • 5,422
  • 14
  • 66
  • 113
  • Actually I don't think you can, and you shouldn't. Although Windows Mobile development is going to be obsolete in the near future, people who work with it are used to a certain interface. When you decide to do it completely different and lose focus of what feels intuitive on that specific platform people are going to find it odd, and become confused. Thats just my 2 cents about this. – Gerald Versluis Jul 12 '12 at 07:07
  • I dont quite understand the relevance of your comment Gerald. – Lock Jul 12 '12 at 23:10

2 Answers2

3

For the Pop-Up dialog effect, drop a Panel control onto your main form that you call "loginPnl" or something like with one or more TextBox controls and some Button controls for "OK" and "Cancel". Set Visible to False and stick it behind your other controls.

private Panel loginPnl;

public Form1() {
  InitializeComponent();
  loginPnl.SendToBack();
  loginPnl.Visible = false;
}

Now, whenever you are ready for someone to log in, just call your custom Login routine:

private void LoginPanel(bool show) {
  // don't forget to reset your TextBox controls
  loginPnl.Visible = show;
  if (loginPnl.Visible) {
    loginPnl.BringToFront();
    txtLoginPwd1.Text = null;
    txtLoginPwdVerify.Text = null;
  } else {
    loginPnl.SendToBack();
  }
}

Don't forget to hide your Login Panel afterwards, though.

0

Try creating a form that encapsulates your login functionality, then form.ShowDialog(). This will provide more than just a textbox, though, as it will also provide buttons to dismiss the dialog (which I would recommend versus ONLY having a textbox).

If you really want to have only the textbox then you'll need to "fade" all other areas of the screen to give the impression those controls/areas are temporarily nonusuable while your textbox is shown (and other related aspects like focus traversal).

BonanzaDriver
  • 6,411
  • 5
  • 32
  • 35