Results 1 to 6 of 6

Thread: SetLayeredWindowAttributes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Wisconsin
    Posts
    64

    SetLayeredWindowAttributes

    I am trying to test the SetLayeredWindowAttributes API. My declare is:
    VB Code:
    1. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    but when I try to call the function, I get an error that says:
    "Can't find DLL entry point SetLayeredWindowAttributes in user32"
    When looking through user32.dll with Microsoft's Depends Viewer and AXE (hex editor), I can't find SetLayeredWindowAttributes anywhere. Is it declared in another dll or is it just non-existent (I am running Win ME)? I have tried looking through kernel32.dll and gdi32.dll (with Depends Viewer and AXE) and can't find it in either of those.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    SetLayeredWindowAttributes is not supported in Win9x or ME.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Wisconsin
    Posts
    64
    Is there any function that I can use to model SetLayeredWindowAttributes?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Take a look at the SetLayOut API. According to the API viewer, this requires Win98 or later (it doesn't say anything about ME).

    What are you trying to do? Maybe there are other ways.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Wisconsin
    Posts
    64
    I was just trying to test the SetLayeredWindowAttributes API and window style WS_EX_TRANSPARENT to see if they would work better with the program described below.
    I am trying to make a program that uses bmp's to specify the window region. You can specify the transparent color and my program is supposed to draw the picture, find the non-transparent pixels, create a region from them and set the form to that region; but when I run it, not all of the transparent pixels get cut out all the time (it works fine some times, but not others). Also, it seems that no matter what I do, I can't get my program to delete all the regions and everything else I create because it seems to get slower the more times I run it.
    For the pictures, I simply set the form's picture property and run it through a routine that is supposed to find all the non-transparent pixels of the picture and return their region.
    VB Code:
    1. '**Prior to the call:**
    2. Set Form1.Picture = LoadPicture(Path)
    3. 'Use a "dummy" picturebox to pass to the transparency function
    4. Set Picture1.Picture = Form1.Picture
    5. newFormRegion = MakeTransPic(Picture1) 'Ignore transColor to use the color of the first pixel
    6. SetWindowRgn Form1.hWnd, newFormRegion, True
    7.  
    8. '**Transparency function**
    9. Private Function MakeTransPic(PicToTrans As PictureBox, Optional transColor) As Long
    10. Dim retRgn&, curRgn&, allRgn&
    11. Dim startPt As POINTAPI, endPt As POINTAPI
    12. Dim curPt As POINTAPI, makeRgn As Boolean
    13.  
    14. PicToTrans.ScaleMode = vbPixels
    15. PicToTrans.AutoSize = True
    16. PicToTrans.AutoRedraw = True
    17. PicToTrans.BorderStyle = vbBSNone
    18.  
    19. If IsMissing(transColor) Or (transColor < 0 Or transColor > RGB(255, 255, 255)) Then transColor = PicToTrans.Point(0, 0)
    20. retRgn = CreateRectRgn(0, 0, 0, 0)
    21. allRgn = CreateRectRgn(PicToTrans.ScaleLeft, PicToTrans.ScaleTop, PicToTrans.ScaleWidth, PicToTrans.ScaleHeight)
    22. startPt.X = -1
    23. endPt.X = -1
    24. startPt.Y = -1
    25. endPt.Y = -1
    26. makeRgn = False
    27.  
    28. For curPt.Y = 0 To PicToTrans.ScaleHeight
    29.     For curPt.X = 0 To PicToTrans.ScaleWidth
    30.         If PicToTrans.Point(curPt.X, curPt.Y) = transColor Then
    31.             'Transparent pixel
    32.             If startPt.X = -1 Then
    33.                 startPt.X = curPt.X
    34.                 startPt.Y = curPt.Y
    35.                 makeRgn = True
    36.             End If
    37.         Else
    38.             'Non-transparent pixel
    39.             If makeRgn Then
    40.                 endPt.X = curPt.X
    41.                 endPt.Y = curPt.Y
    42.                 If endPt.X < 0 Then
    43.                     endPt.X = 0
    44.                     endPt.Y = endPt.Y - 1
    45.                 End If
    46.                 curRgn = CreateRectRgn(startPt.X, startPt.Y, endPt.X, endPt.Y + 1)
    47.                 CombineRgn retRgn, retRgn, curRgn, RGN_OR
    48.                 DeleteObject curRgn
    49.                 startPt.X = -1
    50.                 startPt.Y = -1
    51.                 endPt.X = -1
    52.                 endPt.Y = -1
    53.                 makeRgn = False
    54.             End If
    55.         End If
    56.     Next curPt.X
    57. Next curPt.Y
    58. 'The following line turns retRgn into the non-transparent region
    59. 'Without this line, it was returning the transparent region
    60. CombineRgn retRgn, retRgn, allRgn, RGN_XOR
    61. MakeTransPic = retRgn
    62. DeleteObject retRgn
    63. DeleteObject allRgn
    64. End Function
    By the way, are you using API Guide from AllApi.net?
    Last edited by lnelsestuen; Mar 12th, 2002 at 12:49 AM.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    By the way, are you using API Guide from AllApi.net?
    Yes...an invaluable tool!

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