I got it working.
There is a Difference in saved / displayed Dlg-left and Bottom.
I have to detect where it comes from. With the adjustment, it works fine.
oDlg:Move( nDTop, nDLeft, nDRight - nDLeft - 18, nDBottom - nDTop - 38 ), oDlg:CoorsUpdate() )
( otherwise, these values are counted at Restart )
You can find out the Difference with using :
oDlg:Move( nDTop, nDLeft, nDRight - nDLeft, nDBottom - nDTop), oDlg:CoorsUpdate() )
- Code: Select all Expand view
#include "fivewin.ch"
STATIC oMain, oDlg, nDTop := 100, nDLeft := 200, nDBottom := 600, nDRight := 800, lActivated := .F., c_Path
STATIC cDTop := "100", cDLeft := "200", cDBottom := "600", cDRight := "800"
REQUEST HB_GT_GUI_DEFAULT
#define crlf CHR(13)+CHR(10)
FUNCTION Main()
LOCAL oBut1, oBut2
LOCAL oDTop, oDLeft
LOCAL oDBottom, oDRight
c_Path := CURDRIVE() + ":\" + GETCURDIR()
GET_INI()
DEFINE WINDOW oMain
@ 1 , 1 BUTTON oBut1 PROMPT "Dialog" ;
ACTION IIF( lActivated = .F., Dialogo( oDTop, oDLeft, oDBottom, oDRight ), NIL ) size 100 , 30
@ 1 , 90 BUTTON oBut2 PROMPT "Reset" ACTION ( nDTop := 100 , nDLeft := 100 , nDBottom := 600 , nDRight := 800 , ;
IIF( lActivated = .T., oDlg:End(), NIL ), ;
DIALOGO( oDTop, oDLeft, oDBottom, oDRight ) ) SIZE 100 , 30
@ 1 , 130 BUTTON oBut3 PROMPT "Exit" ;
ACTION oMain:End() size 100 , 30
@ 1 , 20 GET oDTop VAR nDTop OF oMain SIZE 50 , 20 UPDATE
@ 1 , 30 GET oDLeft VAR nDLeft OF oMain SIZE 50 , 20 UPDATE
@ 1 , 40 GET oDBottom VAR nDBottom OF oMain SIZE 50 , 20 UPDATE
@ 1 , 50 GET oDRight VAR nDRight OF oMain SIZE 50 , 20 UPDATE
ACTIVATE WINDOW oMain MAXIMIZED
SAVE_INI()
RETURN NIL
//---------------
FUNCTION DIALOGO( oDTop, oDLeft, oDBottom, oDRight )
lActivated := .T.
// From Top / Left TO Height / Width
// ---------------------------------------------
DEFINE DIALOG oDlg FROM nDTop, nDLeft TO nDBottom, nDRight OF oMain PIXEL ;
STYLE nOr( WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX ) ;
TITLE "Dialog-position and Size : Top " + Alltrim( STR( nDTop )) + ;
", Left : " + Alltrim( STR( nDLeft )) + ;
", Bottom : " + Alltrim( STR( nDBottom )) + ;
", Right : " + Alltrim( STR( nDRight ))
oDlg:bResized = { || oDlg:CoorsUpdate(), AGGIORNA(oDTop, oDLeft, oDBottom, oDRight ) }
oDlg:bMoved := {|| oDlg:CoorsUpdate(), AGGIORNA(oDTop, oDLeft, oDBottom, oDRight ) }
ACTIVATE DIALOG oDlg NOWAIT ;
ON INIT ( oDlg:Move( nDTop, nDLeft, nDRight - nDLeft - 18, nDBottom - nDTop - 38 ), oDlg:CoorsUpdate() )
// oDlg:Move Top / Left , Width / Height
RETURN NIL
// ----------------------------
FUNCTION AGGIORNA(oDTop, oDLeft, oDBottom, oDRight)
nDTop := oDlg:nTop
nDLeft := oDlg:nLeft
nDBottom := oDlg:nBottom
nDRight := oDlg:nRight
oDTop:Refresh()
oDLeft:Refresh()
oDBottom:Refresh()
oDRight:Refresh()
oDlg:cTitle := "Dialog-position and Size : Top " + Alltrim( STR( nDTop )) + ;
", Left : " + Alltrim( STR( nDLeft )) + ;
", Bottom : " + Alltrim( STR( nDBottom )) + ;
", Right : " + Alltrim( STR( nDRight ))
RETURN NIL
//-------- Read INI ----------------------
FUNCTION GET_INI()
Local oInifile
IF !FILE ( c_path + "\SETTINGS.ini" )
SAVE_INI()
ELSE
INI oInifile FILE c_path + "\SETTINGS.ini"
GET cDTop SECTION "Dialog" ENTRY "DlgTop" OF oInifile DEFAULT "100"
GET cDLeft SECTION "Dialog" ENTRY "DlgLeft" OF oInifile DEFAULT "200"
GET cDBottom SECTION "Dialog" ENTRY "DlgBottom" OF oInifile DEFAULT "600"
GET cDRight SECTION "Dialog" ENTRY "DlgRight" OF oInifile DEFAULT "800"
ENDINI
ENDIF
nDTop := VAL(cDTop)
nDLeft := VAL(cDLeft)
nDBottom := VAL(cDBottom)
nDRight := VAL(cDRight)
RETURN( NIL )
// --------- Write INI ------------------------
FUNCTION SAVE_INI()
LOCAL cIniFile := c_path + "\SETTINGS.INI"
lSysini := .T.
IF WritePProString( "Dialog", "DlgTop", ALLTRIM(STR(nDTop)) , cIniFile ) = .F.
lSysini := .F.
ENDIF
IF WritePProString( "Dialog", "DlgLeft", ALLTRIM(STR(nDLeft)) , cIniFile ) = .F.
lSysini := .F.
ENDIF
IF WritePProString( "Dialog", "DlgBottom", ALLTRIM(STR(nDBottom)) , cIniFile ) = .F.
lSysini := .F.
ENDIF
IF WritePProString( "Dialog", "DlgRight", ALLTRIM(STR(nDRight)) , cIniFile ) = .F.
lSysini := .F.
ENDIF
IF lSysini = .F. .or. !FILE( cInifile )
MsgAlert("Not possible, to write in INI-File", "INI-File")
ENDIF
RETURN( NIL )
Best Regards
Uwe