Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Message Box Macro Examples

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Box Macro Examples

    Comments here:
    User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.



    '
    Code:
    'Message Box Macros - Gösta H.Lovgren 
    'http://www.swedesdock.com/powerbasic/pb_shortcuts.html
    #Compile Exe  
    #Include "WIN32API.INC"
     
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''   
    '""""""""""" MsgBox Macros """"""""""""""""""""""""""""""""
    Macro mb_Locals 'to use in Subs, Functions without Common_Locals
      Local m$, m0$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
      Local ans&, MB_Style&, m_len&
    End Macro
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Macro mb_Msgbox   
      If m0$ = "" Then m0$ = FuncName$ 'header
      m_len = Len(m0$) + 35
     
      If m_len > Len(m$) Then m$ = m$ & Space$(m_len - Len(m$)) 
      If m_len > Len(m1$) Then m1$ = m1$ & Space$(m_len - Len(m1$)) 
      If m_len > Len(m2$) Then m2$ = m2$ & Space$(m_len - Len(m2$)) 
      If m_len > Len(m3$) Then m3$ = m3$ & Space$(m_len - Len(m3$)) 
      If m_len > Len(m4$) Then m4$ = m4$ & Space$(m_len - Len(m4$)) 
      If m_len > Len(m5$) Then m5$ = m5$ & Space$(m_len - Len(m5$)) 
      If m_len > Len(m6$) Then m6$ = m6$ & Space$(m_len - Len(m6$)) 
      If m_len > Len(m7$) Then m7$ = m7$ & Space$(m_len - Len(m7$)) 
      If m_len > Len(m8$) Then m8$ = m8$ & Space$(m_len - Len(m8$)) 
      If m_len > Len(m9$) Then m9$ = m9$ & Space$(m_len - Len(m9$)) 
      If m_len > Len(m10$) Then m10$ = m10$ & Space$(m_len - Len(m10$)) 
     
     
      MsgBox m$ & $CrLf & _
             m1$ & $CrLf & _
             m2$ & $CrLf & _
             m3$ & $CrLf & _
             m4$ & $CrLf & _
             m5$ & $CrLf & _
             m6$ & $CrLf & _
             m7$ & $CrLf & _
             m8$ & $CrLf & _
             m9$ & $CrLf & _
             m10$, _
           %MB_OK Or %MB_SYSTEMMODAL Or mb_Style, _
            m0$ 
      Reset m$, m0$,m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
    End Macro      
    '
    Macro mb = mb_Msgbox
    '
    Macro m_Err_Msg 
     If Err Then 
        m0$ = Using$("ERROR ### ", Err) 
        m2$ = "   In " & FuncName$    
        m5$ = Error$(Err)
        mb_Style = %MB_ICONERROR 
        mb  
     End If                
     ErrClear
    End Macro 
    '                
    Macro mb_Question =  mb_Style = %MB_ICONQUESTION: Mb_MsgBox                   
    '
    Macro mb_Stop = mb_Style = %MB_ICONERROR: mb_Msgbox
    '
    Macro mb_Alert = mb_Style = %MB_ICONWARNING: mb_Msgbox
    '
    Macro mb_ans 
    ' m$ = "Do you REALLY want to erase everything?"
    ' m1$ = 
    ' mb_ans
    '  If ans = %IdYes Then             
    '     '
    '  End If
        If m0$ = "" Then m0$ = FuncName$ 'header
        m$ = m$ & $CrLf & _ 
             m1$ & $CrLf & _
             m2$ & $CrLf & _
             m3$ & $CrLf & _
             m4$ & $CrLf & _
             m5$ & $CrLf & _
             m6$ & $CrLf & _
             m7$ & $CrLf & _
             m8$ & $CrLf & _
             m9$ & $CrLf & _
             m10$
      Ans = MsgBox(m$, _
                   %MB_TASKMODAL Or %MB_YESNO, _
                   m0$)
      Reset m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
    End Macro
    '
     
     
    '****************************************************************************
     
    Function PBMain
      mb_Locals
      Local x&                       
      x = 123 * 456
     
      m0$ = "Check Variables During Program Run"
      m1$ = Using$("Variable A = #, ", 1 )
      m2$ = Using$("Variable B$ = \  \ ", "2" )
      m3$ = Using$("Variable C = #, ", 3 )
      m4$ = Using$("Variable D$ = \  \ ", "4" )
      m5$ = Using$("Variable E = #, ", x \ 23)
      m6$ = Using$("Variable F = #, ", 5 )
      m7$ = Using$("Variable G = #, ", 6 )
      m8$ = Using$("Variable H = #, ", 7 )
      m9$ = Using$("Variable I = #, ", 8 )
      m10$ = Using$("Variable J = #, ", 10 )
      mb_Alert 'Alert
     
      m0$ = "STOP STOP STOP!!!"
      m2$ = Using$("Variable X = #, ", x * 123)
      m5$ = Using$("Variable X = #, ", x \ 231)
      mb_Stop 
     
      m0$ = "Hey Dummy"  'header
      m1$ = "    Catastrophe Ahead Warning!!!" 
      m4$ = "Do you REALLY want to erase everything?"
      m1$ = "    Catastrophe Ahead Warning!!!" 
      mb_ans
        If ans = %IdYes Then             
         ' Shoot self in leg
        End If
     
      m0$ = "Hey Buddy"
      m1$ = "Can you spare a dime?"
      m3$ = "No?"
      m5$ = "How about a buck?"
      m7$ = "No?"
      m9$ = "Okay then gimme your watch or your life"
      mb_Ans 
        If ans = %IdYes Then             
         ' Shoot beggar
        End If
     
      Err = 53  'force an error
      m1$ = "Forced Error"
      m_Err_Msg
     
     
    End Function
    '
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/
Working...
X