How to calculate this dialog-position ? RESOLVED

How to calculate this dialog-position ? RESOLVED

Postby ukoenig » Fri Aug 02, 2019 8: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 )

Image

regards
Uwe :?:
Last edited by ukoenig on Fri Aug 02, 2019 10:00 am, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to calculate this dialog-position ?

Postby ukoenig » Fri Aug 02, 2019 9:59 am

I got it working :D

Code: Select all  Expand view

#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 :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests