I grabbed this messagebox function from one of the reaction examples provided with the OS4 SDK. It works great, but only has one button. It looks like it should support multiple buttons and button texts, but I can;t figure out how I need to call it to do something like getting a requester that has both a "Delete" and "Cancel" button, returning a different value for each.
Here is the reaction code from the examples on the SDK:
uint32 MessageBoxA(char *gadgets, char *format, APTR args ) { Object *requester; char buffer[512]; uint32 result = 0; memset(buffer, 0, 512); IExec->RawDoFmt(format, args, NULL, buffer); requester = IIntuition->NewObject(IRequester->REQUESTER_GetClass(), NULL, REQ_Type, REQTYPE_INFO, REQ_TitleText, "Auto Sample", REQ_BodyText, buffer, REQ_GadgetText, gadgets, TAG_DONE); if (requester) { result = IIntuition->IDoMethod( requester, RM_OPENREQ, NULL, NULL, NULL ); IIntuition->DisposeObject(requester); } return result; } uint32 VARARGS68K MessageBox(char *gadgets, char *format, ...) { va_list ap; LONG result; va_startlinear (ap, format); result = MessageBoxA(gadgets, format, va_getlinearva(ap,void*) ); va_end(ap); return result; }
Is there an easy way to modify this to accept two buttons and their text, or does it need a rewrite? Also, is there a way to add an image to a button easily?
Thanks!
It already takes as many buttons as you like. Try "Ok|Retry|Cancel" as gadget text.
REQ_Image tag can be used to specify an image.
You should consider to read the autodocs. You could find out this and much more on your own.
@Thomas
Thanks. That is what I was looking for. Yes, I use SDKBrowser to look at autodocs but sometimes things are just buried - I'm sure if I would have looked up "requester" I would have found what I needed. Sorry for taking your time!
Thanks again,
Scott