Re: Message Box

From: <rtproffitt_at_my-deja.com>
Date: Fri, 16 Jul 1999 20:51:01 GMT
Message-ID: <7mo5vf$qo4$1_at_nnrp1.deja.com>


Shelli,
For the very reasons you give, I invented a "message box" methodology on my Forms 5 project. I will be happy to share it with you....

There are two ways:
1) you could create a whole module with canvas to be your message box... I did not do this.
2) You can use ALERTS, the closest thing available to VB MessageBox. This is what I adapted...

  1. In the main module (in a multi module app) I created at least three permanent ALERTS. INFO_ALERT, WARN_ALERT, FATAL_ALERT. I set the properties accordingly. These all were 1 Button ("ok") ALERTS. Later, when we needed YES/NO choices, I created another whole set of ALERTS, INFO_ALERT_2BTN... etc. The main reason for this is that all these properties are "covered up" at runtime and you may only access the Title and the Text of the ALERT...(In this sense, VB is far more flexible!).
  2. Once the ALERTS were defined, I created an object group for all of them and stored the whole mess in an OBJECT LIBRARY.
  3. Now we needed a procedure to drive the messaging, so I created library Procedure MESSAGEBOX (Stored in a Forms LIBRARY). MESSAGEBOX takes 3 parameters MessageBox('TYPE', 'Title', 'MessageText'); all varchar2. Type can be INFO, WARN, FATAL, and defaults to INFO if there is no match. Title and Text get set by Set_Alert_Property and then SHOW_ALERT is called.

3a) In the case of YES/NO buttons, it was necessary to return a value, so FUNCTION MESSAGEBOX_2BTN was created, which returns the value choosen, such as 'Y' or 'N'.

4) All modules in the application get the Library attached and all modules get the "subclass" copy of the Object Group from the Object Library...so every module may then utilize messagebox.

5) Usage.
Usage is
...[statements]....
MESSAGEBOX('warn','Error','There is an error in the blah blah...'); Usage for the 2 button is:
...[statements]...
IF MessageBox_2BTN('Info','Continue?','Do you wish to continue?')

  • 'OK' THEN ... statements.... END IF;
Here is the text of the MessageBox procedure: PROCEDURE MESSAGEBOX(AlertType in Varchar2,
                      AlertTitle in Varchar2,
                      AlertText  in Varchar2) IS
  x number;
  AlertId alert;
BEGIN
  If Upper(AlertType) = 'INFO' then
    AlertID := Find_Alert('InfoAlert');
  Elsif Upper(AlertType) = 'WARN' then
    AlertID := Find_Alert('WarnAlert');
  Elsif Upper(AlertType) = 'FATAL' then
    AlertID := Find_Alert('FatalAlert');   Else
  • couldn't find it AlertID := Find_Alert('InfoAlert'); End if;

  if AlertTitle is null then
    Set_Alert_property(AlertId, Title, 'Alert!');   else
    Set_Alert_property(AlertId, Title, AlertTitle);   end if;
  Set_Alert_property(AlertId, Alert_Message_Text, AlertText);   x:=show_alert(AlertID);
END;

  • The function (2 button version) adds the following code to RETURN VARCHAR2:
    • return the button number. IF x = ALERT_BUTTON1 THEN RETURN 'OK'; ElsIf x = ALERT_BUTTON2 THEN RETURN 'CANCEL'; Else RETURN 'CANCEL'; END IF;
Feel free to write if you have questions. My address is encoded, below.

Good Luck,
Robert Proffitt
Beckman Coulter
Brea California
RTProffitt AT beckman DOT com

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Jul 16 1999 - 22:51:01 CEST

Original text of this message