Hi There!

Ich have a form, and if someone presses a button, a modal form is
display.
On the modal form, there is a textfield, which is filled with a string.
When the modal form is 
closed, the underlaying form is reactivated, but the content of the
textfield is still present, draw above the old form.
I added a FrmDrawForm(frmP) after FrmSetActive(previousForm) but not
only some artefacts remain.
Is this an OS-Bug, or have I made an mistake?

Here is my code:


---- Code wich shows the modal form an reactivates the previous on
list = GetObjectPtr(KategorieKategorieList);
LstSetListChoices(list, NULL, DmNumRecords(gKategorieDB));              
if (DmNumRecords(gKategorieDB) > 0)
{
        LstSetSelection(list,0);
        h = DmQueryRecord(gKategorieDB,0);
        k = MemHandleLock(h);
        SetFieldTextFromStr(KategorieNameField, k->Name);
        MemHandleUnlock(h);
        DmReleaseRecord(gKategorieDB,0,true);           
}       
                
LstSetDrawFunction(list, ListKategorieBearbeitenDrawFunc);
FrmSetEventHandler(frm, KategorieHandleEvent);
button = FrmDoDialog(frm);
FrmSetActiveForm(previousForm);



Here are the function which I use to fill the textfield (from Neil
Rhodes, Palm Programming)
static FieldPtr SetFieldTextFromHandle(Word fieldID, VoidHand txtH)
{
        VoidHand        oldTxtH;
        FormPtr frm = FrmGetActiveForm();
        FieldPtr        fldP;
        
        // get the field and the field's current text VoidHand.
        fldP = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID));
        ErrNonFatalDisplayIf(!fldP, "missing field");
        oldTxtH = (VoidHand) FldGetTextHandle(fldP);
        
        // set the field's text to the new text
        FldSetTextHandle(fldP, (Handle) txtH);
        FldDrawField(fldP);
        
        // free the VoidHand AFTER we call FldSetTextHandle.
        if (oldTxtH)
                MemHandleFree(oldTxtH);
        
        return fldP;
}

// Allocates new VoidHand and copies incoming string
static FieldPtr SetFieldTextFromStr(Word fieldID, CharPtr strP)
{
        VoidHand txtH;
        
        // get some space in which to stash the string
        txtH = MemHandleNew(StrLen(strP) + 1);
        if (!txtH)
                return NULL;
                
        // copy the string to the locked VoidHand.
        StrCopy(MemHandleLock(txtH), strP);
        
        // unlock the string VoidHand 
        MemHandleUnlock(txtH);
        
        // set the field to the VoidHand
        return SetFieldTextFromHandle(fieldID, txtH);
}


Does anyone have an advice? Or a hint to make it run correctly?


Thanks in advance,
bexxx

-- 
"Donuts - is there anything they can't do?"
                                            Homer J. Simpson

Reply via email to