#include "fivewin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd
@ 40,40 BUTTON "Dialog" OF oWnd SIZE 80,28 PIXEL ACTION CreateDlg()
ACTIVATE WINDOW oWnd MAXIMIZED
return nil
static function CreateDlg()
static lOk := .t.
local oDlg
local lInit := .t.
if ! lOK
return nil
endif
// In case of resource
DEFINE DIALOG oDlg RESOURCE "DIALOGO" ;
STYLE nOr( WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, ;
WS_MINIMIZEBOX, WS_MAXIMIZEBOX )
/* //Desde codigo
DEFINE DIALOG oDlg ;
STYLE nOr( WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, ;
WS_MINIMIZEBOX, WS_MAXIMIZEBOX )
*/
oDlg:bMoved := { || If( ! lInit, SaveDlgPos( oDlg ), nil ) }
oDlg:bResized := { || SaveDlgPos( oDlg ) }
ACTIVATE DIALOG oDlg ON INIT ( RestoreDlgPos( oDlg ), lInit := .f. ) ;
VALID ( SaveDlgPos( oDlg ), lOK := .t. )
return nil
static function SaveDlgPos( oDlg )
local oIni, oRect
oIni := TIni():New( ".\dlgpos.ini" )
if ! IsIconic( oDlg:hWnd ) .and. ! IsZoomed( oDlg:hWnd )
oRect := oDlg:GetRect()
oIni:Set( "Dialog", "nTop", oRect:nTop )
oIni:Set( "Dialog", "nLeft", oRect:nLeft )
oIni:Set( "Dialog", "nBottom", oRect:nBottom )
oIni:Set( "Dialog", "nRight", oRect:nRight )
endif
return nil
static function RestoreDlgPos( oDlg )
local oIni
local nTop,nLeft, nBottom, nRight
oIni := TIni():New( ".\dlgpos.ini" )
nTop := oIni:Get( "Dialog", "nTop", 100 )
nLeft := oIni:Get( "Dialog", "nLeft", 100 )
nBottom := oIni:Get( "Dialog", "nBottom", 600 )
nRight := oIni:Get( "Dialog", "nRight", 800 )
oDlg:Move( nTop, nLeft, nRight - nLeft, nBottom - nTop )
return nil