In new:
 
There is no sense calling CoerceMethod(cl, obj, OM_DISPOSE); when obj == NULL becase object is already completely disposed.. You should use CoerceMethodA() there, if your custom initialization failed AFTER calling DoSuperNewA() but when it SUCCEEDED (when obj != NULL)..
 
In dispose & cleanup:

  /* */
  return(DoSuperMethodA(cl, obj));
 
*WRONG* You should pass msg too! i.e. return(DoSuperMethodA(cl, obj,msg));
 
And thing which is very often ignored by MUI programming people (the most of people writing here their example codes and other places on the net), but doesn't cause crashes or other bad things, you don't check whether MUI window was really opened after using set( win, MUIA_Window_Open, TRUE ); it should be:
 
set( win, MUIA_Window_Open, TRUE );
if( xget( win, MUIA_Window_Open ) )
{
    [ ... ]
}
 
otherwise if window can't be opened for various of reasons application will not quit nicely!

          /* set some text */
          data = "" win);
          if(data)
           {
            data->buffer = AllocVec(255, MEMF_ANY|MEMF_CLEAR);
            if(data->buffer) sprintf(data->buffer, "Simple MUI Custom Class Test");
           }
instance data is always available if 2nd argument is not NULL, because it's simple adding value to value.. No need to checking whether it's not NULL here.. :)
 
Best Regards!
 
----- Original Message -----
Sent: Thursday, September 09, 2004 4:36 PM
Subject: [MUI] Correct Custom Class Usage

Hi all,
 
I'm currently trying to fathom out MUI Custom Classes, and I thought I had, until my applicaion started crashing once I used INST_DATA() I would get random crashes.
 
So, I wrote a small test application and it seems to work without crashing so I must be doing something wrong in my main application with regards to INST_DATA(). I've attached my test application and I would really appreciate it if someone could run through my code and see that I'm declaring and calling everything correctly.
 
Also, can the INST_DATA() data structure consist of any variable type? e.g. other structs, pointers, ULONG's etc.
 
Thanks for any advice,
Daniel


Visit http://www.amiga.dk/tumult for MUI-related
information, especially about MUI custom classes.





Visit http://www.amiga.dk/tumult for MUI-related
information, especially about MUI custom classes.



Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to