Author Topic: store / restore window position (Win32)  (Read 1824 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Code: GLBasic [Select]



GOSUB RestoreWindow

WHILE TRUE
        PRINT PLATFORMINFO$("TIME"), 0,0
        SHOWSCREEN
WEND


SUB end_of_main:
ENDSUB

INLINE
}

struct RECT{int l,t,r,b;};

extern "C"
{
        int __stdcall GetWindowRect(void* hwnd, void* rect);
        int __stdcall SetWindowPos(void* hwnd, int after, int x, int y, int cx, int cy, int flag);
}
namespace __GLBASIC__ {

ENDINLINE


SUB GLB_ON_QUIT:
        LOCAL x, y
        INLINE
                RECT r;
                ::GetWindowRect(GLBASIC_HWND(), &r);
                x=r.l; y=r.t;
        ENDINLINE      

        INIOPEN "windowrect.ini"
        INIPUT "Window", "left", x
        INIPUT "Window", "top", y

ENDSUB



SUB RestoreWindow:

LOCAL x, y
        INIOPEN "windowrect.ini"
        x = INIGET$( "Window", "left", -1)
        y = INIGET$( "Window", "top",  -1)

        IF x<>-1 AND y<>-1
        INLINE
                ::SetWindowPos(GLBASIC_HWND(), 0, x,y, 0,0, 0x0010|0x0200|0x0001|0x0004|0x0040);
        ENDINLINE
       
        ENDIF

ENDSUB