关于 modal dialogs(modal form) 的三种编程方法
原文:http://www.palmos.com/dev/support/docs/recipes/modal_dialogs.html 【相关文章:DudoJ框架——最初的设想】
translated and modified by carol 【扩展阅读:enoeht的Java源码系列(3)--】
由简至繁,依次为: 【扩展信息:enoeht的Java源码系列(4)--】
在 tompda 上有更多讨论: http://www.tompda.com/bbs/display.asp?luntan=2&forumid=1660213
1) 使用 frmdodialog, 不需要自己写事件处理程序(event handler) 这种方法最简单,但是灵活性比较差2) 使用 frmdodialog, 自己要写一部分的事件处理程序
3) 使用 frmpopupform, 自己写独立的事件处理程序,事件循环函数
根据 form/dialog 不同复杂度,选择不同的方式来处理,事半功倍
上述三种编程方法虽然不同,但是它们的资源文件是没有什么差别的,都是选用 modal form 来建造的
假设我们要做的是在 mainform 上按 "details", 驱动打开 detailsformoption 1: 不需要写事件驱动的 frmdodialog
在 mainformhandleevent 里面加上这一段:
if (eventp->data.ctlselect.controlid == maindetailsbutton) {
frmp = frminitform(detailsform);/* initialize your controls on the form here */
在这里加上form的控件初始化// open the dialog, and wait until a button is pressed to close it.
// 这一句 frmdodialog 打开了 detailsform,form 会在你按了上面的 button 以后退出来, // 返回的值 whichbutton 告诉你按的是哪个 button. whichbutton = frmdodialog(frmp);if (whichbutton == detailsokbutton) {
/* get data from controls on the form to save/apply changes */ ... 下一页