Results 1 to 5 of 5

Thread: Generated DC problems!!!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39

    Exclamation

    Each time when I click on a command button, the procedure commandbutton_click is executed...

    Inside the commandbutton_click procedures, a mask image and sprite image will be generated using the GenerateDC and BitBlt function and it'll move 10 pixels left.

    therefore, whenever the commandbutton is click, a sprite will be generated and it'll move around the screen 10 pixels left

    now the problem is, after hundreds time clicking the button, the 'low memory' or 'low resources' message is displayed.

    Although, i've added deleteDC function in every click, the problem never subside.
    To make the matter worse, after exiting the program, the windows will be messed up... signs of not enough memory...

    Can anyone help me?

    Code:
    Private Sub CommandButton_Click()
    Dim Move
    Move = 10
    Move = Move + 10
    
    'load images
    DCMask = GenerateDC("c:\1m.bmp")
    
    If DCMask <= 0 Then
        MsgBox "Failure in creating mask dc"
        Exit Sub
    End If
    
    DCSprite = GenerateDC("c:\1.bmp")
    
    If DCSprite <= 0 Then
        MsgBox "Failure in creating sprite dc"
        'Clean up after the created mask
        DeleteGeneratedDC DCMask
    End If
    
    'add the sprite and the mask
    
    BitBlt Me.hdc, 0, Move, 30, 30, DCMask, 0, 0, vbSrcAnd
    BitBlt Me.hdc, 0, Move, 30, 30, DCSprite, 0, 0, vbSrcPaint
    
    'delete the images after generated
    DeleteGeneratedDC DCMask
    DeleteGeneratedDC DCSprite
    
    frmTest.Cls
    frmtest.Refresh

    This is not the real code, but just to give you the main idea
    Any suggestion?

    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You should use ReleaseDC instead of DeleteDC
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    Can you please give me the code for releaseDC if it's not too much trouble...

    Btw, what's the difference between DeleteDC and ReleaseDC

    and how do you apply releaseDC on generatedDC
    Thanx

    [Edited by nameJack on 12-20-2000 at 04:45 AM]
    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I have no idea from where you got generateDC, i guess it's a procedure you have from before that loads a bitmap and then attaches it to a DC without you have to worry about that. In that case i think you have to release the bitmap too. Deleteobject should do the trick. Before i get further i need to know how this generateDC looks like, it would be easier to work with it if you store the bitmap handle.
    I'm not sure what the difference is between deleteDC and releaseDC, except that DeleteDC doensn't do what i also once thought was freing up the handle.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    Well... i guess i had to upload this project...
    http://www.geocities.com/weirdteenage/project.zip
    Try and see if theres something wrong
    the message box was put up to indicate the error
    when you move the sprite 200 times or more
    the messagebox icon will turn black indicating low memory

    Actually i would prefer if u could give me another way of doing so?

    take a look at the project...

    [Edited by nameJack on 12-20-2000 at 10:30 AM]
    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

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