Modifying Reaction MessageBox() function to handle two buttons and images?

3 posts / 0 new
Last post
AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 10 years 11 months ago
Joined: 2011-11-14 16:18
Modifying Reaction MessageBox() function to handle two buttons and images?

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:

  1. uint32 MessageBoxA(char *gadgets, char *format, APTR args )
  2. {
  3. Object *requester;
  4. char buffer[512];
  5. uint32 result = 0;
  6.  
  7. memset(buffer, 0, 512);
  8. IExec->RawDoFmt(format, args, NULL, buffer);
  9. requester = IIntuition->NewObject(IRequester->REQUESTER_GetClass(), NULL,
  10. REQ_Type, REQTYPE_INFO,
  11. REQ_TitleText, "Auto Sample",
  12. REQ_BodyText, buffer,
  13. REQ_GadgetText, gadgets,
  14. TAG_DONE);
  15. if (requester)
  16. {
  17. result = IIntuition->IDoMethod( requester, RM_OPENREQ, NULL, NULL, NULL );
  18. IIntuition->DisposeObject(requester);
  19. }
  20.  
  21. return result;
  22. }
  23.  
  24. uint32 VARARGS68K MessageBox(char *gadgets, char *format, ...)
  25. {
  26. va_list ap;
  27. LONG result;
  28.  
  29. va_startlinear (ap, format);
  30. result = MessageBoxA(gadgets, format, va_getlinearva(ap,void*) );
  31. va_end(ap);
  32. return result;
  33. }

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!

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
It already takes as many

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.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 10 years 11 months ago
Joined: 2011-11-14 16:18
@Thomas Thanks. That is

@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

Log in or register to post comments