Announcement

Collapse
No announcement yet.

Any problem with this type of "timed msgbox"?

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

  • Any problem with this type of "timed msgbox"?

    I looked up many of the "timed MSGBOX" solutions in the forums, and then wondered why a person could not do a simple "timed error message box" like the attached code does it.

    Can anyone see a flaw or caveat to doing one this way?

    By the way, the CONTROL SET TEXT statements were needed because the dialog box showed up blank when I put the text in the CONTROL ADD LABEL statements.


    Code:
    DIALOG NEW 0, "My USB Program Error", 0, 0, 200, 45, %DS_CENTER, 0 TO hDlg
    CONTROL ADD LABEL, hDlg, 998, "", 10, 5, 190, 10
    CONTROL ADD LABEL, hDlg, 999, "", 10, 15, 190, 10
    DIALOG SHOW MODELESS hDlg
    DIALOG SHOW STATE hDlg, %SW_RESTORE
    CONTROL SET TEXT hDlg, 998, "There was a problem opening the USB connection."
    CONTROL SET TEXT hDlg, 999, "Check the power and USB connections to the display."
    SLEEP 3000
    DIALOG END hDlg
    Gary Peek, Industrologic, Inc.

  • #2
    Originally posted by Gary Peek View Post
    Can anyone see a flaw or caveat to doing one this way?

    By the way, the CONTROL SET TEXT statements were needed because the dialog box showed up blank when I put the text in the CONTROL ADD LABEL statements.
    Just needed the WPI Include, and a function (PBMain in this case) and a Local and the code ran fine (no need of the Set Text's).

    I see no caveats and think it could be very handy in some cases. (Maybe add a WinBeep?)

    '
    Code:
    $Include "WIN32API.INC"
    Function PBMain
     Local hdlg As Dword
    Dialog New  0,"My USB Program Error", , , 200, 45, %DS_CENTER, 0 To hDlg
    Control Add Label, hDlg, 998, "There was a problem opening the USB connection.", 10, 5, 190, 10
    Control Add Label, hDlg, 999, "Check the power and USB connections to the display.", 10, 15, 190, 10
    Dialog Show Modeless hDlg
    Dialog Show State hDlg, %SW_RESTORE
    Sleep 3000
    Dialog End hDlg
    End Function
    '
    ========================================
    "He is one of those people who would be
    enormously improved by death."
    H. H. Munro (Saki) (1870-1916)
    ========================================
    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/

    Comment


    • #3
      I don't see a problem with it, but there have been several threads about SLEEP not really being intended or desirable to use as a time delay. If you do a search on SLEEP and DELAY you can decide for yourself. I've been know to use SLEEP as a delay with no problem, but in more recent code I use the system time, especially for something several seconds long.

      Comment


      • #4
        Oh, yes, I had the API defined and all, the way I used it was within some other code where it was already defined.

        [ ... and the code ran fine (no need of the Set Text's). ]

        I played around with it some more, and I either need the SET TEXT lines, or a DIALOG REDRAW hDLG.

        Perhaps it needs that when it is being uncovered by another window.

        Thanks for the comments.
        Gary Peek, Industrologic, Inc.

        Comment


        • #5
          >Perhaps it needs that when it is being uncovered by another window.

          Or moved.

          With no message loop, the window does not get notified that it needs to redraw iteself.

          I think there are some other "Messagebox with timeout" demos in the source code forum. They might give you some extra ideas.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            You could use a Graphic Window -
            .. persistent -- they are automatically redrawn for you after resuming from being minimized or temporarily covered by other windows.
            Code:
            #Dim All
            #Register NONE
            #INCLUDE "WIN32API.INC"
             
            Function PbMain()
             Dim hGfx???, click&, x!, y!, tc&, Key$
             
              GRAPHIC WINDOW " My USB Program Error", 500, 500, 300, 80 TO hGfx
              GRAPHIC ATTACH hGfx, 0
              GRAPHIC SET POS (0,20)
              GRAPHIC PRINT "     There was a problem opening the USB connection."
              GRAPHIC PRINT "     Check the power and USB connections to the display."
              Do While Click = 0
                'GRAPHIC WINDOW CLICK TO Click, x, y                           ' Useful if no caption
                'GRAPHIC INKEY$ TO Key : If Key = CHR$(27) Then Exit Loop      '    "    "  "    "
                Incr tc
                SLEEP 10
              Loop Until tc = 500
              GRAPHIC WINDOW END
             
            End Function
            '------------------/PBMain
            A limitation might be that you have to 'hand craft' a message box of this kind to suit the amount of text to be displayed. I suppose adding buttons and icons would be a chore too, unlike a 'standard' message box..
            Rgds, Dave

            Comment

            Working...
            X