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

MSGBOX for beginners (like me)

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

  • MSGBOX for beginners (like me)

    ' This simple program demonstrates some features of MSGBOX,
    ' which provides an easy way of producing output of text and
    ' numbers to the screen in PowerBASIC DLL 6.0 for Windows.
    ' MSGBOX also provides an easy way of interacting with the program
    ' not to be overlooked in the difficult beginning phase of
    ' Windows programming.
    ' For further information consult the section on "MessageBox"
    ' in the Win32 help file: "Win32 programmer's Reference".
    '
    ' Erik Christensen, Copenhagen, Denmark. e.chr@email.dk
    Code:
    #DIM ALL
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    
    FUNCTION PBMAIN () AS LONG
    LOCAL I%,K%,J%,MsStyleFlagAndValue$
    LOCAL Result AS LONG           ' In the PowerBASIC help file
                                   ' this is erroneously defined
                                   ' as an INTEGER variable.
    LOCAL ResultID AS STRING
    DIM StyleFlagText(34) AS STRING
    DIM StyleFlagValue(34) AS LONG ' In the PowerBASIC help file
                                   ' this is erroneously defined
                                   ' as an INTEGER variable.
    
    ' MessageBox() StyleFlags (copied from the Win32api.inc file):
    
    DATA "%MB_OK                   = &H0&"
    DATA "%MB_OKCANCEL             = &H1&"
    DATA "%MB_ABORTRETRYIGNORE     = &H2&"
    DATA "%MB_YESNOCANCEL          = &H3&"
    DATA "%MB_YESNO                = &H4&"
    DATA "%MB_RETRYCANCEL          = &H5&"
    
    DATA "%MB_ICONHAND             = &H10&"
    DATA "%MB_ICONQUESTION         = &H20&"
    DATA "%MB_ICONEXCLAMATION      = &H30&"
    DATA "%MB_ICONASTERISK         = &H40&"
    
    DATA "%MB_ICONERROR            = &H10&" '=%MB_ICONHAND
    DATA "%MB_ICONINFORMATION      = &H40&" '=%MB_ICONASTERISK
    DATA "%MB_ICONSTOP             = &H10&" '=%MB_ICONHAND
    DATA "%MB_ICONWARNING          = &H30&" '=%MB_ICONEXCLAMATION
    
    DATA "%MB_DEFBUTTON1           = &H0&"
    DATA "%MB_DEFBUTTON2           = &H100&"
    DATA "%MB_DEFBUTTON3           = &H200&"
    
    ' The following style flags may also be applied
    ' They are not used here.
    ' You can experiment with them.
    DATA "%MB_APPLMODAL            = &H0&"
    DATA "%MB_SYSTEMMODAL          = &H1000&"
    DATA "%MB_TASKMODAL            = &H2000&"
    
    DATA "%MB_NOFOCUS              = &H8000&"
    DATA "%MB_SETFOREGROUND        = &H10000"
    DATA "%MB_DEFAULT_DESKTOP_ONLY = &H20000"
    
    DATA "%MB_TYPEMASK             = &HF&"
    DATA "%MB_ICONMASK             = &HF0&"
    DATA "%MB_DEFMASK              = &HF00&"
    DATA "%MB_MODEMASK             = &H3000&"
    DATA "%MB_MISCMASK             = &HC000&"
    DATA "%MB_TOPMOST              = &H40000&"
    DATA "%MB_RIGHT                = &H80000&"
    DATA "%MB_RTLREADING           = &H100000&"
    
    DATA "%MB_PRECOMPOSED          = &H1" ' use precomposed chars
    DATA "%MB_COMPOSITE            = &H2" ' use composite chars
    DATA "%MB_USEGLYPHCHARS        = &H4" ' use glyph chars, not ctrl chars
    
    MSGBOX "This simple program demonstrates some features of MSGBOX,"+_
    " which provides an easy way of producing output of text and"+_
    " numbers to the screen in PowerBASIC DLL 6.0 for Windows."+_
    " MSGBOX also provides an easy way of interacting with the program"+_
    " not to be overlooked in the difficult beginning phase of"+_
    " Windows programming."+_
    " For further information consult the section on MessageBox"+_
    " in the Win32 help file: Win32 programmer's Reference."+$CRLF+$CRLF+_
     "Erik Christensen, Copenhagen, Denmark.   e.chr@email.dk",,_
    " Message Box test program"
    
    
    FOR I%=1 TO 34
        MsStyleFlagAndValue$ = READ$(I%)' MsStyleFlagAndValue$
        K% = INSTR(MsStyleFlagAndValue$," ")
        J% = INSTR(MsStyleFlagAndValue$,"=")
        StyleFlagText(I%)=LEFT$(MsStyleFlagAndValue$,K%-1)
        StyleFlagValue(I%)=VAL(MID$(MsStyleFlagAndValue$,J%+1))
    NEXT
    
    FOR I%=1 TO 6
      Result = MSGBOX ("The style flag for this message box is: " _
                       +StyleFlagText(I%),StyleFlagValue(I%), _
                       "Message box style flag test")
               
      SELECT CASE Result
        CASE %IDOK      ' =1    OK button was selected.
          ResultID = "%IDOK"
    
        CASE %IDCANCEL  ' =2    Cancel button was selected.
          ResultID = "%IDCANCEL"
    
        CASE %IDABORT   ' =3    Abort button was selected.
          ResultID = "%IDABORT"
    
        CASE %IDRETRY   ' =4    Retry button was selected.
          ResultID = "%IDRETRY"
    
        CASE %IDIGNORE  ' =5    Ignore button was selected.
          ResultID = "%IDIGNORE"
    
        CASE %IDYES     ' =6    Yes button was selected.
          ResultID = "%IDYES"
    
        CASE %IDNO      ' =7    No button was selected.
          ResultID = "%IDNO"
    
        CASE ELSE
      END SELECT
    
    ' display result code for selected button
    
      MSGBOX "You pressed the "+MID$(ResultID,4)+" button"+$CRLF+ _
             "Result = "+LTRIM$(STR$(Result))+$CRLF+ _
             "This is the value of "+ResultID,,"Selection Result"
    
    NEXT
    
    FOR I%=7 TO 10
      Result = MSGBOX ("The style flag for this message box is: " _
               +StyleFlagText(I%),StyleFlagValue(I%),"Message Box test")
    NEXT
    
    FOR I%=3 TO 4
      FOR J%=15 TO 17
        Result = MSGBOX ("The style flags for this message box are: "_
                 +StyleFlagText(I%)+" + " _
                 +StyleFlagText(J%)+" + " _
                 +StyleFlagText(J%-I%*3+6), _
                 StyleFlagValue(I%)+ _
                 StyleFlagValue(J%)+ _
                 StyleFlagValue(J-I%*3+6), _
                 "Message box style flags test")
      NEXT
    NEXT
    
    MSGBOX "This was the end of this small message test program!",, _
           "The End"
    
    END FUNCTION
    
    ------------------
    [This message has been edited by Erik Christensen (edited December 20, 2000).]
Working...
X