Palm OS開発の一般的な問題とテクニック

13950 ワード

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"

BEGIN

    MENUITEM "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 10005

    MENUITEM "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でなければ同グループ内で1つだけが選択されることを保証する.FrmSetControlGroupSelectionはpush buttonに値を割り当てます.
6.PrefGetAppPreferencesについて
PrefGetAppPreferences戻る結果がnoPreferenceFoundであるかどうかを判断する
7.テキストボックスに値を割り当てる
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()戻りコードの1つはsysXXXではなくstatXXXであり、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は、CtlSelectEventではなくCtlRepeatEventに応答する
14.Palm simulatorとコンピュータの同期
このサイトを参照してください.http://duchaoqian.blogbus.com/logs/538520.htmlあ、注意電話番号は「00」
15.複数行テキストボックス
Multi-lineのtextは内容を変更した後、FldRecolculateField(textField,false);改行が正しくない可能性があります.
16.ドロップダウンリストについて
popSelectEventを生成するには、ctlSelectEventで必ずhandled=false
17.debugについて
原因不明のハングアップなどのエラーに遭遇した場合、最も効果的な解決策は排除法でif(false){...}エラーの原因となるコードが見つかるまで範囲を縮小します.ボタンを押すと、シミュレータがクラッシュではなく反応しなければ、プログラムがデッドサイクルに陥った可能性が高い.
18.JPilotDBの使い方
JPilotDBが提供するlibファイルは大きすぎて、4 M余り(UIと関連libがたくさん含まれているため)があり、Javaで処理するだけであれば.pdbファイルはそのすべての内容を全く必要とせず、簡素化されたサイズは96 K、ダウンロード
コード例:作成.pdbファイル
try {

  //Construct the database

    PilotDBSchema 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 file

    FileOutputStream fos = new FileOutputStream("c:/test.pdb");

    database.write(fos);

    fos.close();

} catch (IOException e) {

    e.printStackTrace();

} catch (PalmDbException e) {

    e.printStackTrace();

}

コード例:1つを読み込む.pdbファイル
try {

    //Read database from file

    FileInputStream fis = new FileInputStream("c:/test.pdb");

    PilotDBDatabase database = new PilotDBDatabase(fis);

    fis.close();

    //Read records of the database

    int 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次元方向キー(5-Way Navigator):
  • [Alt] + [Enter] = Select
  • [Alt] + [Left Arrow] = Left
  • [Alt] + [Right Arrow] = Right
  • [Alt] + [Up Arrow] = Up
  • [Alt] + [Down Arrow] = Down

  • 21.Gadgetについて.ヘルプドキュメントの例は古いかもしれませんが、コールバック関数の最初のパラメータFormGadgettType*タイプはFormGadgettType InCallback*タイプに変更する必要があります.また、3番目のvoid*タイプのパラメータは、直接paramP->eTypeにすることはできません.例えば、f o m m m o m a d g g e t HandleEventCmdではEventType*pToEvent=(EventType*)paramPに変換します.その後、pToEvent->eTypeでイベントタイプを判断できます.
    22.PODSでPalm OS Glue Libraryを使用し、cファイルヘッダに「#include」;また、このプロジェクトのlinker構成も設定します.そうしないと、「Undefind reference」というメッセージが表示されます.配置の方法は祥見ここ.「For managed make 68 K projects,go to the project properties,and in the C/C++Build panel,choose PRC-Tools Palm OS 68 K 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にバグがあり、Simulatorがメモリの問題でクラッシュする可能性が高い.
    25.両方のデータベースのType IDとCreatorIDが同じ場合、Palmは同じデータベースの2つのバージョンとみなされます.したがって、それらを挙げるには、DmGetNextDatabaseByType Creator()の5番目のパラメータがfalseである必要があります(各バージョンを挙げる必要がなく、最新バージョンのみが必要なアプリケーションもありますが、trueを使用します).
    26.データベースはすべてメモリにあるが、1つのデータベースを開くコストは無視できない.DmOpenDatabase()が50回実行する時間は約0.1秒である.
    27.Palm SDKは円を描く関数を提供していないので、円の半径が矩形の辺の長さの半分に等しいように円を描く方法で代用することができます.
    28.テーブルコントロールの使用方法については、この記事で詳しく説明します.推奨リファレンス:http://www.mit.jyu.fi/~mweber/teaching/docs/palmos/book/ch08.htm