1. 判断当前focus是否为field

index=FrmGetFocus(form);
if(index= =noFocus)
return(false);
field=FrmGetObjectPtr(form,index);

2. FrmDoDialog()使用方法:

FrmInitForm
FrmDrawForm
set form controls
FrmDoDialog
read form controls
FrmDeleteForm 

注意:FrmDoDialog()无法获得frmOpenEvent。

3. 测试控件类型:

switch (FrmGetObjectType(pForm, index)) { case frmControlObj: case frmFieldObj: case frmScrollBarObj: default:}

4. 在程序里使用标准的edit menu:

If your form has a menubar that consists of just the "Edit" menu, you can specify menu ID 10000 at form creation time. If your form has a menubar with several menus, you should specify your Edit menu like this, using PilRC notation:

PULLDOWN "Edit"
BEGINMENUITEM "Undo" ID 10000 "U"MENUITEM "Cut" ID 10001 "X"MENUITEM "Copy" ID 10002 "C"MENUITEM "Paste" ID 10003 "U"MENUITEM "Select All" ID 10004 "S"MENUITEM "-" ID 10005MENUITEM "Keyboard" ID 10006 "K"MENUITEM "Grafitti Help" ID 10007 "G"
END

If you're using Constructor, just create an Edit menu with ID 10000, and the IDs for the items will be provided for you. http://www.palmoswerks.com/2001/11/16

5. Push button的使用

GroupID若为0则与普通button一样,若GroupID不为0则同组内保证只有一个被选中。 FrmSetControlGroupSelection给push button赋值。

6. 关于PrefGetAppPreferences

PrefGetAppPreferences要判断返回结果是否为noPreferenceFound

7. 给文本框(Field)赋值

static void SetFieldText(FormType *form, FieldType *field, Char* value){MemHandle newTextH;MemHandle oldTextH;Char *text;newTextH = MemHandleNew(20);text = MemHandleLock(newTextH);StrCopy(text, value);MemHandleUnlock(newTextH);oldTextH = FldGetTextHandle(field);FldSetTextHandle(field, newTextH);if (oldTextH)  MemHandleFree(oldTextH);if(FrmVisible(form))FldDrawField(field);
}

8. 关于CtlGetLabel()

如果需要CtlGetLabel(),则在CtlSetLabel()时不应立即释放Char*参数,否则CtlGetLabel()得到的将是乱内容。 “This function stores the newLabel pointer in the control's data structure. It doesn't make a copy of the string that is passed in. Therefore, if you use CtlSetLabel, you must manage the string yourself. You must ensure that it persists for as long as it is being displayed (that is, for as long as the control is displayed or until you call CtlSetLabel with a new string), and you must free the string after it is no longer in use (typically after the form containing the control is freed). If you never use CtlSetLabel, you do not need to worry about freeing a control's label. ”

9. 关于HideState()

HideState()返回代码之一是statXXX而非sysXXX,Palm SDK参考有误。

10. 最好不要使用全局变量,用Feature代替之。

11. Simulator没有截屏的快捷键,用Alt+PrintScr代替之。

12. 让modal dialog全屏的方法

FormType* pOriForm = FrmGetActiveForm();
pForm = FrmInitForm(KeyboardForm);
FrmSetActiveForm(pForm);//Must
FrmSetEventHandler(pForm, KeyboardFormHandleEvent);formWinH = FrmGetWindowHandle(pForm);
WinSetConstraintsSize(formWinH, 160, 160, 160, 240, 240, 240);
FrmSetDIAPolicyAttr(pForm, frmDIAPolicyCustom);
PINSetInputTriggerState(pinInputTriggerDisabled);
PINSetInputAreaState(pinInputAreaClosed);
SysSetOrientation(sysOrientationLandscape);
StatHide();

13. 关于RepeatingButton

RepeatingButton响应CtlRepeatEvent而非CtlSelectEvent

14. Palm simulator与电脑同步

可参考这个网址:http://duchaoqian.blogbus.com/logs/538520.html,注意电话号码用"00"

15. 多行文本框

Multi-line的text改变内容后要FldRecalculateField(textField, false);否则换行可能不正确。

16. 关于下拉列表

要产生popSelectEvent,在ctlSelectEvent里一定让handled=false

17. 关于debug

遇到不知原因的死机等错误,最有效的解决办法是排除法,用if(false){...}不断缩小范围直到找到导致错误的代码。 按下按钮后,若模拟器不是崩溃而是没有反应,很可能是程序陷入了死循环。

18. JPilotDB的使用方法

JPilotDB提供的lib文件太大,有4M多(因为包含了很多UI和相关lib),如果只是用于在Java里处理.pdb文件完全不需要它的全部内容,精简后的大小为96K,点击下载

代码范例:创建一个.pdb文件

try {//Construct the databasePilotDBSchema schema = new PilotDBSchema();PilotDBDatabase database = new PilotDBDatabase("DB Name", "TypeID", "Creator", schema);for (int i = 0; i < 10; i++) {PilotDBRecord record = database.createRecord();record.setRecordData(new byte[]{});//set contents of the record
    }//Write to fileFileOutputStream fos = new FileOutputStream("c:/test.pdb");database.write(fos);fos.close();
} catch (IOException e) {e.printStackTrace();
} catch (PalmDbException e) {e.printStackTrace();
}

代码范例:读取一个.pdb文件

try {//Read database from fileFileInputStream fis = new FileInputStream("c:/test.pdb");PilotDBDatabase database = new PilotDBDatabase(fis);fis.close();//Read records of the databaseint recCount = database.getRecordCount();for (int i = 0; i < recCount; i++) {Record record = database.getRecord(i);byte[] bytes = record.getRecordData();//deal with the record
    }
} catch (IOException e) {e.printStackTrace();
} catch (PalmDbException e) {e.printStackTrace();
}

19. 用程序控制退出当前运行的程序

EvtEnqueueKey (vchrLaunch, 0, commandKeyMask);

20. Simulator里使用五维方向键(5-Way Navigator):

  • [Alt] + [Enter] = Select
  • [Alt] + [Left Arrow] = Left
  • [Alt] + [Right Arrow] = Right
  • [Alt] + [Up Arrow] = Up
  • [Alt] + [Down Arrow] = Down

21. 关于Gadget。帮助文档里的例子可能比较旧了,回调(Callback)函数里的第一个参数FormGadgetType*类型应改为FormGadgetTypeInCallback*类型。此外,第三个void*类型的参数不能直接paramP->eType,要先转换为确定类型才能使用,例如在formGadgetHandleEventCmd里要先EventType* pToEvent = (EventType*) paramP;,然后才可以用pToEvent->eType来判断事件类型。

22. 在PODS里使用Palm OS Glue Library,除了在.c文件头部加上“#include <PalmOSGlue.h>;”外,还要设置这个project的linker配置,否则会提示"Undefined reference"。配置的方法祥见这里。摘抄如下:“For managed make 68K projects, go to the project properties, and in the C/C++ Build panel, choose PRC-Tools Palm OS 68K Linker/General. Click the "New..." button in the Additional Libraries area, and enter this text into the dialog: -lPalmOSGlue; For a standard make 68K project based on the PalmSource template, in the file "makefile", modify the line for ADDITIONAL_LINK_LIBRARIES to read: ADDITIONAL_LINK_LIBRARIES = -lPalmOSGlue

23. 判断Form里的对象是否可见:用FrmGlueGetObjectUsable()方法,注意要先加载Glue库。

24. 根据新闻组里的言论以及自己的试验,FrmReturnToFrom(0)在Debug ROM里很可能有bug,会导致Simulator因内存问题崩溃。

25. 若两个数据库的TypeID和CreatorID都相同,Palm将视其为同一数据库的两个版本,因此若要枚举出它们,DmGetNextDatabaseByTypeCreator()的第五个参数必须为false(有些应用可能恰恰不需要枚举出每个版本,而只需要最新版本,则应使用true)。

26. 虽然数据库都是在内存里,但打开一个数据库的开销还是不能忽视,DmOpenDatabase()执行50次的时间大约有0.1秒。

27. Palm SDK没有提供画圆的函数,可以用画圆角矩形的方法代替,让圆角的半径等于矩形边长一半即可。

28. 关于使用表格控件的方法,这篇文章介绍的很详细,建议参考:http://www.mit.jyu.fi/~mweber/teaching/docs/palmos/book/ch08.htm

转载于:https://www.cnblogs.com/bjzhanghao/archive/2008/04/14/1152995.html

Palm OS开发常见问题和技巧相关推荐

  1. Palm OS开发简介

    Palm OS开发简介 --简单介绍Palm OS上的应用软件开发过程 篇首语:Palm OS现在的正确名字其实是Garnet OS...不过Palm OS更为人们所知... Palm OS历史 Pa ...

  2. Palm OS开发入门

    从某种意义上说,开发Palm OS系统平台的应用软件要比在其他平台上要容易.当然,其中的差别也是显而易见的.其中很重要的两点类似之处如下: 应用软件是事件驱动的 您能够使用任何来自标准C语言的东西来进 ...

  3. Palm OS开发工具简介【转载】

    一.CodeWarrior 在Mac OS和Win32平台上最流行的Palm OS系统集成开发环境.对PalmOS来说,它是一个主要开发工具,用C语言可以非常方便和快捷的写程序和调试程序.事实上,由P ...

  4. 从Palm OS向Series 60 Platform移植(转)

    移动开发伙伴们如要将其Palm OS应用移植到行业领先的Series 60 Platform上,现正当其时.当您考虑将现有Palm OS应用移植到Series 60 Platform时,可以先用下列三 ...

  5. [转载]Java嵌入式开发之一-简介使用Java编写Palm OS程序的解决方案

    Java嵌入式开发之一-简介使用Java编写Palm OS程序的解决方案 现在,使用Java语言为 Palm OS编写程序的领域还没有完全统一,并且也有许多程度上的差异,目前,市面上有好几种不同的可用 ...

  6. Palm OS 5开发概述

    内容 介绍 发布时间表 基于ARM处理器的Palm OS Palm应用程序兼容性环境 Palm OS仿真器 安全API 高密度API 性能 支持ARM原码 采样声音API Mac OS 管道开发工具( ...

  7. Windows Mobile 开发常见问题集(转自zsu_darkwind的专栏)

    Windows Mobile 开发常见问题集 1.Q:新建项目的时候选择哪个项目类型才能创建智能设备的应用程序? A:在Visual Studio的新建项目对话框中选择Visual C#或者Visua ...

  8. Palm应用开发之四Palm 应用模型

    本系列目录 Palm Web OS 简介 Palm 应用开发之一开发环境搭建 Palm 应用开发之二从Helloworld开始学习Palm开发 Palm应用开发之三appinfo.json文件详解 开 ...

  9. 求职应聘面试常见问题回答技巧

    求职应聘面试常见问题回答技巧 1.请你自我介绍一下你自己? 回答提示:一般人回答这个问题过于平常,只说姓名.年龄.爱好.工作经验,这些在简历上都有.其实,企业最希望知道的是求职者能否胜任工作,包括:最 ...

最新文章

  1. R语言使用ggplot2可视化凹凸图(bumps chart、凹凸图是一种特殊形式的线图,旨在探索随着时间的推移等级的变化)、并设置凹凸图的线条为曲线而不是直线(change into curves)
  2. 京东程序员回应“被猝死”:我还活着,还在写代码
  3. 【ES6专栏】全面解析ECMAScript 6模块系统
  4. linux inotifywait脚本,使用inotify/fswatch构建自动监控脚本
  5. DS实验题 Inversion
  6. 【超级鼠标键盘锁】之远线程注入winlogon.exe进程屏蔽Ctrl+Alt+Del、Win+L
  7. 文件服务器 远程访问,远程访问文件服务器
  8. 解决SQLite异常:library routine called out of sequence
  9. web.xml filter 不包含_Elasticsearch 之 Filter 与 Query 有啥不同?
  10. VBS 打开图片-幻灯片形式
  11. 关于AndroidStudio结合百度地图Api开发的SHA1获取
  12. VS2005 中文版下载
  13. ubuntu登录mysql报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mys
  14. Visual AssistX番茄助手的安装与基本使用
  15. 00后测试员摸爬滚打近一年,为是否要转行或去学软件测试的学弟们总结出了以下走心建议
  16. 《袁老师访谈录》第九期丨陈家强教授/香港科大商学院前院长【问诊未来·院长系列:科技铺就金融创新之路】...
  17. 司马南点火下的联想困局:始于业务,止于人事
  18. 信息安全:使用 Openssl 加密库进行编程
  19. Android网络防火墙实现初探
  20. pycharm的py文件抬头文件头模板

热门文章

  1. 客户端与服务器端交互原理
  2. 西门子828D 840Dsl数控程序PLC西门子数控程序中文注释
  3. Python调用pikepdf模块解密PDF文件(使用tkinter模块绘制GUI)
  4. 【Java】打包工具
  5. 【毕业设计】基于单片机的智能感应垃圾桶设计与实现 - 物联网 stm32 嵌入式
  6. 学习通项目需要用到的
  7. SharePoint2010安装文档
  8. 中级计算机职称哪个可以挂靠,2016年中级职称挂靠哪个证书更值钱?
  9. 码云新增 PR 显示权限助力计算机教学
  10. access2000 转换到SQL2000 方法