Page 1 of 2 12 LastLast
Results 1 to 40 of 44

Thread: GetObjectAPI with DC

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    GetObjectAPI with DC

    Can it be done? I want to get a Bitmap object (so I can do the bitmap array manipulations) but I need to get it with the DC that I have. How would this be done?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151

    Sure it can :)

    use the GetCurrentObject API
    Code:
    Private Declare Function GetCurrentObject Lib "gdi32" (ByVal hdc As Long, ByVal uObjectType As Long) As Long
    Private Const OBJ_BITMAP = 7
    
    Private Function GetBmpHandle(hdc As Long)
    
        GetBmpHandle = GetCurrentObject(hdc, OBJ_BITMAP)
        
    End Function

  3. #3

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Thanks! Do you know how to get a bitmap long into a bitmap type?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Well, yes

    once you retreive the handle of the current bitmap object in your dc, just use the GetObject API to get your BITMAP type. Your code could now look like this :

    Code:
    dim hBmp as long
    dim myBmp as BITMAP
    
        hBmp = GetCurrentObject(myHdc, OBJ_BITMAP)
        GetObject hBmp, len(myBmp), myBmp
    'You keep creatures in cages and release them to fight? That's sick!'

  5. #5

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Wow. I need to learn more API, no?
    Cheers for all the help!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Just glad I could help... damn, I think I'm getting addicted to this forum Anyway, wanna know my API secret ? http://msdn.microsoft.com/library/de..._reference.asp If you are able to deal with learning from c++ examples, all your API questions will be answered there!

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  7. #7

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    How come whenever I go to the MSDN now, it comes up with a stupid list?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Originally posted by Sastraxi
    How come whenever I go to the MSDN now, it comes up with a stupid list?
    Huh!?!... what list are you talking about?
    'You keep creatures in cages and release them to fight? That's sick!'

  9. #9

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    After clicking your link (or any link on the MSDN for that matter), it comes up with a list that contains these links (no formatting, no text formatting, just a white page with these links):
    Code:
    Welcome to the MSDN Library
    Welcome to the MSDN Library
    Component Development
    Data Access
    Development (General)
    Enterprise Development
    Graphics and Multimedia
    Messaging and Collaboration
    Mobile and Embedded Development
    .NET Development
    .NET Development
    Networking and Directory Services
    Office Solutions Development
    Security
    Security
    Setup and System Administration
    User Interface Design and Development
    User Interface Design and Development
    Visual Tools and Languages
    Web Development
    Windows Development
    XML Web Services
    XML Web Services
    MSDN Library Archive
    Weird, no?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  10. #10

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Hmm.. It's not working... It's retrieving everything correctly, and I'd look to the MSDN for advice, but as I mentioned, it's not working for me >_<. Here's what my function looks like:
    VB Code:
    1. Public Function AlphaBltFast(ByVal hDest As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrc As Long, ByVal hAlpha As Long, ByVal xSrc As Long, ByVal ySrc As Long)
    2. Dim I As Long
    3. Dim J As Long
    4.  
    5. Dim TempR As Long
    6. Dim TempG As Long
    7. Dim TempB As Long
    8.  
    9. Dim AlphaVal As Long
    10. Dim SrcVal As Long
    11. Dim DestVal As Long
    12.  
    13. Dim dBitmap As Long
    14. Dim dBMP As BITMAP
    15. Dim dPic() As Byte
    16. Dim dSA As SAFEARRAY2D
    17.  
    18. Dim sBitmap As Long
    19. Dim sBMP As BITMAP
    20. Dim sPic() As Byte
    21. Dim sSA As SAFEARRAY2D
    22.  
    23. Dim aBitmap As Long
    24. Dim aBMP As BITMAP
    25. Dim aPic() As Byte
    26. Dim aSA As SAFEARRAY2D
    27.  
    28. Dim nSrcX As Long
    29. Dim nSrcY As Long
    30.  
    31.     dBitmap = GetCurrentObject(hDest, OBJ_BITMAP)
    32.     sBitmap = GetCurrentObject(hSrc, OBJ_BITMAP)
    33.     aBitmap = GetCurrentObject(hAlpha, OBJ_BITMAP)
    34.  
    35.     GetObject dBitmap, Len(dBMP), dBMP
    36.     GetObject sBitmap, Len(sBMP), sBMP
    37.     GetObject aBitmap, Len(aBMP), aBMP
    38.  
    39.     dSA.cbElements = 1
    40.     dSA.cDims = 2
    41.     dSA.Bounds(0).lLbound = 0
    42.     dSA.Bounds(0).cElements = dBMP.bmHeight
    43.     dSA.Bounds(1).lLbound = 0
    44.     dSA.Bounds(1).cElements = dBMP.bmWidthBytes
    45.     dSA.pvData = dBMP.bmBits
    46.    
    47.     CopyMemory ByVal VarPtrArray(dPic), VarPtr(dSA), 4
    48.    
    49.     sSA.cbElements = 1
    50.     sSA.cDims = 2
    51.     sSA.Bounds(0).lLbound = 0
    52.     sSA.Bounds(0).cElements = sBMP.bmHeight
    53.     sSA.Bounds(1).lLbound = 0
    54.     sSA.Bounds(1).cElements = sBMP.bmWidthBytes
    55.     sSA.pvData = sBMP.bmBits
    56.    
    57.     CopyMemory ByVal VarPtrArray(sPic), VarPtr(sSA), 4
    58.    
    59.     aSA.cbElements = 1
    60.     aSA.cDims = 2
    61.     aSA.Bounds(0).lLbound = 0
    62.     aSA.Bounds(0).cElements = aBMP.bmHeight
    63.     aSA.Bounds(1).lLbound = 0
    64.     aSA.Bounds(1).cElements = aBMP.bmWidthBytes
    65.     aSA.pvData = aBMP.bmBits
    66.    
    67.     CopyMemory ByVal VarPtrArray(aPic), VarPtr(aSA), 4
    68.    
    69.     For J = y To y + (nHeight - 1)
    70.         For I = x * 3 To (x + nWidth) * 3 Step 3
    71.             'I - x + xSrc, J - y + ySrc
    72.            
    73.             nSrcX = ((I / 3) - x + xSrc) * 3
    74.             nSrcY = J - y + ySrc
    75.            
    76.             AlphaVal = aPic(nSrcX + 2, nSrcY)
    77.             SrcVal = sPic(nSrcY + 2, nSrcY)
    78.             DestVal = dPic(I + 2, J)
    79.            
    80.             TempR = (AlphaVal * CLng(SrcVal + 256 - DestVal)) / 256 + DestVal - AlphaVal
    81.            
    82.             AlphaVal = aPic(nSrcX + 1, nSrcY)
    83.             SrcVal = sPic(nSrcY + 1, nSrcY)
    84.             DestVal = dPic(I + 1, J)
    85.            
    86.             TempG = (AlphaVal * CLng(SrcVal + 256 - DestVal)) / 256 + DestVal - AlphaVal
    87.            
    88.             AlphaVal = aPic(nSrcX, nSrcY)
    89.             SrcVal = sPic(nSrcY, nSrcY)
    90.             DestVal = dPic(I, J)
    91.            
    92.             TempB = (AlphaVal * CLng(SrcVal + 256 - DestVal)) / 256 + DestVal - AlphaVal
    93.            
    94.             dPic(I + 2, J) = TempR
    95.             dPic(I + 1, J) = TempG
    96.             dPic(I, J) = TempB
    97.            
    98.         Next I
    99.     Next J
    100.    
    101.     CopyMemory ByVal VarPtrArray(dPic), 0&, 4
    102.     CopyMemory ByVal VarPtrArray(sPic), 0&, 4
    103.     CopyMemory ByVal VarPtrArray(aPic), 0&, 4
    104.    
    105. End Function
    I know there's still lots to be done but it would be functional, for now. But it isn't: the arrays are empty (0, 0 is index out of bounds). Do you, or the MSDN, have anything to say to this?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  11. #11
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Hum... ok, by reading your code i didn't see something wrong at first glance so i copied it (and btw... is there a way to copy correctly code posted on this board?) and try to use your function. And something very strange is happenig... after the getobject calls, every member for all the bitmap variable are set correctly... Every members exepted for the bmbits wich is always 0 so no pointer to the data!? Now, unless my computer is in worst shape than i tought and that does this only for me , This would be why you get the out of bound error since copymemory will fail.

    So now i'm speechless... i've seen exemple using this technique to change the pixels from a bitamp and even used it myselt with success. So why is it not working now... i really don't know (that's why i brought up the computer being in bad shape thing... i know i've already done this... but now it doesn't work!!! I just don't get it.)

    so now i'm gonna go to sleep... i'll probably see things more clearly tomorow. If you get a chance, try to see what are the values for .bmbits when you run your code to see if you have the same problem.
    'You keep creatures in cages and release them to fight? That's sick!'

  12. #12

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Did I not mention that? D'oh. That's what problem I'm having, that the bmBits are 0, so that it doesn't work. I was thinking it had to do with the fact that the pictureboxes I'm getting the DCs from are autoredraw, but I'm not sure.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  13. #13
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Originally posted by Sastraxi
    Did I not mention that? D'oh. That's what problem I'm having, that the bmBits are 0, so that it doesn't work. I was thinking it had to do with the fact that the pictureboxes I'm getting the DCs from are autoredraw, but I'm not sure.
    Well... if that is because of the autoredraw, I would be even more confuse... you see, i've tried almost any way I know of putting a darn bitmap in a dc (by using loadimage for the bitmap and then selecting it in a dc, in a memory dc, creating a bimap with createcompatiblebitmap. I've tried using picutre.image in getobject etc... ) but always to the same result, bmbits is set to 0 all the f'n (sorry it slipped ) time.

    Man! this is suppose to work... I guess we will need help from others to for this one.

    I have to go to work soon, but i'll try to work something again when i come back.

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  14. #14
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Just posted this problem in the API forum... perhaps someone will be able to help with the getobject problem. Because as i've said before, i'm pretty sure the rest of your code is good.

    BTW, good luck with the alphablend, i've tried implementing it once... was pretty cool, but awfully slow with big pictures. If you manage to do it fast, please send me the code

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  15. #15
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151

    update

    I've found out to get the pointer to bits in the BITMAP variable set to something else than 0. if you use picturebox.picture in the getobject call, it will work. But i still don't know why it doesn't work with a bitmap object thought...
    'You keep creatures in cages and release them to fight? That's sick!'

  16. #16
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151

    do as i say... not what i do

    Well, i'm the one who talked about the msdn being a great source for api info... and I didn't even when to check to description for the getobject function. Here is what i've found out:
    If hgdiobj is a handle to a bitmap created by calling CreateDIBSection, and the specified buffer is large enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap's bit values.

    If hgdiobj is a handle to a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function.
    this would also clarify for me the diference between the .picture and .image of a picturebox... .picture seems to be a dib (since it works with getobject) and .image is a ddb.

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  17. #17

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Excellent, my friend. Excellent, excellent, excellent, excellent. I'm really glad you've helped me with all this!

    PS. The Get/SetPixel only takes 0.003 seconds, on average, to do a 16x16 alphablend. It takes a bit longer for a 20x25 (0.01 s) but it's pretty sufficient for what I'm using it for. I just wanted to be able to do it just this bit faster, hehe
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  18. #18

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I'm just about to try it, BTW. Just had to get out my enthusiasm, as it's been a long, boring, painful day of tests at school :/
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  19. #19

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Talking Dingdingdingding!

    We have a winner....

    GetDIBits is awesome. This works completely, 100% now. Excellent, man, excellent!
    VB Code:
    1. Public Function Morph2D(X As Long, Y As Long, NumRow As Long) As Long
    2.     Morph2D = (Y - 1) * NumRow + X
    3. End Function
    4. Public Function AlphaBltFast(ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal hAlphaDC As Long, ByVal xSrc As Long, ByVal ySrc As Long)
    5. Dim I As Long
    6. Dim J As Long
    7.  
    8. Dim TempR As Long
    9. Dim TempG As Long
    10. Dim TempB As Long
    11.  
    12. Dim AlphaVal As mRGB
    13. Dim SrcVal As mRGB
    14. Dim DestVal As mRGB
    15.  
    16. Dim dBitmap As Long
    17. Dim dBMP As BITMAP
    18. Dim dPic() As mRGB
    19. Dim dMem As BITMAPINFO
    20.  
    21. Dim sBitmap As Long
    22. Dim sBMP As BITMAP
    23. Dim sPic() As mRGB
    24. Dim sMem As BITMAPINFO
    25.  
    26. Dim aBitmap As Long
    27. Dim aBMP As BITMAP
    28. Dim aPic() As mRGB
    29. Dim aMem As BITMAPINFO
    30.  
    31.     dBitmap = GetCurrentObject(hDestDC, OBJ_BITMAP)
    32.     sBitmap = GetCurrentObject(hSrcDC, OBJ_BITMAP)
    33.     aBitmap = GetCurrentObject(hAlphaDC, OBJ_BITMAP)
    34.  
    35.     GetObjectAPI dBitmap, Len(dBMP), dBMP
    36.     GetObjectAPI sBitmap, Len(sBMP), sBMP
    37.     GetObjectAPI aBitmap, Len(aBMP), aBMP
    38.    
    39.     With dMem.bmiHeader
    40.         .biBitCount = 32
    41.         .biCompression = BI_RGB
    42.         .biPlanes = 1
    43.         .biSize = Len(dMem.bmiHeader)
    44.         .biWidth = dBMP.bmWidth
    45.         .biHeight = dBMP.bmHeight
    46.         ReDim Preserve dPic(0 To (.biWidth * .biHeight) - 1) As mRGB
    47.     End With
    48.      
    49.     GetDIBits hDestDC, dBitmap, 0, dBMP.bmHeight, dPic(0), dMem, DIB_RGB_COLORS
    50.    
    51.     With sMem.bmiHeader
    52.         .biBitCount = 32
    53.         .biCompression = BI_RGB
    54.         .biPlanes = 1
    55.         .biSize = Len(sMem.bmiHeader)
    56.         .biWidth = sBMP.bmWidth
    57.         .biHeight = sBMP.bmHeight
    58.         ReDim Preserve sPic(0 To (.biWidth * .biHeight) - 1) As mRGB
    59.     End With
    60.    
    61.     GetDIBits hSrcDC, sBitmap, 0, sBMP.bmHeight, sPic(0), sMem, DIB_RGB_COLORS
    62.    
    63.     With aMem.bmiHeader
    64.         .biBitCount = 32
    65.         .biCompression = BI_RGB
    66.         .biPlanes = 1
    67.         .biSize = Len(aMem.bmiHeader)
    68.         .biWidth = aBMP.bmWidth
    69.         .biHeight = aBMP.bmHeight
    70.         ReDim Preserve aPic(0 To (.biWidth * .biHeight) - 1) As mRGB
    71.     End With
    72.    
    73.     GetDIBits hAlphaDC, aBitmap, 0, aBMP.bmHeight, aPic(0), aMem, DIB_RGB_COLORS
    74.    
    75.     For J = Y To Y + (nHeight - 1)
    76.         For I = X To X + (nWidth - 1)
    77.            
    78.             DestVal = dPic(Morph2D(I, dBMP.bmHeight - J, dBMP.bmWidth)) 'dColour.L = GetPixel(hDestDC, I, J)
    79.             SrcVal = sPic(Morph2D(I - X + xSrc, sBMP.bmHeight - (J - Y + ySrc), sBMP.bmWidth)) 'sColour.L = GetPixel(hSrcDC, I - x + xSrc, J - y + ySrc)
    80.             AlphaVal = aPic(Morph2D(I - X + xSrc, aBMP.bmHeight - (J - Y + ySrc), aBMP.bmWidth)) 'aColour.L = GetPixel(hAlphaDC, I - x + xSrc, J - y + ySrc)
    81.            
    82.             AlphaVal.R = 255 - AlphaVal.R
    83.             AlphaVal.G = 255 - AlphaVal.G
    84.             AlphaVal.B = 255 - AlphaVal.B
    85.            
    86.             TempR = (AlphaVal.R * CLng(SrcVal.R + 256 - DestVal.R)) / 256 + DestVal.R - AlphaVal.R
    87.             TempG = (AlphaVal.G * CLng(SrcVal.G + 256 - DestVal.G)) / 256 + DestVal.G - AlphaVal.G
    88.             TempB = (AlphaVal.B * CLng(SrcVal.B + 256 - DestVal.B)) / 256 + DestVal.B - AlphaVal.B
    89.            
    90.             With dPic(Morph2D(I, dBMP.bmHeight - J, dBMP.bmWidth))
    91.                 .R = TempR
    92.                 .G = TempG
    93.                 .B = TempB
    94.             End With
    95.            
    96.         Next I
    97.     Next J
    98.    
    99.     SetDIBits hDestDC, dBitmap, 0, dBMP.bmHeight, dPic(0), dMem, DIB_RGB_COLORS
    100.    
    101. End Function
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  20. #20
    Addicted Member
    Join Date
    Oct 2002
    Location
    Somewhere out in space
    Posts
    151
    Great man! I'm happy to see you have succeded. Beside it was a pleasure helping you... heck, it made me learn new stuff too . stuff like the GDI can be a real pain in the ... sometime But hey, this was fun! Finally, I have a better understand of how to use the copy memory trick.

    - Valkan
    'You keep creatures in cages and release them to fight? That's sick!'

  21. #21

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I think I have a complete understanding of it, you can get memory out in any format, which is both the beauty and the failing of it

    It's still pretty slow though.... but it's faster for larger images. I'm going to compile it to see how fast it goes.

    [EDIT] Good news Instead of 0.17s (IDE), it runs at 0.08s (compiled). More than two-times speed increase, which is nice.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  22. #22
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    Sastraxi, I would like to see your subs in action. I've been programming vb for about 4 years. I made my own very easy to use blit subs. I still don't know what an hDC is, and Bitblt looks like a heap of technical gibberish (I realize that it copies data extremely rapidly). Mostly it's the hDC and 7 other parameters that go with it that make it look more like "loose wires" than a "control panel". That's why I say I would like to see you post an example of your subs in action.

  23. #23

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Do you mind running compiled code? The reason I'm hesitant to post the actual code is that I've used some pretty bad coding practices to get this test done...

    If you don't trust me, I'll post it, but I hope you do
    Attached Files Attached Files
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  24. #24

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    And here's a screenshot Office, Apache, and EAC icons probably won't show up, I have their paths hard-coded. And if you don't have Winamp, it won't show up either. But IE should...
    Attached Images Attached Images  
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  25. #25
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Sastraxi
    Do you mind running compiled code? The reason I'm hesitant to post the actual code is that I've used some pretty bad coding practices to get this test done...

    If you don't trust me, I'll post it, but I hope you do
    I got an error message: "failed to delete C:\" What does that mean?

    That's pretty cool, though. What are you planning to do with it/use it for?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  26. #26
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    intresting.. at first click I got .11s, and second and later i was getting .06 and even .00 (1ghz duron). I got "subscript out of" after clicking about 20 times.

    'Then don't click 20 times."

  27. #27
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Dafi: I got the same error message after clicking about 50 times.

    The first result was 11, and after that it used 1,2,3 (Athlon 1,9+)...I have WinAmp, but it didn't show. But IE did).

  28. #28
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    took 0.02 for me..

    i would like to have the code.....can you attach it please
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  29. #29

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Okay, but let me clean it up first. There's definately some stuff that's draining the memory like crazy, I'll do a test.

    [EDIT]I've found the problem, which lies in the SmoothIconBlt function. I think it's the memory DCs I'm creating, let me check it and I'll post![/EDIT]
    Last edited by Sastraxi; Nov 16th, 2002 at 01:25 PM.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  30. #30

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    And I'll put in a little special effect for you guys, enumerating the real quicklaunch icons and sticking the first 5 in
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  31. #31

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Okay, DON'T run this program anymore, lol. It has a huge memory leak that eventually destroys all of your memory... lol. Anyway, you might notice that the subscript out of range is in a horrible, Win16-emulation bold font. That shows real trouble, so, like I said, don't use it until I figure out what's wrong with it
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  32. #32
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    This was very tricky to find: in win98 that I use, when you double-click to start a file, a mouseup event occurs. It was causing an error in one of my projects.

  33. #33

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Here's the code, tell me if you're able to fix the memory leaks...
    Attached Files Attached Files
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  34. #34
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    thanks alot! that will be really useful for me!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  35. #35

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yeah, use it an any way you please I just hope you tell me about anything you use it in
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  36. #36

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Okay, found out how to fix the Memory Leak in SmoothIconBlt.

    New/Changed Code:
    VB Code:
    1. Public Function DestroyDC(ByVal DC As Long, ByVal hOldBitmap As Long) As Long
    2.     DeleteObject SelectObject(DC, hOldBitmap)
    3.     ReleaseDC GetDesktopWindow, DC
    4.     DeleteDC DC
    5. End Function
    6.  
    7. Public Function CreateMyDC(WidthInPixels As Long, HeightInPixels As Long, ByRef hOldBitmap As Long, Optional CompatibleDC As Long) As Long
    8. '## NOTE THIS FUNCTION IS FROM SOMEONE ON VBW. I CAN'T REMEMBER THEIR NAME SO IF YOU DO, PLEASE
    9. '## TELL ME SO APPROPRIATE THANKS CAN BE GIVEN
    10.  
    11. Dim hCompatibleDC As Long
    12. Dim hMemDC As Long
    13.  
    14. 'check there is a compatible DC
    15. If CompatibleDC = 0 Then
    16.  
    17.     hCompatibleDC = GetDC(GetDesktopWindow)
    18.  
    19. Else
    20.  
    21.     hCompatibleDC = CompatibleDC
    22.  
    23. End If
    24.  
    25. 'CreateDC
    26. hMemDC = CreateCompatibleDC(hCompatibleDC)
    27.  
    28. 'Get Default Bitmap Out of DC and Delete it and Put New one in.
    29.  
    30. hOldBitmap = SelectObject(hMemDC, CreateCompatibleBitmap(hCompatibleDC, WidthInPixels, HeightInPixels))
    31.  
    32. 'and We're Done
    33. CreateMyDC = hMemDC
    34.  
    35. End Function
    36. Public Function SmoothIconBlt(ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hExeSrc As String, ByVal hIndex As Long, ByVal hSmallIcon As Boolean, Optional SmoothValue As Long = smoothval) As Long
    37. Dim hSmIco As Long
    38. Dim hLgIco As Long
    39. Dim hResult As Long
    40.  
    41. Dim hImgDC As Long
    42. Dim hMaskDC As Long
    43. Dim hTempDC As Long
    44.  
    45. Dim hImgOld As Long
    46. Dim hMaskOld As Long
    47. Dim hTempOld As Long
    48.  
    49.     hImgDC = CreateMyDC(16, 16, hImgOld)
    50.     hMaskDC = CreateMyDC(16, 16, hMaskOld)
    51.     hTempDC = CreateMyDC(16, 16, hTempOld)
    52.    
    53.     Call ExtractIconEx(hExeSrc, hIndex, hLgIco, hSmIco, 1)
    54.     If hSmallIcon Then
    55.         hResult = DrawIconEx(hMaskDC, 0, 0, hSmIco, 16, 16, 0, 0, DI_MASK)
    56.         hResult = DrawIconEx(hImgDC, 0, 0, hSmIco, 16, 16, 0, 0, DI_IMAGE)
    57.         SmoothMaskFast hTempDC, hMaskDC, 0, 0, 16, 16, SmoothValue
    58.         AlphaBltFast hDestDC, X, Y, 16, 16, hImgDC, hMaskDC, 0, 0
    59.     Else
    60.         hResult = DrawIconEx(hMaskDC, 0, 0, hLgIco, 32, 32, 0, 0, DI_MASK)
    61.         hResult = DrawIconEx(hImgDC, 0, 0, hLgIco, 32, 32, 0, 0, DI_IMAGE)
    62.         SmoothMaskFast hTempDC, hMaskDC, 0, 0, 32, 32, SmoothValue * 4
    63.         AlphaBltFast hDestDC, X, Y, 32, 32, hImgDC, hMaskDC, 0, 0
    64.     End If
    65.     DestroyIcon hSmIco: DestroyIcon hLgIco
    66.        
    67.     DestroyDC hImgDC, hImgOld
    68.     DestroyDC hMaskDC, hMaskOld
    69.     DestroyDC hTempDC, hTempOld
    70.    
    71. End Function
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  37. #37
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    there gotta be some leaks left, cuz my comp gets really slow after using that program for a while, and i've got the error "cant create autoredraw image" or whatever it says...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  38. #38

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Index Out of Bounds for SmoothMaskFast, is that your error? Yeah, I'm working on it, it doesn't seem to be fixed [yet]. There is also a MASSIVE memory leak in the TextBlt function (which is called by the CropTextBlt function, so both of them have leaks). If you can fix these, it'd be great.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  39. #39
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    no, the error message i got was "cant create autoredraw image"...

    sorry, but im not so goot at there stuff so im not sure that i can be to any help...

    but if i find anything, i'll let you know!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  40. #40

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    What function did you get the error in?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Page 1 of 2 12 LastLast

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