(Was:
RE: [vwnc] Is it posible to handle killing the visual process?) I’ve
published ServiceStartup in the public Store as a way to help people use the
excellent WinService package built by the COAST guys. With these two packages,
it’s much simpler to create VW programs that run as headless Windows services
– no need to use srvany or other Windows resource kit tools, or to
require your users to use them. The services receive the appropriate
notifications from Windows of service stop or system shutdown events. They can
also respond in similar ways to Unix SIGTERM and SIGHUP. See the package and
class comments for more details. For
this version, I’ve kept plenty of commented-out COAST code, in the hope
that it helps give some idea of what kinds of code to add where in your own
subclass. Share
and enjoy, Steve From:
[hidden email] [mailto:[hidden email]] On Behalf Of Emiliano
Pérez Steven, that was really really
helpful. 2008/10/3 Wallen, David <[hidden email]> Steve, This
goes much further than our docs in Chapter 1! I'll file this info away for
future reference. Hopefully
Emiliano can find what he needs here. -
Dave From: [hidden email]
[mailto:[hidden email]]
On Behalf Of Steven Kelly
When
the user tries to shutdown, restart or log off, Windows sends the
WM_QUERYENDSESSION (16r11 = 17) message to all applications. The VM
responds true or false to WM_QUERYENDSESSION depending on the value of
acceptQuitEvents. Note that the VM responds: the image doesn't get a chance to
intervene. From Windows' point of view, if all applications return true then
the shutdown proceeds; if any return false (zero), the shutdown is not started
and Windows stops asking any remaining applications. However, the applications
that replied true will still be closed with WM_ENDSESSION (apparently: the
Windows docs seem to contradict each other on this). Regardless
of the result of WM_QUERYENDSESSION, Windows sends WM_ENDSESSION (16r16 = 22)
to all windows, passing the overall result as a Boolean in wParam. If you want
a VW window to receive WM_ENDSESSION, add the following in its postOpenWith:
method:
aBuilder window application: self.
aBuilder window sendWindowEvents: #(#eventUnknown) In
its windowEvent:from: method you can then add:
(anEvent key == #eventUnknown and: [Screen default platformName =
'MS-Windows' and: [((anEvent value at: 10) longAt: 9) = 22]])
ifTrue: [self closeRequest] The
ifTrue: action can of course be whatever you want. The test is probably not
quite right, because we should also check that wParam is true – remember
WM_ENDSESSION is sent even if some app refused WM_QUERYENDSESSION and hence
Windows will not actually shut down. Here are the contents of "anEvent
value" in that case: #(0
2469 0 0 0 0 0 0 0 #[0 0 0 0 165 9 0 0 22 0 0 0 0
0 0 0 0 0 0 0] 0 nil nil nil nil nil) I
guess longAt: 13 will be wParam and longAt: 17 will be lParam (I'm assuming
32-bit Windows here: in 64-bit, I think HWND is 64 bits, not sure about the
others). So maybe an extra check: ((anEvent
value at: 10) longAt: 13) ~= 0 before
deciding to do whatever pre-shutdown tidying up your app requires. I
don't know what your hex 3B is: it's not listed anywhere that I could find. The
details are here: http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx Finally,
note this all applies to normal GUI apps. If you have a console app or a
service, shutdown notification is different. For services, see WinService in
the public repository: call it with something like this: [
interface := WinServiceInterface new.
interface
startDispatcherWithHandler:
[:event |
(event = interface SERVICE_CONTROL_STOP
or: [event = interface SERVICE_CONTROL_SHUTDOWN])
ifTrue:
["ADD YOUR SERVICE SHUTDOWN CODE HERE"]]
serviceName: serviceName
startupBlock:
["ADD YOUR SERVICE STARTUP CODE HERE"] ]
fork HTH, Steve From: [hidden email]
[mailto:[hidden email]]
On Behalf Of Emiliano Pérez David, i´ve checked the AppDevGuide and tried
the suggestions, but they didn´t work for me. 2008/9/29 Wallen, David <[hidden email]> Check
out "Exiting VisualWorks" -> "Closing Windows" in
Chapter 1 of the AppDevGuide.pdf. I haven't worked with that system, but it may
help you a bit. -
Dave From: [hidden email]
[mailto:[hidden email]]
On Behalf Of Emiliano Pérez
Thanks for the hint David!
2008/9/18 Wallen, David <[hidden email]>
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |