James,
it is just a guess. To properly calculate a dimension we need to use +1.
If +1 is not needed then somewhere there is a wrong code...
James,
it is just a guess. To properly calculate a dimension we need to use +1.
If +1 is not needed then somewhere there is a wrong code...
Sorry, I don't understand. The coordinates are aCoord := {100,100,300,500}, so the dimensions are:
width:= 500 - 100 = 400
height:= 300 - 100 = 200
James,
aCoord := {100,100,101,101}
width = 101 - 100 = 1
or
width = 101 - 100 + 1 = 2
?
EMG
![]()
Enrico,
I guess you are confirming my point?
The +1 in not needed, at least in this instance.
James
James,
no! ![]()
Size of 100, 101 is 2 pixels (100 and 101) not 1 pixel.
EMG
Enrico,
Ok, I see what you're saying, but my example seems to be working. I'll do more tests.
/*
Purpose : Test showing how to save/restore dialog location
Author : James Bott, <!-- e --><a href="mailto:jbott@compuserve.com">jbott@compuserve.com</a><!-- e -->
Date : 12/3/2014 2:09:38 PM
Language: Fivewin/xHarbour
Notes : Drag the dialog to a new position, then close it, then press the button
and the dialog will be restored in the last position.
The location is saved using the VALID clause and restored using oDlg:Move()
The location is saved in memory here, but you could use a file to restore
it.
*/
#include "fivewin.ch"
static aCoord
Function main()
local oWnd, oBar, oBtn
aCoord := {100,100,300,500}
define window oWnd
define buttonbar oBar of oWnd
define button oBtn of oBar action MakeDlg(saveRestore())
activate window oWnd maximized on init makeDlg()
return nil
Function MakeDlg(aRect)
local oDlg
Local nTop,nLeft,nWidth,nHeight
define dialog oDlg of wndMain()
@ 2,4 BUTTON "Get Width/Height" ;
ACTION ;
msgInfo( cValToChar(getWndRect(oDlg:hWnd)[3]-getWndRect(oDlg:hWnd)[1] ) +"/"+;
cValToChar(getWndRect(oDlg:hWnd)[4]-getWndRect(oDlg:hWnd)[2]) ) ;
size 100,15
aRect:= saveRestore()
nTop:= aRect[1]
nLeft:= aRect[2]
// test only. Trying adding +1
nWidth:= aRect[4] - aRect[2] +1
nHeight:= aRect[3] - aRect[1] +1
activate dialog oDlg centered ;
VALID ( saveRestore(getWndRect(oDlg:hWnd)), .t.);
ON INIT oDlg:move(nTop, nLeft, nWidth, nHeight, .t.)
return nil
function saveRestore(aRect)
if aRect != nil
aCoord := aclone(aRect)
endif
return aCoord
// eofIn conformance with conventions for the RECT structure, the bottom-right coordinates of the returned rectangle are exclusive. In other words, the pixel at (right, bottom) lies immediately outside the rectangle.
Enrico,
Thanks for finding that.
Enrico, James,
Thanks!
So do we need to modify something in FWH regarding this ?
Antonio Linares wrote:So do we need to modify something in FWH regarding this ?
Cool ![]()