Sunday, January 28, 2007

Creating a dynamic form in Palm OS

Code below shows how to create a dynamic form for Palm OS 3.0 or greater. See this link of the entire project created using Palm OS Development Suite.

/****************************************************************************** * Application Name : DynamicUI.prc * Purpose : Demonstrate how to create a dynamic UI * Programmed by : Techno Scavenger *****************************************************************************/ #include <PalmOS.h> /*********************************************************************** * * Internal Constants * ***********************************************************************/ #define appFileCreator 'ewa8' #define appVersionNum 0x01 #define appPrefID 0x00 #define appPrefVersionNum 0x01 /*********************************************************************** * * Application constants * ***********************************************************************/ #define MainForm 1000 /*********************************************************************** * FUNCTION: MainFormHandleEvent * DESCRIPTION: This routine is the event handler for the * "MainForm" of this application. * PARAMETERS: pEvent - a pointer to an EventType structure * RETURNED: true if the event has handle and should not be passed * to a higher level handler. * REVISION HISTORY: ***********************************************************************/ static Boolean MainFormHandleEvent(EventType* pEvent) { Boolean handled = false; FormType* pForm; switch (pEvent->eType) { case frmOpenEvent: pForm = FrmGetActiveForm(); FrmDrawForm(pForm); handled = true; break; default: break; } return handled; } /*********************************************************************** * FUNCTION: AppHandleEvent * DESCRIPTION: This routine loads form resources and set the event * handler for the form loaded. * PARAMETERS: event - a pointer to an EventType structure * RETURNED: true if the event has handle and should not be passed * to a higher level handler. * REVISION HISTORY: ***********************************************************************/ static Boolean AppHandleEvent(EventType* pEvent) { UInt16 formId; FormType* pForm; Boolean handled = false; if (pEvent->eType == frmLoadEvent) { formId = pEvent->data.frmLoad.formID; // pForm = FrmInitForm(formId); pForm = FrmGetFormPtr(MainForm); FrmSetActiveForm(pForm); // Set the event handler for the form. The handler of the currently // active form is called by FrmHandleEvent each time is receives an // event. switch (formId) { case MainForm: FrmSetEventHandler(pForm, MainFormHandleEvent); break; default: break; } handled = true; } return handled; } /*********************************************************************** * FUNCTION: AppEventLoop * DESCRIPTION: This routine is the event loop for the application. * PARAMETERS: nothing * RETURNED: nothing * REVISION HISTORY: ***********************************************************************/ static void AppEventLoop(void) { Err error; EventType event; do { EvtGetEvent(&event, evtWaitForever); if (SysHandleEvent(&event)) continue; if (MenuHandleEvent(0, &event, &error)) continue; if (AppHandleEvent(&event)) continue; FrmDispatchEvent(&event); } while (event.eType != appStopEvent); } /*********************************************************************** * FUNCTION: AppStart * DESCRIPTION: Get the current application's preferences. * PARAMETERS: nothing * RETURNED: Err value errNone if nothing went wrong * REVISION HISTORY: ***********************************************************************/ static Err AppStart(void) { // FrmGotoForm(MainForm); static Char strTitle[13] = "Dynamic Form"; FormType* pMainForm; pMainForm = FrmNewForm( MainForm, strTitle, 0, 0, 160, 160, false, 0, 0, 0); FrmGotoForm(MainForm); return errNone; } /*********************************************************************** * FUNCTION: AppStop * DESCRIPTION: Save the current state of the application. * PARAMETERS: nothing * RETURNED: nothing * REVISION HISTORY: ***********************************************************************/ static void AppStop(void) { // Close all the open forms. FrmCloseAllForms(); } /*********************************************************************** * FUNCTION: PilotMain * DESCRIPTION: This is the main entry point for the application. * PARAMETERS: cmd - word value specifying the launch code. * cmdPB - pointer to a structure that is associated with the launch code. * launchFlags - word value providing extra information about the launch. * RETURNED: Result of launch * REVISION HISTORY: ***********************************************************************/ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { Err error = errNone; switch (cmd) { case sysAppLaunchCmdNormalLaunch: if ((error = AppStart()) == 0) { AppEventLoop(); AppStop(); } break; default: break; } return error; }

