How to create and display a message in reaction?

10 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2012-02-18 19:55
How to create and display a message in reaction?

As in the subject, how to create and display a message in reaction?

Is there something like MessageBox("Title Box, please choose yes or no", yesno);

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
From UQM port

From UQM port (src/libs/port/msgbox_amigaos4.c):

  1. void log_displayBox (const char *title, int isError, const char *msg)
  2. {
  3. struct ClassLibrary *RequesterBase;
  4. Class *RequesterClass;
  5. RequesterBase = IIntuition->OpenClass("requester.class", 53, &RequesterClass);
  6. if (RequesterBase != NULL) {
  7. Object *requester;
  8. requester = IIntuition->NewObject(RequesterClass, NULL,
  9. REQ_TitleText, title,
  10. REQ_BodyText, msg,
  11. REQ_GadgetText, "_Ok",
  12. REQ_Image, isError ? REQIMAGE_ERROR : REQIMAGE_INFO,
  13. TAG_END);
  14. if (requester != NULL) {
  15. IIntuition->IDoMethod(requester, RM_OPENREQ, NULL, NULL, NULL);
  16. IIntuition->DisposeObject(requester);
  17. }
  18. IIntuition->CloseClass(RequesterBase);
  19. }
  20. }

For more information see "SDK:Documentation/AutoDocs/requester_cl.doc".

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2012-02-18 19:55
Thank you for the info. I

Thank you for the info.
I tought that requester class was used for system request dialog only, such Open/Close/Save file and for displaying alerts.

What's UQM, btw?

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
What's UQM,

What's UQM, btw?

http://sc2.sf.net/

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2012-02-18 19:55
The message box sample works.

The message box sample works. The only problem is that the message box is dyplayed behind the custom scrreen i've opened. How to display on top of my screen?

Thank you

trixie
trixie's picture
Offline
Last seen: 5 months 12 hours ago
Joined: 2011-02-03 13:58
@AmigaBlitter You need to

@AmigaBlitter

You need to change the messagebox function to take a screen pointer as parameter, and then use the pointer in the opening method call:

  1. void log_displayBox (const char *title, int isError, const char *msg, struct Screen *scr)
  2. {
  3.  
  4. ...
  5.  
  6. IIntuition->IDoMethod(requester, RM_OPENREQ, NULL, scr, NULL);
  7.  
  8. ...
  9.  
  10. }

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
@trixie The screen parameter

@trixie

The screen parameter is the last one so it should be:
IIntuition->IDoMethod(requester, RM_OPENREQ, NULL, NULL, scr);

@AmigaBlitter

Format of RM_OPENREQ message is (from classes/requester.h):

  1. struct orRequest
  2. {
  3. ULONG MethodID; /* RM_OPENREQ */
  4. struct TagItem *or_Attrs; /* List of tag attributes */
  5. struct Window *or_Window; /* Reference window for requester. */
  6. struct Screen *or_Screen; /* Reference screen for requester.
  7.   * REQUIRED if or_Window is
  8.   * not supplied
  9.   */
  10. };

To specify which screen the requester should open on you can either specify an intuition window pointer (opens on the same screen as the window) or a screen pointer directly. If both of these are NULL then the default public screen will be used (usually the WB screen).

trixie
trixie's picture
Offline
Last seen: 5 months 12 hours ago
Joined: 2011-02-03 13:58
@salass You're right. I got

@salass

You're right. I got fooled by the requester class autodoc, which says

reqmsg.MethodID = RM_OPENREQ;
reqmsg.or_Window = NULL;
reqmsg.or_Screen = myScreenPtr;
reqmsg.or_Attrs = tags;

so I assumed this is the same order of parameters as in the OPENREQ message. Perhaps it should be changed in the autodoc to avoid confusion?

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2012-02-18 19:55
@sallass00 & Trixie Thank

@sallass00 & Trixie

Thank you. It works now!

@trixie

Perhaps it should be changed in the autodoc to avoid confusion?

Yeah! Get a newbie like me: Autodocs say §":}{¶, wiki say :{}{":", newmethods, old methods :**éç macros: °PO°POoèpèo.....

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Perhaps it should be changed


Perhaps it should be changed in the autodoc to avoid confusion?

Done.

Log in or register to post comments