Below used to work. Now it doesn't, in the sense that while the form
loads. The menu function don't change the record or add or save.
In fact, no data shows in the forms at all.
JDK
function main()
wxwindow w
dataform1 f
wxmenubar mb
integer e, width, height, dispwidth, dispheight
string filename, cd, result, errtext
e = 0
cd = getcurrentdirectory()
filename = ""
result = ""
wxfiledialog(.nul, "Pick a form to show", cd, "",
"*.sxf",
"open,mustexist", filename, result)
if result == "ok"
errtext = ""
f =@ opendataform1(filename, error=e, errortext=errtext)
if f !@= .nul
width = 1
height = 1
dispwidth = 1
dispheight = 1
getusabledisplaysize(dispwidth, dispheight)
width = f.currentpage.width
height = f.currentpage.height
w =@ wxwindow.new(1, 1, innerwidth=width, innerheight=height,
captiontext=filename)
if w !@= .nul
mb =@ makemenu(f)
if mb !@= .nul
mb.setwindow(w)
w.onvisibilitychange.function =@ quit
f.setcontainer(w)
f.selectfirst()
wxprocess(.inf)
end if
end if
end if
end if
end function
function quit(wxwindow me)
wxbreak()
end function
function selfirst(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
f.selectfirst(error=e)
end function
function selprev(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
f.selectprevious(error=e)
end function
function selnext(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
f.selectnext(error=e)
end function
function sellast(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
f.selectlast(error=e)
end function
function addrecord(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
f.newrecord(error=e)
end function
function saveform(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
end function
function menu2_1(wxmenuitem me, dataform1 f)
integer e
e = 0
f.saverecord(error=e)
// what shall this do? Figure it out and put it here.
end function
function makemenu(dataform1 f)
wxmenubar mb
mb =@ wxmenubar.new()
wxmenu filemenu, menu2
filemenu =@ wxmenu.new()
menu2 =@ wxmenu.new()
filemenu.insert("","Select &First",
name="selfirst")
filemenu!selfirst.onselect.function =@ selfirst
filemenu!selfirst.onselect.reference =@ f
filemenu.insert("","Select &Previous",
name="selprev")
filemenu!selprev.onselect.function =@ selprev
filemenu!selprev.onselect.reference =@ f
filemenu.insert("","Select &Next",
name="selnext")
filemenu!selnext.onselect.function =@ selnext
filemenu!selnext.onselect.reference =@ f
filemenu.insert("","Select &Last",
name="sellast")
filemenu!sellast.onselect.function =@ sellast
filemenu!sellast.onselect.reference =@ f
filemenu.insert("separator")
filemenu.insert("","Save", name="saveform")
filemenu!saveform.onselect.function =@ saveform
filemenu!saveform.onselect.reference =@ f
filemenu.insert("","Add", name="addrecord")
filemenu!addrecord.onselect.function =@ addrecord
filemenu!addrecord.onselect.reference =@ f
menu2.insert("","Menu2_1", name="menu2_1")
menu2!menu2_1.onselect.function =@ menu2_1
menu2!menu2_1.onselect.reference =@ f
mb.insert(filemenu, "&File", name="file")
mb.insert(menu2,"Menu2", name="menu2")
|
Kromkowski wrote:
> Below used to work. Now it doesn't, in the sense that while the form
> loads. The menu function don't change the record or add or save.
> In fact, no data shows in the forms at all.
I found this to be true as well. It turns out to be a lot sillier than
you might think. I would bet, that the form you opened was not in the
starting directory when you tried it, but in the past it was. The
problem is that formlib.sml has not yet been taught to deal with this
situation. That has changed. I just revised the code, so that it can
cope with this scenario, and in future, if it gets an error, it will
report it to you and tell you why it is unhappy. It will do this via a
wxmessagedialog() though, since it would be fairly complicated to pass
this level of information all the way back up to you (that may
eventually change). I will be updating the dataform1 object in the near
future to add a boolean property called "valid", which will be set to
.true if the form opens completely successfully, otherwise it will be
set to .false. The advantage to the way this works at the moment, is
that you can open a form even if the datasources cannot be found, one of
the things that won't work in Superbase.
|