Sunday, January 21, 2007

Useful Internet Explorer 7 addons

Inline Search - an Internet Explorer add-on that mimics Firefox search behavior. It is a non-modal coupled with "find as you type" functionality.

Saturday, January 20, 2007

Use Palm OS Developement Suite documentation in latest version of Eclipse

Palm OS Developer Suite v 1.2 comes with Eclipse 3.0.x and CDT 2.0.2.ps002 which is quite outdated. Latest Eclipse version as of this writing was 3.2.1 with CDT at version 3.1.1. This latest CDT comes with lots of goodies like bracket matching and code folding which is absent in the CDT that comes with PODS. To use the documentation from PODS to the latest version of Eclipse copy the following directory including the files: com.palmsource.eclipse.sdk.palmos5.doc.user_1.2.0.23 com.palmsource.eclipse.tools.doc.user_1.2.0.23 Assuming default install these files should be located in C:\Program Files\PalmSource\Palm OS Developer Suite\eclipse\plugins. Copy this files into \plugins

Sunday, January 14, 2007

Open any document in IFix via shell

Below is a sample procedure to open a text in IFix.
Private Sub CommandButton1_Click()
    Dim ret As Long
    Dim hwnd As Long

    hwnd = FindWindow(vbNullString, Application.Caption)
    ret = shellExecute(hwnd, "Open", "c:\DVPendingFileRenameOp.log", vbNullString, vbNullString, 4)
End Sub
Note: Application is an IFix global variable.

Monday, January 08, 2007

Shell extension issue with Free Download Manager

I have found an issue with using Free Download Manager on Windows XP Pro Sp2. It used to work before then it suddenly causes Explorer to crash. Here are some data about the extension installed by Free Download Manager Extension name : FDMIECookiesBHO Class Type : FDMIECookiesBHO Class Filename : C:\Program Files\Free Download Manager\iefdmcks.dll I discovered that this is the extension that caused Explorer to crash using ShellExView. Note that I was a happy user of Free Download Manager for more than a year. This extension might have been affected by Windows Update. I was using Free Download Manager 1.8, this might be fixed with the newer version. Here some side effects of this extension: a) Clicking on a folder in the navigation view (treeview) that contains files in Explorer will crash the application. b) Windows Event Viewer logs something like this: Type: Information Source: Winlogon Category: None Event ID: 1002 Description: The Shell stopped unexpectedly and Explorer.exe was restarted.

VI common commands

Cursor movements in command mode: h=move the cursor to the left one character position l=move the cursor to the right one character position j=move the cursor down one line k=move the cursor up one line Changing mode: i=enter insert mode, the characters typed in will be inserted before the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times. a=enter insert mode, the characters typed in will be inserted after the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times. Text manipulation in command mode: x=delete character under the cursor. Count specifies how many characters to delete. The characters will be deleted after the cursor. u=undo the last change to the file. Typing u again will re-do the change. r=replace one character under the cursor. Specify count to replace a number of characters Cutting and Yanking:

The command commonly used command for cutting is d. This command deletes text from the file. The command is preceded by an optional count and followed by a movement specification. If you double the command by typing dd, it deletes the current line. Here are some combinations of these:

d^
deletes from current cursor position to the beginning of the line.
d$
deletes from current cursor position to the end of the line.
dw
deletes from current cursor position to the end of the word.
3dd
deletes three lines from current cursor position downwards.

There is also the y command which operates similarly to the d command which take text from the file without deleting the text.

Pasting:

