Embedded modal question

S

S Wheeler

Hi all -
I am somewhat new to winforms and my question should be kind of basicbut I
have been unable to find the solution thus far.

I have a VB.net app that requires a user to login; the idea is to open the
app with toolbars disabled - the user clicks on a "login button" and a login
dialog (form) appears. The user enters a username password pair and is
subsequently authenticated and the toolbars are then enabled; simple so far.
But, I want the login dialog to be modal which it is by using showdialog()
but the user can move the login dialog outside of the bounds of the main
application window - I was able to prevent this by using an "embedded form"
but then that was not modal - so, how can I make an embedded form modal OR
how can I make a modal dialog that can not be moved outside of a "parent"
form (window)?

Thanks...
SWheeler
 
M

Mike Hofer

S said:
Hi all -
I am somewhat new to winforms and my question should be kind of basicbut I
have been unable to find the solution thus far.

I have a VB.net app that requires a user to login; the idea is to open the
app with toolbars disabled - the user clicks on a "login button" and a login
dialog (form) appears. The user enters a username password pair and is
subsequently authenticated and the toolbars are then enabled; simple so far.
But, I want the login dialog to be modal which it is by using showdialog()
but the user can move the login dialog outside of the bounds of the main
application window - I was able to prevent this by using an "embedded form"
but then that was not modal - so, how can I make an embedded form modal OR
how can I make a modal dialog that can not be moved outside of a "parent"
form (window)?

Thanks...
SWheeler

I'm not sure I understand how your application is configured, but I'm
going to try to recap it for clarity.

You have a main window which contains some toolbars.
The toolbar buttons should be disabled until the user logs into the
application.
Somewhere on the form, you have a Log On button.
When the user clicks the Log On button, the Log On dialog box appears.
The user provides their credentials and clicks an OK button.
When the user clicks the OK button, you authenticate them, and then
close the dialog.
When the dialog is closed, control returns to the main window.
The main window enables the dialog buttons if the user was successfully
authenticated.

If this is the correct idea, then it should work just fine. Why do you
want to prevent the user from moving the dialog box outside the bounds
of the main window? That's nonstandard behavior for a Windows
application -- users should be free to move the dialog to any position
they like.

The desired behavior sounds like an MDI feature to me; however, dialog
boxes should NOT be MDI child windows--it's counterintuitive. I'd
really recommend sticking with a standard windows dialog, and letting
the user position it however they want to.

I probably haven't helped much, but I'd like to help you out. Can you
explain a bit more about the design, and why you want to constrain the
window's movement?

--Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top