Results 1 to 9 of 9

Thread: Expert in Regions? Oooh Fun!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82

    Angry 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?

  2. #2
    Hyperactive Member TiPeRa's Avatar
    Join Date
    Apr 2001
    Location
    In between
    Posts
    464
    I am not sure but:
    VB Code:
    1. Function CreateWindow() As Long
    2.     Dim RoundRgn As Long, PolyRgn As Long
    3.     Dim CombRgn As Long
    4.     Dim Vertices(2) As POINT_TYPE
    5.     RoundRgn = CreateRoundRectRgn(20, 20, 150, 150, 10, 10)
    6.     Vertices(0).x = 45: Vertices(0).y = 150
    7.     Vertices(1).x = 85: Vertices(1).y = 150
    8.     Vertices(2).x = 200: Vertices(2).y = 200
    9.     PolyRgn = CreatePolygonRgn(Vertices(0), 3, WINDING)
    10.     [b]CombRgn[/b] = CreateRectRgn(0, 0, 0, 0)
    11.     [b]ret[/b] = CombineRgn([b]CombRgn[/b], RoundRgn, PolyRgn, RGN_AND)
    12.     CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
    13.     DeleteObject RoundRgn
    14.     DeleteObject PolyRgn
    15.     DeleteObject CombRgn
    16. 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.)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82
    Nice catch but still no go...now the form just dissappears!

  4. #4
    Hyperactive Member TiPeRa's Avatar
    Join Date
    Apr 2001
    Location
    In between
    Posts
    464
    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.)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82
    Thanks for your help...CombineRgn returned Null. Thanks

  6. #6
    Hyperactive Member TiPeRa's Avatar
    Join Date
    Apr 2001
    Location
    In between
    Posts
    464
    This works for me:
    VB Code:
    1. Private Type POINTAPI
    2.     x As Long
    3.     y As Long
    4. End Type
    5. Function CreateWindow() As Long
    6.     Dim RoundRgn As Long, PolyRgn As Long
    7.     Dim CombRgn As Long
    8.     Dim Vertices(2) As [b]POINTAPI[/b]
    9.     RoundRgn = CreateRoundRectRgn(20, 20, [b]250, 250[/b], 10, 10)
    10.     Vertices(0).x = 45: Vertices(0).y = 150
    11.     Vertices(1).x = 85: Vertices(1).y = 150
    12.     Vertices(2).x = 200: Vertices(2).y = 200
    13.     PolyRgn = CreatePolygonRgn(Vertices(0), 3, WINDING)
    14.     CombRgn = CreateRectRgn(0, 0, 0, 0)
    15.     ret = CombineRgn(CombRgn, RoundRgn, PolyRgn, RGN_AND)
    16.     CreateWindow = SetWindowRgn(Form1.hWnd, CombRgn, True)
    17.     DeleteObject RoundRgn
    18.     DeleteObject PolyRgn
    19.     DeleteObject CombRgn
    20. 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.)

  7. #7
    Hyperactive Member TiPeRa's Avatar
    Join Date
    Apr 2001
    Location
    In between
    Posts
    464
    Are you trying to make speech bubble? If yes you need to use:
    VB Code:
    1. Private Const RGN_OR As Long = 2
    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.)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82
    Thanks. Everythings cool now. Realized my mistake.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    norcross, ga, USA
    Posts
    82
    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
  •  



Click Here to Expand Forum to Full Width