Announcement

Collapse
No announcement yet.

HowTo: Save if window was maximized?

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

  • HowTo: Save if window was maximized?

    Hi. I tried to save if the app window was maximized to set it to maximized on the next run.
    I tried it with this Code on "OnSize":
    Code:
    if e_Type == SIZE_MAXIMIZED then
    	MAXIMIZED = true;
    end
    if e_Type == SIZE_RESTORED then
    	MAXIMIZED = false;
    end
    But the RESTORED event is always called when the app launches and so it's always set to false and not maximized on startup (put it in Preload/onShow). If I comment this line it always stays maximized because its not set to false when the user restores the window.

    Does anyone know a workaround? I could not find an action to get the windows state on close (to know if it was maximized or not).
    Bl4ckSh33p-Soft - Custom Software and Indie Games

  • #2
    Hi Bl4ckSh33p

    you can do that by this code Example :

    On Size Put this Code:

    Code:
    Application.SaveValue("abood", "Widht", e_WindowWidth);
    
    Application.SaveValue("abood", "Height", e_WindowHeight);
    and On StartUp Put this Code :

    Code:
    w = Application.LoadValue("abood", "Widht");
    h = Application.LoadValue("abood", "Height");
    Window.SetSize(Application.GetWndHandle(), w, h);

    and you Can do the Same of that with the POS :yes

    Comment


    • #3
      Or you can use the GetWindowPlacement function OnClose then OnPreload call this:

      Code:
      Dimmain = function()
       local load, band, bor, sprintf = Library.Load, Bitwise.And, Bitwise.Or, string.format;
       local user32 	= load("user32.dll");
       local style = user32.GetWindowLongA(Application.GetWndHandle(), -20);
       style = bor(style, 0x00080000);
       user32.SetWindowLongA(Application.GetWndHandle(), -20, style);
       user32.SetLayeredWindowAttributes(Application.GetWndHandle(),0,0,0x00000002)
      end;
      then use the SetWindowPlacement with saved values from the GetWindowPlacement function and the Window will be reset to the exact same state and on the exact same monitor as it was the last time it was run followed by:

      Code:
      User32.SetLayeredWindowAttributes(Application.GetWndHandle(),0,255,0x00000002)
      to set the window visible again so the whole restoring is done without a flicker.

      You'll need MemoryEx to do this.

      Comment

      Working...
      X