FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to calculate this dialog-position ? RESOLVED
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
How to calculate this dialog-position ? RESOLVED
Posted: Fri Aug 02, 2019 08:17 AM
Hello,

how to calculate the dialog-position from desktop-top and desktop-left ( not from window )
Tested oDlg:nTop and oDlg:nLeft returns 0 :-)

I explain :
A window-button opens the dialog on a defined position
Moving the dialog on the desktop I have to save top and left of the new position.
Like the window, the dialog must be shown on the saved position on new start
A solution will answer my other question of a calculation as well.
viewtopic.php?f=3&t=37568
( the calculation of a child-dialog-position in relation fo a folder-page-field )



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to calculate this dialog-position ?
Posted: Fri Aug 02, 2019 09:59 AM
I got it working :-)

Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION MAIN()
local oWnd

DEFINE WINDOW oWnd

@ 120, 50 BUTTON "Dialog" OF oWnd SIZE 80, 40 PIXEL ACTION CreateDlg()  
@ 120, 200 BUTTON "Restore" OF oWnd SIZE 80, 40 PIXEL ACTION RestDlgPos( oDlg ) 
@ 120, 300 BUTTON "Exit" OF oWnd SIZE 80, 40 PIXEL ACTION oWnd:End() 

ACTIVATE WINDOW oWnd  

RETURN NIL

// -----------

STATIC FUNCTION CREATEDLG()
static lOk  := .t.
local oDlg, oBtn
local lInit := .t.

IF ! lOK
      return nil
ENDIF

// In case of resource
DEFINE DIALOG oDlg RESOURCE "DIALOG1" ;
STYLE nOr( WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, ;
WS_MINIMIZEBOX, WS_MAXIMIZEBOX )

REDEFINE  BUTTON oBtn ID 210 OF oDlg  ACTION ( SaveDlgPos( oDlg ), oDlg:End() )

oDlg:bMoved    := { || If( ! lInit, SaveDlgPos( oDlg ), nil ) }
oDlg:bResized  := { || SaveDlgPos( oDlg ) }

ACTIVATE DIALOG oDlg ON INIT ( RestDlgPos( 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 RESTDLGPOS( 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


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion