SilverScreen Solid Modeler

QMessage Event

QMessage Event

Previous topic Next topic  

QMessage Event

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

The QMessage Event

 

Synopsis

The QMessage event is raised whenever SilverSharp wishes to display a quick-message, or qmessage (a status message in Windows application parlance). A qmessage is displayed in response to the SilverScreen API routine qmessage, and during most prompting.

 

 

Delegate

The QMessage delegate is declared as follows:

 

C# Code

 

 delegate void QMessageEventHandler(string message,

                                    SS_RGB fg,

                                    SS_RGB bg);

 

 string message; // A message string to write in the status area

SS_RGB fg;      // The message foreground color

SS_RGB bg;      // The message background color

 

 

A delegate is similar to a C/C++ function pointer, but delegates are type-safe and can only refer to a method that matches the signature of the delegate. The QMessage delegate declares a function signature that must be used when installing an event handler for the QMessage event.

 

 

Event

The QMessage event is declared within Events as follows:

 

C# Code

 

 static event QMessageEventHandler QMessage;

 

 

QMessage allows your application to subscribe to or unsubscribe from the QMessage event.

 

 

Raise method

The method to raise the QMessage event is declared within Events as follows:

 

C# Code

 

 static void RaiseQMessage(string text, SS_RGB fg, SS_RGB bg)

   

 string message; // A message string to write in the status area    

SS_RGB fg;      // The message foreground color

SS_RGB bg;      // The message background color

 

 

The SilverSharp assembly will automatically raise the QMessage event when a message is to be written into the status area. It would not be typical for a SilverSharp application to raise the event itself.

 

 

Remarks

It is not necessary for a SilverSharp application to establish a handler for the QMessage event, but you must do so if you wish to call SilverScreen API routines that write into the message area, or if you wish to use SilverScreen prompting and wish status messages to appear.

 

 

See Also

Events, set_qmessage_handler, qmessage

 

Example

The following code shows a sample QMessage event handler. The implementation of WriteToStatusArea  is not shown. Note that the method declaration must match the delegate for this event in parameters and return type:

 

C# Code

   

 using SilverSharp;

 

 . . .

 

 void OnQMessage(string message, SS_RGB fg, SS_RGB bg)

    {

    WriteToStatusArea(message, fg, bg)

    }

 

 

The following example shows how to subscribe to the QMessage event, assigning the above handler:

 

C# Code

   

 Events.QMessage += new QMessageEventHandler(this.OnQMessage);

 

 

The following example shows how to unsubscribe from the QMessage event, removing the above handler:

 

 

C# Code

   

 Events.QMessage -= new QMessageEventHandler(this.OnQMessage);