Page 1 of 1
form in form left, top positions
Posted: Wed Feb 17, 2010 8:10 am
by PaPi
Hi my friends,
I`m working with a program, and have an problem:
The program have 2 forms, main form, and a child form. The main form is the parent of the child form. But all the forms in FNXBASIC have left and top coordinates on SCREEN.
How can I wish relative coordinates of a child form on a main form?
This method is bad:
x=childform.left-mainform.left and
y=childform.top-mainform.top
Here x and y gives bad results, when the main form is moving: too...
What can I do?
PaPi
form in form left, top positions
Posted: Wed Feb 17, 2010 10:27 pm
by magna
In my Library Generator I also use two forms, one child of the other. Here the coordinates of the child ARE relative:
OBJECT frmMain AS FORM
Center=True : Width=800 : Height=600
...
OBJECT frmAbout AS FORM
Left=260 : Top=180 : AutoSize=True
...
END OBJECT
END OBJECT
Maybe you defined them as parallel objects like
OBJECT frmMain AS FORM
Center=True : Width=800 : Height=600
...
END OBJECT
OBJECT frmAbout AS FORM
Left=260 : Top=180 : AutoSize=True
Parent=frmMain
...
END OBJECT
which probably won`t work.
form in form left, top positions
Posted: Thu Feb 18, 2010 7:41 am
by PaPi
This is the error, magna:
`forminform_test by magna/PaPi
OBJECT frmMain AS FORM
Center=True : Width=800 : Height=600
OBJECT frmAbout AS FORM
Left=0 : Top=0 `: AutoSize=True
object lala as label
end object
onclick=position
END OBJECT
END OBJECT
frmAbout.Show
frmMain.ShowModal
sub position()
lala.caption=str$(frmabout.left)+" "+str$(frmabout.top)
end sub
You can start this program, and click on frmAbout, then you can move the frmAbout,and now click!
The coordinates are bad...
Why?
This is the question /Hamlet/
(and PaPi)
form in form left, top positions
Posted: Fri Feb 19, 2010 8:30 am
by PaPi
This error to get on actual FNXBASIC, and on new FNXBASIC 2010 too.
And, it is an other sample for this error:
code:
----------
`A form as child of another form - form_test1
object mainform as form
left=0
top=0
width=400
height=400
caption="Mainform"
object subform as form
object mylab as label
end object
object myclick as label
left=200
caption="Click on this form please!""
end object
caption="subform"
onclick=subform_click
show
end object
show
end object
dim start as boolean
start=true
subform_click()
do
doevents
loop until mainform.visible=false
sub subform_click()
dim x as integer, y as integer
x=mainform.left
y=mainform.top
mylab.caption="Positions of mainform=("+str$(x)+"/"+str$(y)+")"+chr$(10)
x=subform.left
y=subform.top
mylab.caption=mylab.caption+"Positions of subform=("+str$(x)+"/"+str$(y)+")"
if start=false then
subform.left=x+1
subform.top=y+1
end if
start=false
end sub
-----------------
end code