Home All Groups Group Topic Archive Search About

Problem on shutdown computer if my appication is opened

Author
4 May 2007 2:46 AM
Cylix
I wrote two application for my company,
but I found that, if anyone of application is opened, the user cannot
shutdown the computer.

the behaviour is that:
if one of application is opened, and then click the shutdown, my
application will be terminate but the computer didn't shotdown.
afterward, if I click the shutdown again, since my application is
already terminated, so the computer can shutdown this time.

What the problem is??

Author
4 May 2007 6:19 AM
Ray Cassick
Show quote Hide quote
"Cylix" <cylix2***@gmail.com> wrote in message
news:1178246819.692740.185360@q75g2000hsh.googlegroups.com...
>I wrote two application for my company,
> but I found that, if anyone of application is opened, the user cannot
> shutdown the computer.
>
> the behaviour is that:
> if one of application is opened, and then click the shutdown, my
> application will be terminate but the computer didn't shotdown.
> afterward, if I click the shutdown again, since my application is
> already terminated, so the computer can shutdown this time.
>
> What the problem is??
>

I had this happen when; in my application I was aborting the form close
event if there was unsaved data. Apparently setting the cancel property to
true was getting in the way of Windows being allowed to close.



I had to look at the way windows was being asked to close and act
accordingly, then allow the form to close and in turn allow Windows to
close.
Author
4 May 2007 6:51 AM
Cylix
Thanks Ray,

I have tried to comment the form closing event already, but the
problem still here.
Do you find any solution for this?
Author
5 May 2007 2:02 AM
Ray Cassick
Do you have any forms that are hidden at the time? They might be causing
issues.

Show quoteHide quote
"Cylix" <cylix2***@gmail.com> wrote in message
news:1178261516.132828.16530@p77g2000hsh.googlegroups.com...
> Thanks Ray,
>
> I have tried to comment the form closing event already, but the
> problem still here.
> Do you find any solution for this?
>
Author
6 May 2007 12:08 AM
Newbie Coder
Cylix,

Use this code & it will do what you need:

    ' Exit Windows message
    Private Shared WM_QUERYENDSESSION As Integer = &H11


#Region "Window Proc (SUB)"


<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissi
ons.SecurityAction.Demand, Name:="FullTrust")> _
        Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
        ' Listen for operating system messages
        If m.Msg = WM_QUERYENDSESSION Then
            Application.Exit()
        End If
        ' Handle the message
        MyBase.WndProc(m)
    End Sub
#End Region

I hope this helps,

--
Newbie Coder
(It's just a name)

Show quoteHide quote
"Ray Cassick" <rcass***@enterprocity.com> wrote in message
news:eolL0lrjHHA.1216@TK2MSFTNGP03.phx.gbl...
> Do you have any forms that are hidden at the time? They might be causing
> issues.
>
> "Cylix" <cylix2***@gmail.com> wrote in message
> news:1178261516.132828.16530@p77g2000hsh.googlegroups.com...
> > Thanks Ray,
> >
> > I have tried to comment the form closing event already, but the
> > problem still here.
> > Do you find any solution for this?
> >
>
>
Author
8 May 2007 3:52 AM
Cylix
I know the problem and solved it.
Thanks a lot.
Author
10 May 2007 8:23 PM
Ray Cassick
"Cylix" <cylix2***@gmail.com> wrote in message
news:1178596376.593143.181380@l77g2000hsb.googlegroups.com...
>I know the problem and solved it.
> Thanks a lot.
>

share share share.

Show quoteHide quote
:)