Announcement

Collapse
No announcement yet.

Graphic Window Scrolling

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

  • Michael Mattias
    replied
    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

    Leave a comment:


  • Ian Cairns
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    > I'm very interesting in your sourcecode DDT Graphic scrolling window example

    Why don't you finish your scrollbars/timer application first?

    Leave a comment:


  • Stephane Fonteyne
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    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:
        [COLOR=gray]Graphic Print Msg[/COLOR]
        'Graphic WAITKEY$ To s$
        While IsWin(hWin)
          Graphic Inkey$ To s$
          If Len(s$) <> 0 Then Exit Loop
          Sleep 1
        Wend
        [COLOR=gray]Function = s$[/COLOR]
    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
    =======================================================

    Leave a comment:


  • Dave Biggs
    replied
    #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:
        [COLOR=gray]Graphic Print Msg[/COLOR]
        'Graphic WAITKEY$ To s$
        While IsWin(hWin)
          Graphic Inkey$ To s$
          If Len(s$) <> 0 Then Exit Loop
          Sleep 1
        Wend
        [COLOR=gray]Function = s$[/COLOR]

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    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

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Michael Mattias View Post
    Graphics applications? Moi?

    I'm not a graphics guy.
    Ah ...., but you can graphiclly sting when you replys to (Graphic) posts.

    =======================================================
    Writing is a difficult trade
    which must be learned slowly by reading great authors;
    by trying at the outset to imitate them;
    by daring then to be original;
    by destroying one’s first productions.
    André Maurois
    =======================================================

    Leave a comment:


  • Michael Mattias
    replied
    Graphics applications? Moi?

    I'm not a graphics guy.

    Hell, I can't win a game of 'Hangman' for lack of the required art skills.......

    Leave a comment:


  • Dave Biggs
    replied
    I really like 'Real World' examples of applications...
    Do you have any particular graphic applications in mind Michael?

    If you need to display a scrollable bitmap you could add scroll bar controls to a graphic control in a dialog using code similar to the sample posted by Steve.
    You also have the option to use a Graphic Window as in the sample code that I posted.

    While you cannot resize either a Graphic Control or a Graphic Window - you are able to drag a Graphic Window independently to different positions on the screen, which can be useful.

    You can subclass a Graphic Control to detect clicks.
    With a Graphic Window the functionality is built-in.

    Similar tools but different enough that you might want to use one instead of the other - depending on the circumstances.

    Leave a comment:


  • Michael Mattias
    replied
    I think the "loud message box" use makes some sense.

    (Using a GRAPHIC WINDOW just to detect clicks or keys in a gui program to me does not)

    I really like 'Real World' examples of applications... when it's just "how does <functionname> work?" the post reads like the compiler documentation and provides just about as much insight into "what" purpose it is serving - none.

    MCM

    Leave a comment:


  • Cliff Nichols
    replied
    Actually I follow MCM's line of thinking (once I get the hang of the graphic window) that if the rest of my app is GUI...why console? or window separate?

    The answer here is..."Take the simple example, make it work, and then learn why it works" sort of attitude
    or depending on your style

    Lucky me, I get to look into "GRAPHICS" and make something work (and GRRRRrrrr I suck at anything graphicly and going the crayola crayon route to learn about drawing lines/squares/maybe even ovals

    (Anyone that teaches in any compacity, stand up for this one and take pride in a "Student FINALLLLLY gets it")
    If it were not for my days of "When the FUBAR will I ever need this" comments (and yep I was a cocky kid when I did not understand something) I finally get a situation where I need it!!! (others I bent a bit to actually understand, but still had to be cocky out of stubborness)

    Why graphics?? (well color flash-bangs distract the user)

    seriously though, I have 2 possible purposes (1 to show the action of what is happening, and the other to show a picture of how the overall system works when words are not enough)

    so I took my 1st step (and my crayon mentality of what I can understand) and attempt to build something I can learn from.

    That said...InKeys and Graphic Print are 2 things I have to research once I learn how to draw lines at an angle

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Dave Biggs View Post
    Why not reverse the question?

    In any case, the answer might well be "application specific".

    Another answer might be that you would like to make use of of the GRAPHIC WINDOW CLICK statement for something or other..
    Another might be to get a painless Inkey functionality.

    ========================================
    "And I looked,
    and behold a pale horse:
    and his name that sat on him was Death,
    and Hell followed with him."
    Revelations 6:8
    ========================================

    Leave a comment:


  • Dave Biggs
    replied
    Why would you use a GRAPHIC WINDOW with PB/Windows instead of a GRAPHIC CONTROL on a 'regular' dialog?
    Why not reverse the question?

    In any case, the answer might well be "application specific".

    Another answer might be that you would like to make use of of the GRAPHIC WINDOW CLICK statement for something or other..

    Leave a comment:


  • Cliff Nichols
    replied
    Thank you Ian for the code, works great.

    Between your code and Steve Rossell's code, I have some research to do.

    (Small side note I found interesting, I left your demo running over the weekend (forgot to close the window), and this morning when I went to reboot, saw the program still running (but everything was black and white with no color))
    Just thought you may want to know in case it is ever meant to run that long.

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Michael Mattias View Post
    Sincere Question:

    Why would you use a GRAPHIC WINDOW with PB/Windows instead of a GRAPHIC CONTROL on a 'regular' dialog?

    I can see it (sort of) with a console application, but if already a GUI app...????


    MCM
    Dunno about anyone else but I often use GW as a sort of LOUD msgbox. See the Clipboard Phone Dialer in the Programming Forum (would put the address in but the Forum editor seems to be not allowing C&P operations right now for some reason. Dunno why that happens but it does sometimes. Can't highlight either. Works fine in other programs at the same time though.).

    =====================================================
    "I consider the foundation of the Constitution
    is laid on this ground:
    That all powers not delegated to the United States,
    by the Constitution,
    nor prohibited by it to the States,
    are reserved to the States
    or to the people.
    (10th Amendment).

    To take a single step beyond
    the boundaries thus specifically drawn
    around the powers of Congress,
    is to take possession of a boundless field of power,
    no longer susceptible to any definition." -

    Thomas Jefferson letter to George Washington,
    15 February, 1791
    =====================================================

    (Strange but the saying above is Pasted. Curious. C&P Seems to be working again. Curiouser.)

    Here's the address for CPD http://www.powerbasic.com/support/pb...ad.php?t=40189
    Last edited by Gösta H. Lovgren-2; 29 Mar 2009, 09:42 PM.

    Leave a comment:


  • Michael Mattias
    replied
    Sincere Question:

    Why would you use a GRAPHIC WINDOW with PB/Windows instead of a GRAPHIC CONTROL on a 'regular' dialog?

    I can see it (sort of) with a console application, but if already a GUI app...????


    MCM

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by Dave Biggs View Post
    Sample code to add scroll bars to a Graphic Window, posted in source code forum here..
    http://www.powerbasic.com/support/pb...ad.php?t=40241

    The sample shows how to use a Graphic Window as a 'view port' to scroll around a larger bit map.
    Nifty stuff Dave.

    ===============================================
    "Peace is not won
    by those who fiercely guard their differences,
    but by those who with open minds and hearts
    seek out connections."
    Katherine Paterson
    ===============================================

    Leave a comment:


  • Dave Biggs
    replied
    Graphic Window with scroll bars

    Sample code to add scroll bars to a Graphic Window, posted in source code forum here..
    http://www.powerbasic.com/support/pb...ad.php?t=40241

    The sample shows how to use a Graphic Window as a 'view port' to scroll around a larger bit map.
    Last edited by Dave Biggs; 29 Mar 2009, 11:46 AM. Reason: sp

    Leave a comment:

Working...
X