Hi there,

I'm writing a .net Windows application in C#. I have 2 forms: the MainForm
and the Login. The MainForm opens the Login as Dialog from the MainForm's
constructor, and Login asks for username/password. I get these data from the
MainForm and check using a Web service that they're ok. If username/password
are not ok, I want to close the whole application, but I don't know how
(this.Close() doesn't work). Can I close the app from the MainForm's
constructor? Should I call the Login dialog and web service somewhere else?

Thanks,

Alejandro.

Re: Login dialog by Herfried

Herfried
Tue Sep 23 17:33:07 CDT 2003

Hello,

"Alejandro Casal" <Alejandro@kpnmms.com> schrieb:
> I'm writing a .net Windows application in C#. I have 2
> forms: the MainForm and the Login. The MainForm opens
> the Login as Dialog from the MainForm's constructor, and
> Login asks for username/password. I get these data from the
> MainForm and check using a Web service that they're ok.
> If username/password are not ok, I want to close the whole
> application, but I don't know how (this.Close() doesn't work).
> Can I close the app from the MainForm's constructor? Should
> I call the Login dialog and web service somewhere else?

The only way preventing the class from being instantiated is to throw an
exception.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet



RE: Login dialog by v-yiy

v-yiy
Tue Sep 23 20:49:45 CDT 2003

Hi Alejandro,
You may try implement it this way.
1. In Constructor of your MainForm , set the MainForm.Visible = false;
2. In MainForm.On_Load() event handler, show the Login Dialog
and you can call Close() in this handler.
3. if login ok , then set the MainForm.Visible = true;
If you have problem with this, please let me know.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" shouldbe removed before
sending, Thanks!

--------------------
| From: "Alejandro Casal" <Alejandro@kpnmms.com>
| Subject: Login dialog
| Date: Tue, 23 Sep 2003 19:07:04 +0200
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <#55CdUfgDHA.632@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: ip503d4c11.speed.planet.nl 80.61.76.17
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52946
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi there,
|
| I'm writing a .net Windows application in C#. I have 2 forms: the MainForm
| and the Login. The MainForm opens the Login as Dialog from the MainForm's
| constructor, and Login asks for username/password. I get these data from
the
| MainForm and check using a Web service that they're ok. If
username/password
| are not ok, I want to close the whole application, but I don't know how
| (this.Close() doesn't work). Can I close the app from the MainForm's
| constructor? Should I call the Login dialog and web service somewhere
else?
|
| Thanks,
|
| Alejandro.
|
|
|


Re: Login dialog by Alejandro

Alejandro
Wed Sep 24 06:09:54 CDT 2003


He Ying-Shen, it works, thanks a lot!

Alejandro.


"Ying-Shen Yu[MSFT]" <v-yiy@online.microsoft.com> wrote in message
news:UP91g4jgDHA.2076@cpmsftngxa06.phx.gbl...
> Hi Alejandro,
> You may try implement it this way.
> 1. In Constructor of your MainForm , set the MainForm.Visible = false;
> 2. In MainForm.On_Load() event handler, show the Login Dialog
> and you can call Close() in this handler.
> 3. if login ok , then set the MainForm.Visible = true;
> If you have problem with this, please let me know.
> Thanks!
>
> Best regards,
>
> Ying-Shen Yu [MSFT]
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
>
> This posting is provided "AS IS" with no warranties and confers no rights.
> You should not reply this mail directly, "Online" shouldbe removed before
> sending, Thanks!
>
> --------------------
> | From: "Alejandro Casal" <Alejandro@kpnmms.com>
> | Subject: Login dialog
> | Date: Tue, 23 Sep 2003 19:07:04 +0200
> | Lines: 15
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> | Message-ID: <#55CdUfgDHA.632@TK2MSFTNGP10.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.windowsforms
> | NNTP-Posting-Host: ip503d4c11.speed.planet.nl 80.61.76.17
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
> microsoft.public.dotnet.framework.windowsforms:52946
> | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
> |
> | Hi there,
> |
> | I'm writing a .net Windows application in C#. I have 2 forms: the
MainForm
> | and the Login. The MainForm opens the Login as Dialog from the
MainForm's
> | constructor, and Login asks for username/password. I get these data from
> the
> | MainForm and check using a Web service that they're ok. If
> username/password
> | are not ok, I want to close the whole application, but I don't know how
> | (this.Close() doesn't work). Can I close the app from the MainForm's
> | constructor? Should I call the Login dialog and web service somewhere
> else?
> |
> | Thanks,
> |
> | Alejandro.
> |
> |
> |
>



Re: Login dialog by Alejandro

Alejandro
Fri Sep 26 05:09:38 CDT 2003


He Ying-Shen, it works, thanks a lot!

Alejandro.


"Ying-Shen Yu[MSFT]" <v-yiy@online.microsoft.com> wrote in message
news:UP91g4jgDHA.2076@cpmsftngxa06.phx.gbl...
> Hi Alejandro,
> You may try implement it this way.
> 1. In Constructor of your MainForm , set the MainForm.Visible = false;
> 2. In MainForm.On_Load() event handler, show the Login Dialog
> and you can call Close() in this handler.
> 3. if login ok , then set the MainForm.Visible = true;
> If you have problem with this, please let me know.
> Thanks!
>
> Best regards,
>
> Ying-Shen Yu [MSFT]
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
>
> This posting is provided "AS IS" with no warranties and confers no rights.
> You should not reply this mail directly, "Online" shouldbe removed before
> sending, Thanks!
>
> --------------------
> | From: "Alejandro Casal" <Alejandro@kpnmms.com>
> | Subject: Login dialog
> | Date: Tue, 23 Sep 2003 19:07:04 +0200
> | Lines: 15
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> | Message-ID: <#55CdUfgDHA.632@TK2MSFTNGP10.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.framework.windowsforms
> | NNTP-Posting-Host: ip503d4c11.speed.planet.nl 80.61.76.17
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl
> microsoft.public.dotnet.framework.windowsforms:52946
> | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
> |
> | Hi there,
> |
> | I'm writing a .net Windows application in C#. I have 2 forms: the
MainForm
> | and the Login. The MainForm opens the Login as Dialog from the
MainForm's
> | constructor, and Login asks for username/password. I get these data from
> the
> | MainForm and check using a Web service that they're ok. If
> username/password
> | are not ok, I want to close the whole application, but I don't know how
> | (this.Close() doesn't work). Can I close the app from the MainForm's
> | constructor? Should I call the Login dialog and web service somewhere
> else?
> |
> | Thanks,
> |
> | Alejandro.
> |
> |
> |
>