Jump to content

Recommended Posts

I am developing an application with some custom graphics. I found this function here. it works perfectly but I was wondering; is there a way to round only the top or bottom two corners?


Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
   $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
         Return 0
      Return 0
EndFunc  ;==>_GuiRoundCorners
Link to post
Share on other sites

Example for _WinAPI_CreateRoundRectRgn() in helpfile might be useful.
You can create two regions. First one would have height equals total window height reduced by the radius of corners. Second one would be rounded rectangular region whose height equals twice the radius.
If something is unclear ask.

Link to post
Share on other sites

Yes, I understand _WinAPI_CreateRoundRectRgn() does the same thing as :

DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)

But that doesnt answer my question, it adjusts the region as a rectangle meaning it will always adjust for 4 corners. Is there a system used for point to point corners or single corners?

Link to post
Share on other sites

Amazing, got my desired outcome with:


Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x2, $i_y2, $i_x3, $i_y3)
    Local $XS_pos, $XS_reta, $XS_retb, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_reta = _WinAPI_CreateRoundRectRgn ( 0, 0, $XS_pos[2], $XS_pos[3]-30, $i_x3, $i_y3 )
    $XS_retb = _WinAPI_CreateRectRgn (0, $XS_pos[2]-$XS_pos[1]/2, $XS_pos[2], $XS_pos[3] )
    $XS_retc = _WinAPI_CombineRgn ( $XS_reta, $XS_reta, $XS_retb, $RGN_OR  )
    _WinAPI_SetWindowRgn($h_win, $XS_reta)
EndFunc   ;==>_GuiRoundCorners


Thank you for your assistance!

Edited by CodeTinkerer
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...