form in form left, top positions

In this category you can exchange your programming questions and solutions.
Post Reply
PaPi
Posts: 114
Joined: Wed May 16, 2007 11:55 am

form in form left, top positions

Post: # 609Post PaPi
Wed Feb 17, 2010 8:10 am

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

magna
Posts: 30
Joined: Tue Nov 08, 2005 3:00 pm

form in form left, top positions

Post: # 610Post magna
Wed Feb 17, 2010 10:27 pm

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.

PaPi
Posts: 114
Joined: Wed May 16, 2007 11:55 am

form in form left, top positions

Post: # 611Post PaPi
Thu Feb 18, 2010 7:41 am

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)

PaPi
Posts: 114
Joined: Wed May 16, 2007 11:55 am

form in form left, top positions

Post: # 612Post PaPi
Fri Feb 19, 2010 8:30 am

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

Post Reply