|
-
Mar 1st, 2002, 05:54 PM
#1
Thread Starter
Lively Member
Expert in Regions? Oooh Fun!
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?
-
Mar 1st, 2002, 06:23 PM
#2
Hyperactive Member
I am not sure but:
VB Code:
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)
[b]CombRgn[/b] = CreateRectRgn(0, 0, 0, 0)
[b]ret[/b] = CombineRgn([b]CombRgn[/b], RoundRgn, PolyRgn, RGN_AND)
CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
DeleteObject RoundRgn
DeleteObject PolyRgn
DeleteObject CombRgn
End Function
W#Ć€V€® W¦|| ߀ W¦|| ߀, ÄÑÐ †#€®€ ¦§ ÑÖ†#¦Ñ6 ¥Öµ ©ÄÑ ÐÖ ÄßÖµ† ¦†, §Ö §¦† ßÄ©K, ®€|ÄX ÄÑÐ |€† ¦† #ÄÞÞ€Ñ.
(Whatever will be will be, and there is nothing you can do about it, so sit back, relax and let it happen.)
-
Mar 1st, 2002, 06:54 PM
#3
Thread Starter
Lively Member
Nice catch but still no go...now the form just dissappears!
-
Mar 1st, 2002, 07:05 PM
#4
Hyperactive Member
Well then you need to fiddle with your regions What is ret returning? What shape are you going for?
W#Ć€V€® W¦|| ߀ W¦|| ߀, ÄÑÐ †#€®€ ¦§ ÑÖ†#¦Ñ6 ¥Öµ ©ÄÑ ÐÖ ÄßÖµ† ¦†, §Ö §¦† ßÄ©K, ®€|ÄX ÄÑÐ |€† ¦† #ÄÞÞ€Ñ.
(Whatever will be will be, and there is nothing you can do about it, so sit back, relax and let it happen.)
-
Mar 1st, 2002, 07:48 PM
#5
Thread Starter
Lively Member
Thanks for your help...CombineRgn returned Null. Thanks
-
Mar 1st, 2002, 08:06 PM
#6
Hyperactive Member
This works for me:
VB Code:
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 [b]POINTAPI[/b]
RoundRgn = CreateRoundRectRgn(20, 20, [b]250, 250[/b], 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.
W#Ć€V€® W¦|| ߀ W¦|| ߀, ÄÑÐ †#€®€ ¦§ ÑÖ†#¦Ñ6 ¥Öµ ©ÄÑ ÐÖ ÄßÖµ† ¦†, §Ö §¦† ßÄ©K, ®€|ÄX ÄÑÐ |€† ¦† #ÄÞÞ€Ñ.
(Whatever will be will be, and there is nothing you can do about it, so sit back, relax and let it happen.)
-
Mar 1st, 2002, 08:23 PM
#7
Hyperactive Member
Are you trying to make speech bubble? If yes you need to use:
VB Code:
Private Const RGN_OR As Long = 2
ret = CombineRgn(CombRgn, RoundRgn, PolyRgn, [b]RGN_OR[/b])
W#Ć€V€® W¦|| ߀ W¦|| ߀, ÄÑÐ †#€®€ ¦§ ÑÖ†#¦Ñ6 ¥Öµ ©ÄÑ ÐÖ ÄßÖµ† ¦†, §Ö §¦† ßÄ©K, ®€|ÄX ÄÑÐ |€† ¦† #ÄÞÞ€Ñ.
(Whatever will be will be, and there is nothing you can do about it, so sit back, relax and let it happen.)
-
Mar 1st, 2002, 08:26 PM
#8
Thread Starter
Lively Member
Thanks. Everythings cool now. Realized my mistake.
-
Mar 1st, 2002, 08:32 PM
#9
Thread Starter
Lively Member
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
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
|