MUIM_Setup & MUIM_Cleanup ========================= Since your object doesn't know anything about display environment after it is created with OM_NEW, MUI will send you an MUIM_Setup when it is about to open a window containing your object. The first thing you have to do is to pass MUIM_Setup to your super class an return FALSE on failure. After this, you can calculate some internal data or allocate some display buffers. Return TRUE if everything went ok or FALSE when you discovered any errors. In this case, MUI will send a MUIM_Cleanup to all objects that already received a MUIM_Setup (excluding the current one!) and fail to open the window. Typical setup/cleanup pairs could look like this: static ULONG mSetup(struct IClass *cl,Object *obj,Msg msg) { struct Data *data = INST_DATA(cl,obj); if (!(DoSuperMethodA(cl,obj,msg))) return(FALSE); data->lineheight = _font(obj)->tf_YSize; if (!(data->linebuf = AllocVec(data->count*data->lineheight))) return(FALSE); MUI_RequestIDCMP(obj,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_INACTIVEWINDOW); return(TRUE); } static ULONG mCleanup(struct IClass *cl,Object *obj,Msg msg) { struct Data *data = INST_DATA(cl,obj); FreeVec(data->linebuf); MUI_RejectIDCMP(obj,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_INACTIVEWINDOW); return(DoSuperMethodA(cl,obj)); }


converted with guide2html by Kochtopf for the Meeting Pearls Vol.1