Tutorials to .com

Tutorials to .com » Os » Mobile » Palm OS and skills development of Frequently Asked Questions

Palm OS and skills development of Frequently Asked Questions

Print View , by: iSee ,Total views: 10 ,Word Count: 2090 ,Date: Mon, 8 Jun 2009 Time: 12:25 AM

1. To determine whether or not the current focus for the field

index = FrmGetFocus (form);

if (index = = noFocus)

return (false);

field = FrmGetObjectPtr (form, index);

2. FrmDoDialog () Usage:

FrmInitForm

FrmDrawForm

set form controls

FrmDoDialog

read form controls

FrmDeleteForm

Note: FrmDoDialog () unable to obtain frmOpenEvent.

3. Test controls Type:

switch (FrmGetObjectType(pForm, index)) {
case frmControlObj:

case frmFieldObj:

case frmScrollBarObj:

default:

}

4. In the program using the standard 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
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 use

If the GroupID for ordinary button with 0 as, if not GroupID with 0 to ensure that there is only one group is selected. FrmSetControlGroupSelection assignment to the push button.

6. PrefGetAppPreferences

PrefGetAppPreferences To determine whether to return to the results of noPreferenceFound

7. To the text box (Field) assignment

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);
}
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);
}
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);
}
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);
}
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. On CtlGetLabel ()

If you need CtlGetLabel (), while CtlSetLabel () should not be the immediate release of Char * parameters, or else CtlGetLabel () get the content will be chaos. "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. On HideState ()

HideState () return code is one of statXXX not sysXXX, Palm SDK reference is incorrect.

10. Is best not to use global variables, instead of using the Feature.

11. Simulator Screenshots of no shortcuts, instead of using the Alt + PrintScr.

12. Modal dialog to allow full-screen method

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();
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();
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();
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. On RepeatingButton

CtlRepeatEvent not RepeatingButton response CtlSelectEvent

14. Palm simulator and computer synchronization

Can refer to this URL: http://duchaoqian.blogbus.com/logs/538520.html, pay attention to the telephone number with "00"

15. Multi-line text box

Multi-line to change the contents of the text after FldRecalculateField (textField, false); otherwise may not be the correct line.

16. On the drop-down list

To produce popSelectEvent, so that in a certain ctlSelectEvent years handled = false

17. On the debug

I do not know the cause of death encountered such errors, the most effective solution is to exclude the law, and if (false ){...} continued to narrow the range until you find the code causing the error. Press the button, if the simulator is not a collapse but there was no response, the procedure is likely to be plunged into a death cycle.

18. JPilotDB use

JPilotDB provided lib file is too large, there are more than 4M (because that contains a lot of UI and related lib), if only to deal with java for. Pdb files do not need all its content, streamlined the size of 96K, click Download

Code Example: Create a. Pdb files

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();
}
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();
}

Code Examples: read a. Pdb files

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. With control from the currently running process

EvtEnqueueKey (vchrLaunch, 0, commandKeyMask);

20. Simulator using the arrow keys to five-dimensional (5-Way Navigator):

[Alt] + [Enter] = Select

[Alt] + [Left Arrow] = Left

[Alt] + [Right Arrow] = Right

[Alt] + [Up Arrow] = Up

[Alt] + [Down Arrow] = Down

21. On the Gadget. Help may be more examples in the old, callback (Callback) function's first parameter should be changed to FormGadgetType * type FormGadgetTypeInCallback * type. In addition, the third type of void * parameter can not be directly paramP-> eType, first to determine the type of conversion to use, for example, in formGadgetHandleEventCmd first EventType * pToEvent = (EventType *) paramP;, can be used before pToEvent-> eType to determine the types of events.

22. PODS use in Palm os Glue Library, in addition to. c files with the head "# include <PalmOSGlue.h>;" but also the linker settings to configure the project, or will be prompted to "Undefined reference". Hereconfiguration methods. The following excerpt: "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. To determine whether the object in the Form can be seen: The FrmGlueGetObjectUsable () method, pay attention to first base to load Glue.

24. According to the news group as well as their own tests of speech, FrmReturnToFrom (0) in the Debug ROM Lane are likely to be bug, will lead to memory problems due to the collapse of Simulator.

25. TypeID if the two databases and CreatorID are the same, Palm will be the same database as the two versions, so if their enumeration, DmGetNextDatabaseByTypeCreator () parameter of the fifth must be false (Some applications may not be precisely need to enumerate each version, and only need the latest version, you should use true).

26. Although the database is in memory, but the cost to open a database or can not be ignored, DmOpenDatabase () implementation of 50 of the time there were about 0.1 seconds.

27. Palm SDK drawcircle did not provide the function, can be rounded rectangle with a painting in lieu of, so that the radius of rounded rectangle side length equal to half of the can.


Mobile OS Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.