|
-
Mar 9th, 2002, 02:20 PM
#1
Thread Starter
Lively Member
SetLayeredWindowAttributes
I am trying to test the SetLayeredWindowAttributes API. My declare is:
VB Code:
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.
-
Mar 9th, 2002, 04:21 PM
#2
SetLayeredWindowAttributes is not supported in Win9x or ME.
-
Mar 9th, 2002, 08:59 PM
#3
Thread Starter
Lively Member
Is there any function that I can use to model SetLayeredWindowAttributes?
-
Mar 10th, 2002, 07:47 AM
#4
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.
-
Mar 10th, 2002, 11:54 AM
#5
Thread Starter
Lively Member
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:
'**Prior to the call:**
Set Form1.Picture = LoadPicture(Path)
'Use a "dummy" picturebox to pass to the transparency function
Set Picture1.Picture = Form1.Picture
newFormRegion = MakeTransPic(Picture1) 'Ignore transColor to use the color of the first pixel
SetWindowRgn Form1.hWnd, newFormRegion, True
'**Transparency function**
Private Function MakeTransPic(PicToTrans As PictureBox, Optional transColor) As Long
Dim retRgn&, curRgn&, allRgn&
Dim startPt As POINTAPI, endPt As POINTAPI
Dim curPt As POINTAPI, makeRgn As Boolean
PicToTrans.ScaleMode = vbPixels
PicToTrans.AutoSize = True
PicToTrans.AutoRedraw = True
PicToTrans.BorderStyle = vbBSNone
If IsMissing(transColor) Or (transColor < 0 Or transColor > RGB(255, 255, 255)) Then transColor = PicToTrans.Point(0, 0)
retRgn = CreateRectRgn(0, 0, 0, 0)
allRgn = CreateRectRgn(PicToTrans.ScaleLeft, PicToTrans.ScaleTop, PicToTrans.ScaleWidth, PicToTrans.ScaleHeight)
startPt.X = -1
endPt.X = -1
startPt.Y = -1
endPt.Y = -1
makeRgn = False
For curPt.Y = 0 To PicToTrans.ScaleHeight
For curPt.X = 0 To PicToTrans.ScaleWidth
If PicToTrans.Point(curPt.X, curPt.Y) = transColor Then
'Transparent pixel
If startPt.X = -1 Then
startPt.X = curPt.X
startPt.Y = curPt.Y
makeRgn = True
End If
Else
'Non-transparent pixel
If makeRgn Then
endPt.X = curPt.X
endPt.Y = curPt.Y
If endPt.X < 0 Then
endPt.X = 0
endPt.Y = endPt.Y - 1
End If
curRgn = CreateRectRgn(startPt.X, startPt.Y, endPt.X, endPt.Y + 1)
CombineRgn retRgn, retRgn, curRgn, RGN_OR
DeleteObject curRgn
startPt.X = -1
startPt.Y = -1
endPt.X = -1
endPt.Y = -1
makeRgn = False
End If
End If
Next curPt.X
Next curPt.Y
'The following line turns retRgn into the non-transparent region
'Without this line, it was returning the transparent region
CombineRgn retRgn, retRgn, allRgn, RGN_XOR
MakeTransPic = retRgn
DeleteObject retRgn
DeleteObject allRgn
End Function
By the way, are you using API Guide from AllApi.net?
Last edited by lnelsestuen; Mar 12th, 2002 at 12:49 AM.
-
Mar 10th, 2002, 07:49 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|