User Tools

Site Tools


codesamples:broadcast_message_winforms

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
codesamples:broadcast_message_winforms [2018/06/07 18:30] wolfgangriedmanncodesamples:broadcast_message_winforms [2018/09/11 04:12] (current) wolfgangriedmann
Line 6: Line 6:
 You can use "BroacastMessage" from EVERYWHERE in your code. There is even no need to identify a particular "Sender" (oSender: NULL_OBJECT) but every opened Form can receive the message by implementing a "BroadCastMessageReceive" method You can use "BroacastMessage" from EVERYWHERE in your code. There is even no need to identify a particular "Sender" (oSender: NULL_OBJECT) but every opened Form can receive the message by implementing a "BroadCastMessageReceive" method
  
-<code>PUBLIC FUNCTION BroadCastMessage(oSender AS Form, cMessage AS STRING, oExtra AS OBJECT) AS VOID PASCAL+<code visualfoxpro>PUBLIC FUNCTION BroadCastMessage(oSender AS Form, cMessage AS STRING, oExtra AS OBJECT) AS VOID PASCAL
   LOCAL aParameters AS OBJECT[]   LOCAL aParameters AS OBJECT[]
-  LOCAL oFormsList AS FormCollection    +  LOCAL oFormsList:= List<Form>{} AS List<Form>
   LOCAL oReturnValue AS OBJECT   LOCAL oReturnValue AS OBJECT
   aParameters:= <OBJECT>{oSender,cMessage,oExtra}   aParameters:= <OBJECT>{oSender,cMessage,oExtra}
-  oFormsList:Application.OpenForms+  //We "copy" the "current" Opened Forms list ...into a local variable (oFormList).    
 +  //Why? The FOREACH...NEXT doesn't accept that a change occurs in its list.  
 +  //Such a change can occur if one of the opened forms, during the loop,  opens a NEW Form in its "BroadCastMessageReceive"... 
 +  FOREACH oForm AS Form IN Application.OpenForms 
 +    oFormsList:Add(oForm) 
 +  NEXT                                                    
  
-  FOREACH oForm AS Form IN oFormsList +  FOREACH oForm AS Form IN oFormsList           
-    oReturnValue:=Send(oForm,"BroadCastMessageReceive",aParameters) +    IF !oForm:IsDisposed 
-    IF oReturnValue IS LOGIC  .and. ! (LOGIC)oReturnValue  +      oReturnValue:=Send(oForm,"BroadCastMessageReceive",aParameters) 
-      //If a particular Form:BroadcastMessageReceive method returns FALSE, +      IF oReturnValue IS LOGIC  .and. ! (LOGIC)oReturnValue   
-      //exit the loop   +        //If a particular Form:BroadcastMessageReceive method returns FALSE, 
-      EXIT+        //exit the loop   
 +        EXIT 
 +      ENDIF
     ENDIF     ENDIF
   NEXT   NEXT
Line 41: Line 48:
 **Implementation example.** **Implementation example.**
  
-<code>Class xyz inherit Form+<code visualfoxpro>Class xyz inherit Form
 Method xyz_FormClosed(sender AS OBJECT, e AS System.Windows.Forms.FormClosedEventArgs) AS VOID Method xyz_FormClosed(sender AS OBJECT, e AS System.Windows.Forms.FormClosedEventArgs) AS VOID
  
codesamples/broadcast_message_winforms.1528396245.txt.gz · Last modified: 2018/06/07 18:30 by wolfgangriedmann