MsgMulti ( Bicahi Esgici )

  • Archivo: TestMsM.Prg 

/*

  MINIGUI - Harbour Win32 GUI library Demo/Sample
 
  Copyright 2002-06 Roberto Lopez
 
 
  MsgMulty is Freevare HMG Message function.
  Accepts any type data values.
   
  Test program also demonstrate using of some
  handy HMG functions and how made tabulation
  in message boxs.
 
  Without changing and modifying any vay,
  using and distributing is totally free.

  All bug reports and suggestions are welcome.
   
  Developed under Harbour Compiler and
  MINIGUI - Harbour Win32 GUI library (HMG).
 
  Thanks to "Le Roy" Roberto Lopez.
 
  Copyright 2006 Bicahi Esgici
  History :
 
     7.2006 : First Release
*/

#include <minigui.ch>
#define c1Tab CHR(9)
#define NTrim( n ) LTRIM( STR( n, IF( n == INT( n ), 0, 2 ) ))

PROC Main()
   SET DATE GERM
   SET CENT ON
   DEFINE WINDOW frmMMTest  ;
      AT     0,0 ;
      WIDTH  GetDesktopWidth() * 0.5 ;
      HEIGHT GetDesktopHeight() * 0.5 ;
      TITLE  "Test for MsgMulty function" ;
      MAIN
      ON KEY ESCAPE ACTION frmMMTest.Release
      DEFINE MAIN MENU
         POPUP "&Test"
            ITEM "&Folders"   ACTION MsgMulty( { ;
                 "Current"       + c1Tab + ": " + GetCurrentFolder(),;
                 "Prg. Files"    + c1Tab + ": " + GetProgramFilesFolder(),;
                 "Desktop"       + c1Tab + ": " + GetDesktopFolder(),;
                 "Docs"          + c1Tab + ": " + GetMyDocumentsFolder(),;
                 "System"        + c1Tab + ": " + GetSystemFolder(),;
                 "Temp"          + c1Tab + ": " + GetTempFolder(),;
                 "Windows"       + c1Tab + ": " + GetWindowsFolder()},;
                 "Folders" )
                
            ITEM "&KeyBoard LEDs"  ACTION MsgMulty({;
                 "CapsLock"      + c1Tab + ": " + Any2Strg( IsCapsLockActive() ),;
                 "Insert"        + c1Tab + ": " + Any2Strg( IsInsertActive() ),;                              
                 "NumLock"       + c1Tab + ": " + Any2Strg( IsNumLockActive() ),;
                 "ScrollLock"    + c1Tab + ": " + Any2Strg( IsScrollLockActive() ) },;
                 "KeyBoard LEDs" )
                             
            ITEM "&Memory   Status"  ACTION MsgMulty( {;
                 "Total memory"     + c1Tab + ": " + NTrim( MemoryStatus( 1 )) + " MB" ,;
                 "Available memory" + c1Tab + ": " + NTrim( MemoryStatus( 2 )) + " MB" ,;
                 "Page memory-1"    + c1Tab + ": " + NTrim( MemoryStatus( 3 )) + " MB" ,;
                 "Page memory-2"    + c1Tab + ": " + NTrim( MemoryStatus( 4 )) + " MB" ,;
                 "Available VM"     + c1Tab + ": " + NTrim( MemoryStatus( 6 )) + " MB" },;
                 "Memory Infos")
                
            ITEM "&Desktop Size"  ACTION MsgMulty( {;    
                 "Width  : " + NTrim( GetDesktopWidth()),;
                 "Height : " + NTrim( GetDesktopHeight())},;
                 "Desktop Size" )
                
            ITEM "&Date of day"     ACTION MsgMulty( DATE(), "Date of day" )
                
            ITEM "&Random Number"   ACTION MsgMulty( Random(), "A Random Number" )
           
            POPUP "&Versions"
               ITEM "&Windows"   ACTION MsgMulty( WIndowsVersion(), "Windows Version" )
               ITEM "&Harbour"   ACTION MsgMulty( Version(), "Harbour Version" )
               ITEM "&MiniGUI"   ACTION MsgMulty( MiniGuiVersion(), "HMG Version" ) 
            END POPUP // Versions
           
            SEPARATOR                                                                                               
            ITEM "E&xit"      ACTION frmMMTest.Release
           
         END POPUP // Test 
        
         POPUP "&?"
            ITEM "&About"     ACTION MsgMulty( { ;
                 'MsgMulty is a HMG Message Function',;
                 '',;
                 'Developed under Harbour Compiler and',;
                 'MINIGUI - Harbour Win32 GUI library (HMG)',;
                 '',;  
                 'http://www.geocities.com/harbour_minigui',;
                 '',;  
                 'Thanks to "Le Roy" Roberto Lopez',;
                 '',;  
                 'Copyright 2006 Bicahi Esgici ',;
                 '' }, "What is MsgMulty ?" )
                                              
         END POPUP // ? 
        
      END MENU // MAIN
     
   END WINDOW  // frmMMTest

   CENTER   WINDOW frmMMTest
   ACTIVATE WINDOW frmMMTest
     

RETU // MsgMulty Test Main

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
/*
  
  p.MsgMulty()  : Display a message in any type data
 
  Syntax        : MsgMulty( <xMesaj> [, <cTitle> ] ) -> NIL
 
  Arguments     : <xMesaj> : Any type data value.
 
                             If <xMesaj> is an array, each element will display as
                             a seperated line.
                            
                  <cTitle> : Title of message box.
                             Default is calling module name and line number.
 
  Return        : NIL
 
  Uses          : Any2Strg()
 
  History       :
 
                  7.2006 : First Release 

*/
PROC MsgMulty( xMesaj, cTitle )

   LOCA cMessage := ""
   
   IF xMesaj # NIL
  
      IF cTitle == NIL
         cTitle := PROCNAME(1) + "\" +   NTrim( PROCLINE(1) )
      ENDIF
     
      IF VALTYPE( xMesaj  ) # "A"
         xMesaj := { xMesaj }
      ENDIF
     
      AEVAL( xMesaj, { | x1 | cMessage +=  Any2Strg( x1 ) + CRLF } )
     
      MsgInfo( cMessage, cTitle )
     
   ENDIF xMesaj # NIL
  
RETU //  MsgMulty()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

/*
    f.Any2Strg() : Covert any type data to string
   
    Syntax       : Any2Strg( <xAny> ) -> <cString>
   
    Argument     : <xAny> : A value in any data type
   
    Return       : <cString> : String equivalent of <xAny>
   
    History      :
   
                   7.2006 : First Release 
      
*/

FUNC Any2Strg( xAny )

   LOCA cRVal  := '???',;
        nType  :=  0,;
        aCases := { { "A", { | x | "{...}" } },;               
                    { "B", { | x | "{||}" } },;               
                    { "C", { | x | x }},;
                    { "M", { | x | x   } },;                  
                    { "D", { | x | DTOC( x ) } },;            
                    { "L", { | x | IF( x,"On","Off") } },;   
                    { "N", { | x | NTrim( x )  } },;
                    { "O", { | x | ":Object:" } },;
                    { "U", { | x | "<NIL>" } } }
                   
   IF (nType := ASCAN( aCases, { | a1 | VALTYPE( xAny ) == a1[ 1 ] } ) ) > 0
      cRVal := EVAL( aCases[ nType, 2 ], xAny )
   ENDIF   
                  
RETU cRVal // Any2Strg()
         
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._