Click to See Complete Forum and Search --> : Expert in Regions? Oooh Fun!
cvaden
Mar 1st, 2002, 04:54 PM
I created a complex region using createroundrectrgn and createpolygonrgn and then used combinergn to merge the two regions. Now I want to SetWindowRgn but it keeps returning 0.
I know that regions can be complicated, I might just be missing something.
Here is my Function....
Function CreateWindow() As Long
Dim RoundRgn As Long, PolyRgn As Long
Dim CombRgn As Long, NullRgn As Long
Dim Vertices(2) As POINT_TYPE
RoundRgn = CreateRoundRectRgn(20, 20, 150, 150, 10, 10)
Vertices(0).x = 45: Vertices(0).y = 150
Vertices(1).x = 85: Vertices(1).y = 150
Vertices(2).x = 200: Vertices(2).y = 200
PolyRgn = CreatePolygonRgn(Vertices(0), 3, WINDING)
NullRgn = CreateRectRgn(0, 0, 0, 0)
CombRgn = CombineRgn(NullRgn, RoundRgn, PolyRgn, RGN_AND)
CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
DeleteObject RoundRgn
DeleteObject PolyRgn
DeleteObject CombRgn
DeleteObject NullRgn
End Function
Any ideas?
TiPeRa
Mar 1st, 2002, 05:23 PM
I am not sure but:
Function CreateWindow() As Long
Dim RoundRgn As Long, PolyRgn As Long
Dim CombRgn As Long
Dim Vertices(2) As POINT_TYPE
RoundRgn = CreateRoundRectRgn(20, 20, 150, 150, 10, 10)
Vertices(0).x = 45: Vertices(0).y = 150
Vertices(1).x = 85: Vertices(1).y = 150
Vertices(2).x = 200: Vertices(2).y = 200
PolyRgn = CreatePolygonRgn(Vertices(0), 3, WINDING)
CombRgn = CreateRectRgn(0, 0, 0, 0)
ret = CombineRgn(CombRgn, RoundRgn, PolyRgn, RGN_AND)
CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
DeleteObject RoundRgn
DeleteObject PolyRgn
DeleteObject CombRgn
End Function
cvaden
Mar 1st, 2002, 05:54 PM
Nice catch but still no go...now the form just dissappears!
TiPeRa
Mar 1st, 2002, 06:05 PM
Well then you need to fiddle with your regions :eek: What is ret returning? What shape are you going for?
cvaden
Mar 1st, 2002, 06:48 PM
Thanks for your help...CombineRgn returned Null. Thanks
TiPeRa
Mar 1st, 2002, 07:06 PM
This works for me:
Private Type POINTAPI
x As Long
y As Long
End Type
Function CreateWindow() As Long
Dim RoundRgn As Long, PolyRgn As Long
Dim CombRgn As Long
Dim Vertices(2) As POINTAPI
RoundRgn = CreateRoundRectRgn(20, 20, 250, 250, 10, 10)
Vertices(0).x = 45: Vertices(0).y = 150
Vertices(1).x = 85: Vertices(1).y = 150
Vertices(2).x = 200: Vertices(2).y = 200
PolyRgn = CreatePolygonRgn(Vertices(0), 3, WINDING)
CombRgn = CreateRectRgn(0, 0, 0, 0)
ret = CombineRgn(CombRgn, RoundRgn, PolyRgn, RGN_AND)
CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
DeleteObject RoundRgn
DeleteObject PolyRgn
DeleteObject CombRgn
End Function
I have change the values in bold because the 2 regions you originally created weren't overlapping. I am using POINTAPI because I could not find the declaration for the type you were using although it is probably exactly the same.
TiPeRa
Mar 1st, 2002, 07:23 PM
Are you trying to make speech bubble? If yes you need to use:
Private Const RGN_OR As Long = 2
ret = CombineRgn(CombRgn, RoundRgn, PolyRgn, RGN_OR)
cvaden
Mar 1st, 2002, 07:26 PM
Thanks. Everythings cool now. Realized my mistake.
cvaden
Mar 1st, 2002, 07:32 PM
Actually, do you know if you can change the color of a region before you apply it to a form. Like blue or red or something. I tried using fillrgn but couldn't see a change.
C
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.