Tim-

The frmOpenEvent inside HardwareFormHandleEvent is to open a specific form (in 
this case 1700).  This form is the active form when called from the previous 
form so open event works correctly.  The problem is that when you call 
frmGotoForm, it changes the active form to the next in line (say 1800 for 
example).  So when you call frmOpenEvent again, the line of code executing 
FrmDrawForm(pForm) will draw the next form (1800) instead of 1700, but it also 
executes any command inside the case frmOpenEvent:.  When you execute 
FrmGotoForm, is there a way to ONLY close the current form without executing 
frmOepenEvent in the same event handler?

Maybe it would be simpler to pose this question:

If I want to perform some action ONLY 1 time on 1 form, where would I put the 
function call?  In my if(Refresh2 == true) loop, in frmOpenEvent, or ?????


thanks,

~Tony


>>> [EMAIL PROTECTED] 4/14/2005 11:33 AM >>>
You define pForm as the active form.  Is it possible that the frmOpenEvent 
is meant for a non-active form?  The form ID is within the event structure, 
if you want to check.

Tim

"Tony Janke" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
Does anyone know why frmOpenEvent is executed twice per form?  Once when 
opened and again when closing.  Maybe I shouldn't ask why, I do know that 
FrmGotoForm generates a frmOpenEvent and frmLoadEvent.  My application, upon 
opening a form, initializes fields within the form by retrieving data from 
the bluetooth virtual serial port.  The problem I am having is that this 
data is requested twice when it only needs to be once.  Is there some other 
place I can put this function so that the ONLY time the data is retrieved is 
when the form is open?

I have a temporary workaround by doing the following (where Refresh2 is a 
global variable that is set to TRUE in the previous form):


static Boolean HardwareFormHandleEvent(EventType* pEvent)
{
Boolean handled = false;
FormType* pForm = FrmGetActiveForm();
FieldType* FieldPtr;
UInt32 numBytes = 0;
Err err;

if(Refresh2 == true)
{
WriteTextToField(GetDeviceName(), 1007); // Executed only ONCE if called 
from here
Refresh2 = false;
}

switch (pEvent->eType) {
case ctlSelectEvent:
switch (pEvent->data.ctlSelect.controlID)
{
case 1005: // Edit Device Name
FrmPopupForm(1702);
Refresh = true;
handled = true;
break;

case 1006: // Edit Pin #
Refresh = true;
FrmPopupForm(1703);
handled = true;
break;

case 1004:  // Upgrade Device
Refresh = true;
FrmPopupForm(1701);
handled = true;
break;

case 1014:  // Done
FrmGotoForm(ModeForm);
handled = true;
break;

default:
break;
}

case frmOpenEvent:
FrmDrawForm(pForm);
handled = true;
break;

default:
break;
}
return handled;
}



I realize there has to be a better solution than this.

thanks,

~Tony




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


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

Reply via email to