Since I found this to be a pain in the neck, I'd at least like to let other
know how it was done.  The code sometimes referes to the "Applications and
Dynamic Input Areas" documentation as the "DIA doc".  This documentation is
provided with the Palm OS 5 SDK.

Implement the following code in your AppHandleEvent function.

static Boolean AppHandleEvent(EventType * eventP)
{
    UInt16 formId;
    FormType * frmP;
    WinHandle formWinH;
    Err err;
    RectangleType curBounds, displayBounds;

    if (eventP->eType == frmLoadEvent)
    {
        // Load the form resource.
        formId = eventP->data.frmLoad.formID;
        frmP = FrmInitForm(formId);
        FrmSetActiveForm(frmP);
        formWinH = FrmGetWindowHandle(frmP);

        //  Set the Dynamic Input Area policy attribute, trigger state and
default size contraints
        if (HasDynamicInputArea) {  // Global initialized in the AppStart
function per the instructions in DIA doc
            FrmSetDIAPolicyAttr(frmP, frmDIAPolicyCustom);
            PINSetInputTriggerState(pinInputTriggerEnabled);
            PINSetInputAreaState(pinInputAreaUser);
            WinSetConstraintsSize(formWinH, 160, 320, 320, 160, 160, 320);
        }

        // Get the form size
        WinGetBounds(formWinH, &curBounds);
        // Get screen size
        WinGetBounds(WinGetDisplayWindow(), &displayBounds);

        // Is the form size appropriate for the current screen size?  If so,
we don't need to do anything.
        if (displayBounds.extent.x != curBounds.extent.x ||
displayBounds.extent.y != curBounds.extent.y) {
            WinSetBounds(formWinH, &displayBounds);
        }

        // 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 LoginForm:
            FrmSetEventHandler(frmP, LoginFormHandleEvent);
            break;
etc

In your Form event handlers implement the following:

FormType * frmP = FrmGetActiveForm();
WinHandle formWinH = FrmGetWindowHandle(frmP);
RectangleType curBounds, displayBounds;

// get the current bounds for the form
WinGetBounds (FrmGetWindowHandle(frmP), &curBounds);
// get the new display window bounds
WinGetBounds(WinGetDisplayWindow(), &displayBounds);

switch (eventP->eType)
    case winEnterEvent:
        // This event occurs before FrmOpenEvent.  It ensures your form is
properly resized on entry to the form
        if (HasDynamicInputArea) {
            // Rearrange the controls on the form
            MyFormResizeForm(frmP, &curBounds, &displayBounds);
        }
        handled = true;
        break;

    // Dynamic Input Area was opened or closed. Ensures the form is resized.
    case winDisplayChangedEvent:
        // the following WinSetBounds call ensures that the form is resized
to the display size
        WinSetBounds(formWinH, &displayBounds);
        // Rearrange the controls on the form
        MyFormResizeForm(frmP, &curBounds, &displayBounds);
        .... other code to reinitialize UI components
        FrmDrawForm(frmP);
        handled = true;
        break;

Hope this helps anyone else trying to do the same thing.  If anyone knows of
anthing I've missed or messed up, please let me know.

Phil



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to