i use this code it work good but when application minimize to system tray it not work!
what is wrong ?
Code:
Subclass.Remove(Application.GetWndHandle()); WM_POWERBROADCAST = 0x218; WM_DESTROY = 0x0002; PBT_APMPOWERSTATUSCHANGE = 10; PBT_APMRESUMEAUTOMATIC = 18; PBT_APMRESUMESUSPEND = 7; PBT_APMSUSPEND = 4; PBT_POWERSETTINGCHANGE = 32787; local s = Subclass.Create(Application.GetWndHandle(), function(hWnd, uMsg, wParam, lParam) if(uMsg == WM_DESTROY)then Subclass.Remove(Application.GetWndHandle()); return 0 end if(uMsg == WM_POWERBROADCAST)then if (wParam == PBT_APMPOWERSTATUSCHANGE) then Application.Restore(); Paragraph.SetText("Paragraph1", "PBT_APMPOWERSTATUSCHANGE."); elseif (wParam == PBT_APMRESUMEAUTOMATIC) then Application.Restore(); Paragraph.SetText("Paragraph2", "PBT_APMRESUMEAUTOMATIC."); elseif (wParam == PBT_APMRESUMESUSPEND) then Application.Restore(); Paragraph.SetText("Paragraph3", "PBT_APMRESUMESUSPEND"); elseif (wParam == PBT_APMSUSPEND) then Application.Restore(); Paragraph.SetText("Paragraph4", "PBT_APMSUSPEND"); elseif (wParam == PBT_POWERSETTINGCHANGE) then Application.Restore(); Paragraph.SetText("Paragraph5", "PBT_POWERSETTINGCHANGE"); end end return Subclass.OldWinProc(hWnd, uMsg, wParam, lParam); end)
Comment