Announcement

Collapse
No announcement yet.

CONTROL SET IMAGE workaround

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

  • CONTROL SET IMAGE workaround

    Hi there,

    just spend a whole day on debuging. Made a programm which blocks a
    whole NT Server after running some days. Found out that
    repeatedly calling CONTROL SET IMAGE makes the trouble.

    I'll use CONTROL SEND CBHNDL, 100, %STM_SETIMAGE, %IMAGE_BITMAP, hBmp
    instead. Are there any known side effects ? Pls look at the source below.

    Ralph

    Code:
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' file : ddtsplash.bas
    '
    #DIM ALL
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    #RESOURCE "dsplash.pbr"
    
    
    CALLBACK FUNCTION CB_animate
    
      STATIC picture  AS LONG
      STATIC sTimer   AS LONG
    
      SELECT CASE CBMSG
             
        CASE %WM_INITDIALOG
              DIM arrBmp(1000 TO 1006) AS STATIC LONG
              FOR picture = 1000 TO 1006
                 arrBmp(picture) = LoadBitmap( GetModuleHandle (BYVAL 0&), "#"+STR$(picture) )
              NEXT
              sTimer  = SetTimer(CBHNDL, 0, 120, %NULL)
              picture = 1000
    
        CASE %WM_DESTROY
              CONTROL SEND CBHNDL, sTimer, %WM_DESTROY, CBWPARAM, CBLPARAM
              FOR picture = 1000 TO 1006
                  DeleteObject arrBmp(picture)
              NEXT
    
        CASE %WM_TIMER
             INCR picture
             IF picture = 1007 THEN picture = 1000
             '''''' main thing
             '''''' use
             CONTROL SEND CBHNDL, 100, %STM_SETIMAGE, %IMAGE_BITMAP, arrBmp(picture)
             '''''' instead of
             ' CONTROL SET IMAGE, CBHNDL, 100, "#" + STR$(picture)
    
    
        CASE %WM_LBUTTONDOWN
             DIALOG END CBHNDL, 1
    
      END SELECT
    
    END FUNCTION
    
    
    FUNCTION PBMAIN
        LOCAL hdlg AS LONG
    
        DIALOG NEW 0, "animate",,, 305,158, %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME TO hdlg
        CONTROL ADD IMAGE, hdlg, 100, "#1000", 1,1,42, 29, %WS_CHILD OR %WS_VISIBLE OR %SS_SUNKEN
        DIALOG SHOW MODAL  hdlg CALL CB_animate
    
    END FUNCTION




    ------------------

  • #2
    There is a compiled version at:
    http://www.bergertime.de/horse.exe

    Size 19 k. Shows a galopping horse on top left corner of the
    DDT dialog.

    ------------------


    [This message has been edited by Ralph Berger (edited July 24, 2000).]

    Comment


    • #3
      ralph,

      have a look at http://www.powerbasic.com/support/pb...ead.php?t=2349

      maybe you get some insights from that thread.

      knuth

      ------------------
      http://www.softaware.de

      Comment


      • #4
        Knuth,

        i could save much time, if i'd read before.
        However CONTROL SEND CBHNDL,,%STM_SETIMAGE ..
        solves my resource leak

        Ralph

        ------------------

        Comment


        • #5
          Yes, the IMAGE and IMAGEX controls seem to have a built-in leak
          in them, so it's better to use a LABEL with %SS_BITMAP instead.
          In your PBMAIN, replace CONTROL ADD IMAGE with the following and
          see if that helps:
          Code:
              CONTROL ADD LABEL, hdlg, 100, "", 1,1,42, 29, _
                                 %WS_CHILD OR %WS_VISIBLE OR %SS_BITMAP OR %SS_SUNKEN
              CONTROL SET IMAGE hDlg, 100, "#1000"
          ------------------

          Comment


          • #6
            Ralph,

            I don't know if this could help you, but WinLIFT has built-in functions
            to display animated bitmaps that won't produce any memory leak and use
            very little CPU.


            ------------------
            Patrice Terrier
            mailto[email protected][email protected]</A>
            Patrice Terrier
            www.zapsolution.com
            www.objreader.com
            Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

            Comment


            • #7
              Ralph,

              I downloaded your horse.exe, but it did not show any animation, only a
              what looks like a single horse for just a split second. I also tried to
              compile your source, but of course without the pbr file, I couldn't.

              I would like to understand this animation stuff, so any help would be
              appreciated. I am running with Windows 98 SE.


              ------------------

              Comment


              • #8
                Charles,

                you make me curious. I try with WinNt SP6, Win98 and W2K.
                Works on all. Has anyone else the same problem ?

                You'll find all together at :
                http://www.bergertime.de/horse.zip

                Ralph

                ------------------

                Comment


                • #9
                  Charles,

                  i have to correct myself. The exe doesn't run on my Win98 to.

                  Code:
                  pls replace line: arrBmp(picture) = LoadBitmap( GetModuleHandle (BYVAL 0&), "#"+STR$(picture) )  
                              with  arrBmp(picture) = LoadBitmap( GetModuleHandle (BYVAL 0&), "#"+TRIM$(STR$(picture)) )
                  Updated zip & exe file on my homepage. Thank you for the hint.

                  Ralph

                  ------------------

                  Comment


                  • #10
                    STR$ adds a leading space character. FORMAT$ doesn't, so
                    TRIM$(STR$(picture)) can be replaced with FORMAT$(picture)

                    ------------------

                    Comment

                    Working...
                    X
                    😀
                    🥰
                    🤢
                    😎
                    😡
                    👍
                    👎