The commands to paste are p and P. The only differ in the position relative to the cursor where they paste. p pastes the specified or general buffer after the cursor position, while P pastes the specified or general buffer before the cursor position. Specifying count before the paste command pastes text the specified number of times.

Windows Update fails

When performing Microsoft Windows Update fails (XP, not sure for other variants) try to add the following into trusted sites in Tools | Internet Options | Security Tab:
http://update.microsoft.com/

FreeBSD common commands

Install fluxbox
#: cd /usr/ports/x11-wm/fluxbox ; make install clean
Run fluxbox when executing startx
$: cd ~
$: touch .xinitrc
$: echo "exec fluxbox" > .xinitrc
Installing vmware-tools (FreeBSD 6.1, comes with XOrg 7.x)
#: mount /cdrom
#: cp /cdrom/vmware-freebsd-tools.tar.gz /tmp
#: cd /tmp
#: tar xvzf vmware-freebsd-tools.tar.gz
#: cd vmware-tools-distrib
#: ./vmware-install.pl ;defualts here should be fine
#: cd /usr/X11R6/lib/modules/drivers ;we need the following since vmware-install.pl does not install the mouse driver
#: cp /tmp/vmware-tools-distrib/lib/configurator/XOrg/6.8.x/vmmouse_drv.o
#: vi /etc/X11/xorg.conf
In vi, change the following lines:
Section "InputDevice"
 Identifier  "Mouse0"
 Driver      "vmmouse" #<<-- this line (changed from "mouse")
 Option     "Protocol" "ps/2"
 Option     "Device" "/dev/input/mouse0"
 Option     "ZAxisMapping" "4 5 6 7"
EndSection
//@end@\\

Friday, January 05, 2007

Common QNX commands

To open Phindows with specific screen resolution
c:\path_to_phindows>phindows.exe -t{IP_ADDRESS} -w800 -h600 ;opens a Phindows session on the specified ip using 800x600 res

Thursday, January 04, 2007

Compile farms and test machines

SourceForge.net provides a number of services to the developers of Open Source software development projects hosted on SourceForge.net. Part of this service offering is the SourceForge.net Compile Farm, which provides developers access to a pool of hosts that may be used for the compiling and testing of software. Each host within the Compile Farm is running a different Operating System (OS) on a different hardware platform. HP Testdrive - Want to try the latest technologies over the Internet? This program allows you to testdrive some of the hottest hardware and operating systems available today. Have you ever wanted to try out HP's exciting 64-bit Integrity and PA-RISC technology? Get time on SMP x86 and Opteron ProLiant servers? Try out a Blade server. Try different Open Source operating systems. Do it here! Just register for an account and fasten your seatbelt! Cray - Need to check if your application will work for the mainframes? What are you waiting for, dive in. Nomachine - Need to test remote access performance for NX server? Drop by here.

Wednesday, January 03, 2007

Common Solaris 10 commands

To change screen resolution
#: kdmconfig (note can only be used for XSun)
To reboot the machine
#: init 6
or
#: shutdown -i6 -g0 -y

Monday, January 01, 2007

Reading documents in Handspring Visor

There are quit a few choices when reading documents in Handspring Visor or Palm based PDA's. One is Adobe Acrobat Reader for Palm and Plucker. There might be more but these are the ones that I have used so far. The latest Adobe Reader for Palm OS works only for OS version 3.5 or greater. So for the Handspring Visor we are left with one application, Plucker. Latest version (1.8) does not seem to support Palm OS 3.0. When I was writing this blog it seems like the Plucker website was down. So I instead picked the older version from internet archive. I took v1.6 and low and behold it is working like a charm in Visor Deluxe. For readers convenience, you can download the file from here. Need to download and install 7-zip to extract the contents, though. Update (22Jan07) I found out that there are two binaries for v1.8 of the viewer application. One is for high resolution and non-hires. Non-high resolution works like a charm in Palm OS 3.0.x. Try this link.