Results 1 to 4 of 4

Thread: Fast as flange screen updates

  1. #1

    Thread Starter
    Addicted Member Geoff Gunson's Avatar
    Join Date
    Jun 1999
    Posts
    241

    Fast as flange screen updates

    Hello

    We produce a product called a TGS (picuture included) basically it has some debug screen a circit display. The circuit display is a grid of numbers and states , like IDLE WANS OUT/G etc. The current method we use is a Flexi grid. this in my option is slow and takes up far too much processor time.

    Anyway I am thinking of rewriting it using bitmaps and the BitBLt fuction, is this a good Idea or is there something better? Some control maybe?

    It will need to be able to flick the states on say 60 circuits 6000 times a minute, so you it needs to be quick.

    Any Ideaz??

    CMD

    G

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well you could always use an array of textboxes or something.
    Or you could maybe use the DrawText API

    Code:
    Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    
    ' DrawText() Format Flags
    Const DT_TOP = &H0
    Const DT_LEFT = &H0
    Const DT_CENTER = &H1
    Const DT_RIGHT = &H2
    Const DT_VCENTER = &H4
    Const DT_BOTTOM = &H8
    Const DT_WORDBREAK = &H10
    Const DT_SINGLELINE = &H20
    Const DT_EXPANDTABS = &H40
    Const DT_TABSTOP = &H80
    Const DT_NOCLIP = &H100
    Const DT_EXTERNALLEADING = &H200
    Const DT_CALCRECT = &H400
    Const DT_NOPREFIX = &H800
    Const DT_INTERNAL = &H1000
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    That kind of Speed is impossible, unless you plan on Running the thing on an Extremely Fast Machine.

    If your FlexiGrid was a PictureBox, with a Scroll Bar Drawn Below it.

    You could do it like this:

    1 Picture would Contain The Circits in N/A State, the max Circits, you need.

    Then another picture for each State, the right size to fit in exactly.

    Code:
    dim Stop as Boolean 'Set this when you wish it to stop updating
    dim hDCs(4) as long
    
    Const Background = 1
    Const Idle = 2
    Const WANS =3
    Const OUT/G = 4
    Const WidthCircit = 100 (50 for the number, 50 for state)
    Const HeightCircit
    Const CircitsPerColumn = 12
    Const CircitsPerRow = 4
    
    'ScrollBar.Value should have two values - 0 and 1 for 60 circits
    
    Form_Load()
    LoadPicture
    Stop = False
    
    Do Until Stop = True
          Do Events
          'Blt Background
          BitBlt picture1.hdc , 0,0,picture1.width,picture1.height, hdcs(Background), ScrollBar.Value * WidthCircit,0 SRCCOPY
          for i = CircitsPerColumn * scrollbar.value to CircitsPerColumn * scrollbar.value * CircitsPerRow
              X = ((i \ CircitsPerColumn) - ScrollBar.value) * WidthCircit + (widthcircit /2)
              Y = ((i -1 )mod circitsPerColumn ) * heightColumn
    
               Select case Circits(i).state
                     Case "IDLE" then
                          BitBlt picture1.hdc, x, y,widthcircit /2,heightcircit,hDCs(IDLE),0,0,SRCCOPY
                     Case 'etc
                End Select
    Loop
    
    UnloadPictures
    
    EndSub
    
    Sub LoadPictures
     ' See the Thread vy Fox concerning Releasing DC's, all the code in there, i need to go work now, just but the DC's into the hDCs Array
    End Sub
    
    sub UnLoadPictures
    'Ditto
    End sub
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  4. #4

    Thread Starter
    Addicted Member Geoff Gunson's Avatar
    Join Date
    Jun 1999
    Posts
    241
    Cheers for the info, sorry the reply was a bit late I blame my Email server, its about as fast as an asmatic hamster.

    plenderj: I haven't tried that I'll give it a whril.

    Nirces: Well I wrote a test app, based around your code, it was changing 1500 circuits simutanously without any bother.

    May be I got my maths wrong, what it is, is a tool for generating calls into a BT switch. You could have 30 active calls for instance each call only lasting .1 of a second having to go through 4 different states.

    4 * 30 * 10 * 60 = 72,000 updates to the entire screen per minute.

    The test app flicked all 1500 circuits between 2 states with a 200 ms delay in the loop. In one minute it went through the loop 200 times

    1500 * 2 * 200 = 600,000 updates per minute.

    So it looks as if the API BitBlt is plenty quick enough.

    Thanks again

    G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width