FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to save and restore windows position and size?
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
How to save and restore windows position and size?
Posted: Fri Aug 29, 2014 07:42 PM
Hi,

I use this methods to save and restore my main window. It works ok. but when i move to window, my sizes changes.

How can I solve this problem?

Thanks

Code (fw): Select all Collapse
METHOD Koordinat_Save() CLASS tApplication
LOCAL XFILE, aMyIni,cParagraf 
    xFILE=::CROOT+"AAAA.INI"
    aMyIni := IniLoad(XFILE)
    cParagraf := "DESKTOP_"+ALLTRIM(::aUSERINFO[1])
    IniPut(aMyIni,cParagraf,"nTop",NTRIM(::oWnd:nTop))
    IniPut(aMyIni,cParagraf,"nLeft",NTRIM(::oWnd:nLeft))
    IniPut(aMyIni,cParagraf,"nHeight",NTRIM(::oWnd:nHeight))
    IniPut(aMyIni,cParagraf,"nWidth",NTRIM(::oWnd:nWidth))
    IniSave(aMyIni,XFILE)

    MsgInfo("Masaüstü koordinatlar saklandı.("+ALLTRIM(XFILE)+")","Bilgi")
RETURN
//---------------------------------------------------------------------------//
METHOD Koordinat_Restore() CLASS tApplication
LOCAL XFILE, aMyIni,cParagraf, nTop, nLeft, nHeight, 
nWidth      
    xFILE=::CROOT+"AAAA.INI"
    aMyIni := IniLoad(XFILE)
    cParagraf := "DESKTOP_"+ALLTRIM(::aUSERINFO[1])

    nTop        := 0
    nLeft       := 0
    nHeight := 0
    nWidth  := 0

    IF FILE(XFILE)
        nTop        := VAL(OIniGet(aMyIni,cParagraf,"nTop","0"))
        nLeft   := VAL(OIniGet(aMyIni,cParagraf,"nLeft","0"))
        nHeight := VAL(OIniGet(aMyIni,cParagraf,"nHeight","0"))
        nWidth  := VAL(OIniGet(aMyIni,cParagraf,"nWidth","0"))
    ENDIF

    IF !EMPTY(nTop) .AND. !EMPTY(nLeft) .AND. !EMPTY(nHeight) .AND. !EMPTY(nWidth)
        ::oWnd:SetSize(nWidth, nHeight, .T.)
        ::oWnd:SetPos(nTop, nLeft)
    ENDIF

RETURN
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: How to save and restore windows position and size?
Posted: Fri Aug 29, 2014 08:16 PM

Hi,

You can use function

aKoordinat := GetWndRect(oDlg:hWnd)

Best regards,

Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: How to save and restore windows position and size?
Posted: Sat Aug 30, 2014 08:44 AM
Thank you for your answer.

I have found the solution like that.

Code (fw): Select all Collapse
    ::oWnd:Normal()      <------- It solves my problem.
   ::oWnd:SetSize(nWidth, nHeight, .T.)
   ::oWnd:SetPos(nTop, nLeft)
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion