Announcement

Collapse
No announcement yet.

MemoryEx and catch the WM_POWERBROADCAST not work in minimize to tray

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MemoryEx and catch the WM_POWERBROADCAST not work in minimize to tray

    i use this code it work good but when application minimize to system tray it not work!
    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)
    what is wrong ?

  • #2
    Applications can better adapt their behavior to the current power state of the computer by registering for power events.


    ^^ check that, maybe AMS is destroying the window, i dont know and dont have time to test
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    Working...
    X