Announcement

Collapse
No announcement yet.

Graphic Window Scrolling

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

  • #21
    Example of a "Loud Message" box. It could probably be coded cleaner/simpler but gives the idea and be reasonably easy to follow/implement.

    '
    Code:
    'PBWIN 9.01 - WinApi 05/2008 - XP Pro SP3
    #Compile Exe                                
    #Dim All 
    #Optimize SPEED
     #Debug Display On 'This mode should only be used during program development and debugging.  It should never be used in a production program.
                       ' Dunno why. Only info in Help.
    ' 
    #Include "WIN32API.INC"
    #Include "COMDLG32.INC"
    #Include "InitCtrl.inc"
    '
    Function PBMain         
      ErrClear   
      MsgBox "Do you prefer this for a notice?",,FuncName$
      Local s$
      s$ = Loud_Message("   Or This?", FuncName$)
      ? s$ & " returned",,"From Loud_Message"
    End Function 
    '
    Function Loud_Message(Msg As String,  Msg_Header As String) As String 
        ErrClear
        Local hWin, hfont As Dword 'just needed for setup
        Local col, row, wdth, hght As Long
        Local s As String
       Desktop Get Size To Wdth, hght&
        Col = Wdth \ 4
         Row = hght \ 2  
    '    
        Wdth = Wdth / 2 
        Hght = 100
        Graphic Window Msg_Header$, Col, Row, Wdth, Hght To hWin
        Graphic Attach hWin, 0 
        Font New "Comic MS Sans", 48 To hfont
        Graphic Set Font hfont
        Graphic Set Pos (10, 20)
        Graphic Print Msg              
    '
        While IsWin(hWin)
          Graphic Inkey$ To s$
          If Len(s$) <> 0 Then 
             Function = s$
             Graphic Window End
             Exit Loop
          End If   
          Sleep 1
        Wend
    '
    End Function
    '
    Last edited by Gösta H. Lovgren-2; 2 Apr 2009, 09:42 AM. Reason: New and Improved code - see mext msgs
    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


    • #22
      #Optimize SPEED
      #Debug Display On 'This mode should only be used during program development and debugging. It should never be used in a production program.
      ' Dunno why. Only info in Help.
      Probably incompatable directives here - one is asking for speed, the other is saying slow me down with extra error trapping code .
      (p.s. PB Gazette #066 has more info on Debug Display On).

      BTW I get the following Debug Display message popup if I close the Graphic Window with Alt-F4 or the [X] Close button.
      (ie Close the Graphic Window while Waitkey$ is umm.. waiting. The window closes without any errors when a key is pressed).
      ---------------------------
      Error
      ---------------------------
      Untrapped Error #7 (Out of memory)
      has occurred following execution of LOUD_MES

      Press OK to continue, Cancel to terminate
      ---------------------------
      OK Cancel
      ---------------------------
      This avoids the error but still catches the keypress:
      Code:
          Graphic Print Msg
          'Graphic WAITKEY$ To s$
          While IsWin(hWin)
            Graphic Inkey$ To s$
            If Len(s$) <> 0 Then Exit Loop
            Sleep 1
          Wend
          Function = s$
      Rgds, Dave

      Comment


      • #23
        Originally posted by Dave Biggs View Post
        Probably incompatable directives here - one is asking for speed, the other is saying slow me down with extra error trapping code .
        (p.s. PB Gazette #066 has more info on Debug Display On).
        I was just passing on a gentle needle here. {grin}

        BTW I get the following Debug Display message popup if I close the Graphic Window with Alt-F4 or the [X] Close button.
        (ie Close the Graphic Window while Waitkey$ is umm.. waiting. The window closes without any errors when a key is pressed).
        ---------------------------
        Error
        ---------------------------
        Untrapped Error #7 (Out of memory)
        has occurred following execution of LOUD_MES
        I got the same error once too. Never repeated so I just figured it was some sort OpSys or PB mem cleanup that Display On caught. I probably didn't close via X or Alt F4 again and didn't connect the reason.
        This avoids the error but still catches the keypress:
        Code:
            Graphic Print Msg
            'Graphic WAITKEY$ To s$
            While IsWin(hWin)
              Graphic Inkey$ To s$
              If Len(s$) <> 0 Then Exit Loop
              Sleep 1
            Wend
            Function = s$
        Good improvement. I would still leave the Function = s$ though (after Sleep 1) That way a response could be returned. (I actually use it that way sometimes ).

        It needed a Window End this way too. (Replaced code above to reflect improvements)

        =======================================================
        "We're going to turn this team around 360 degrees."
        Jason Kidd, upon his drafting to the Dallas Mavericks
        =======================================================
        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


        • #24
          Probably incompatable directives here - one is asking for speed, the other is saying slow me down with extra error trapping co
          Au contraire, mon amis.

          While you'd have to ask PB, who might refuse to answer on proprietary grounds....

          I would guess compiling for use with the stepping debugger compiles the program "with all other options intact" and then ADDs any code required to enable stepping thru the program.

          That is, the code which will run in production will be exactly the code thru which you are stepping, minus the code added to support the debugging session.

          Which sounds like a Good Thing.....

          MCM
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #25
            Ian Cairns,

            Can you post your examples to the source forum I'm very interesting in your examples.

            I'm very interesting in your sourcecode DDT Graphic scrolling window example that scrolls using ScrollDC with Time stamp reflecting current time, and simulated inputs.
            Thanks
            Stephane

            Comment


            • #26
              > I'm very interesting in your sourcecode DDT Graphic scrolling window example

              Why don't you finish your scrollbars/timer application first?
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #27
                Source Code for demo scroll window

                I just haven't had time to come back to do anything with the scrolling sample. I haven't played with the DDT graphic commands to know how badly I have mishandled the displays. The code is released as public domain. Just don't ask me to fix anything. Fix the faults yourself and publish the fixed version if you so desire.

                I have an interesting demo of a different way of doing 2D off-centre bitmap rotations, but that is for another posting at a different time.

                regards, Ian
                Attached Files
                :) IRC :)

                Comment


                • #28
                  I did not look at your example, but Paul Dixon came up with a pretty clever way to scroll a graphic horizontally in this thread ....
                  http://www.powerbasic.com/support/pb...ad.php?t=42614

                  .. and if you read that thread more carefully than did I, you will find it the first time you read it through....

                  MCM
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment

                  Working...
                  X