Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Losing connection after PC returns from sleep mode
Message
De
20/12/2019 10:46:15
 
 
À
12/04/2019 11:48:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
01668055
Message ID:
01672350
Vues:
70
NICE.
However, PBT_APMQUERYSUSPEND is no longer supported. It appears that, rather than giving the opportunity to prevent the suspend at that moment, newer than Vista versions expect an application to inform Windows about 'being really busy' as soon as the busy job starts. See: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

>>>Windows sends out messages to each window telling it the machine is going to sleep. You can use BINDEVENT(_screen.hwnd, WM_POWERBROADCAST, myObj, "myHandlerMethod") to capture the event:
>>>
LPARAMETERS hwnd, msg, wParam, lParam
>>>
>>>See here for the wParam and lParam details:
>>>https://docs.microsoft.com/en-us/windows/desktop/Power/wm-powerbroadcast
>>>
>>>I can write it all out for you tomorrow if you'd like.
>>
>>If you don't mind. Thank you.
>
>
#define WM_POWERBROADCAST           0x218
>
>#define PBT_APMPOWERSTATUSCHANGE    0xA
>#define PBT_APMRESUMEAUTOMATIC      0x12
>#define PBT_APMRESUMESUSPEND        0x7
>#define PBT_APMSUSPEND              0x4
>#define PBT_POWERSETTINGCHANGE      0x8013
>#define PBT_APMBATTERYLOW           0x9
>#define PBT_APMOEMEVENT             0xB
>#define PBT_APMQUERYSUSPEND         0x0
>#define PBT_APMQUERYSUSPENDFAILED   0x2
>#define PBT_APMRESUMECRITICAL       0x6
>
>
>loObj = CREATEOBJECT("WindowsIntercept")
>BINDEVENT(_vfp.hwnd, WM_POWERBROADCAST, loObj, "myHandlerMethod")
>READ EVENTS
>
>
>DEFINE CLASS WindowsIntercept AS Custom
>
>    * Record information here you need to record on shut downs
>
>    PROCEDURE myHandlerMethod
>    LPARAMETERS nHwnd, nMsg, wParam, lParam
>        DO CASE
>            CASE wParam = PBT_APMPOWERSTATUSCHANGE
>                this.PowerSourceChanged()
>
>            CASE wParam = PBT_APMRESUMEAUTOMATIC
>                this.Resuming(.t.)
>
>            CASE wParam = PBT_APMRESUMESUSPEND
>                this.Resuming(.f.)
>
>            CASE wParam = PBT_APMSUSPEND
>                this.Suspending()
>
>            CASE wParam = PBT_POWERSETTINGCHANGE
>                * Note:  This will only occur if you register for it using RegisterPowerSettingNotification()
>                this.PowerSettingsChanged()
>
>            CASE wParam = PBT_APMBATTERYLOW
>                this.BatteryLow()
>
>            CASE wParam = PBT_APMOEMEVENT
>                this.OemPowerEvent()
>
>            CASE wParam = PBT_APMQUERYSUSPEND
>                this.WindowsAskingIfWeCanSuspend()
>
>            CASE wParam = PBT_APMQUERYSUSPENDFAILED
>                this.SuspendHasFailed()
>
>            CASE wParam = PBT_APMRESUMECRITICAL
>                this.ResumedFromCriticalShutdown()
>        ENDCASE
>
>        * Always return .t.
>        RETURN .t.
>    ENDPROC
>
>    * Switched from battery to A/C power or vice-versa
>    PROCEDURE PowerSourceChanged
>        WAIT WINDOW "Power source changed..." NOWAIT
>    ENDPROC
>
>    * The machine is resuming from a sleep mode and is preparing for normal work
>    PROCEDURE Resuming
>    LPARAMETERS tlNonUserResume     && .f. = the user manually resumed, .t. = it woke up for some other reason
>        WAIT WINDOW "Resuming..." NOWAIT
>    ENDPROC
>
>    * The machine is going into a sleep mode of some kind, and is suspending
>    PROCEDURE Suspending
>        WAIT WINDOW "Suspending..." NOWAIT
>    ENDPROC
>
>    * The user has change some power setting, like how long until the monitor shuts off, etc.
>    PROCEDURE PowerSettingsChanged
>        WAIT WINDOW "Power Settings Changed" NOWAIT
>    ENDPROC
>
>    PROCEDURE BatteryLow
>        WAIT WINDOW "Battery Low" NOWAIT
>    ENDPROC
>
>    PROCEDURE OemPowerEvent
>        WAIT WINDOW "OEM Power Event Signaled" NOWAIT
>    ENDPROC
>
>    PROCEDURE WindowsAskingIfWeCanSuspend
>        WAIT WINDOW "Windows is asking if we can suspend" NOWAIT
>    ENDPROC
>
>    PROCEDURE SuspendHasFailed
>        WAIT WINDOW "Windows is notifyign us that a suspend request failed" NOWAIT
>    ENDPROC
>
>    PROCEDURE ResumedFromCriticalShutdown
>        WAIT WINDOW "Windows has resumed from a critical shutdown" NOWAIT
>    ENDPROC
>
>ENDDEFINE
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform