Jump to content

Rounding corners of a window function


Recommended Posts

; Round corners function
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3); thanks gafrost
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0]Then
        $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc  ;==>_GuiRoundCorners

Is there any way I cna modify this code to make it round less area of the window. I found that when I compared it to a windows xp window this function took of more of the corner of the window and I would like to modify it so it will round less.

I don't know where to re-code it to my preferences though. :|

Link to comment
Share on other sites

I just tried it on one of my gui's and it worked great, it rounds however much you tell it to. So

Less Rounded

_GuiRoundCorners($GUI_Main, 0, 0, 10, 10)oÝ÷ ØÊ+.×jëh×6_GuiRoundCorners($GUI_Main, 0, 0, 20, 30)

EDIT: with my XP theme 20,20 seems to match up exactly

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

Thank you a lot. It works for me also.

Do you know how to disable it from rounding the two bottom corners?

Could try this.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$GUI_Main = GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)

_GuiRoundCorners($GUI_Main, 100, 0, 40, 40, 0)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd


; Round corners function
; Last optional parameter $BotCrnrs - Default 1 (True) shows bottom rounded corners
;                                   - 0 (False) shows square bottom corners
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3, $BotCrnrs = True); thanks gafrost
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    If Not $BotCrnrs Then $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", _
                $i_x1, "long", $XS_pos[3]-$i_y3, "long", $XS_pos[2]-1, "long", $XS_pos[3])  
    $XS_ret = DllCall("gdi32.dll",  "long", "CreateRoundRectRgn", _
                                    "long", $i_x1, _
                                    "long", $i_y1, _
                                    "long", $XS_pos[2], _
                                    "long", $XS_pos[3], _
                                    "long", $i_x3, _
                                    "long", $i_y3)
    If Not $BotCrnrs Then DllCall("gdi32.dll", "long", "CombineRgn", "long", $XS_ret[0], "long", $XS_ret[0], _
                                                             "long", $ret2[0], "int", 2)
    If $XS_ret[0] Then
        $XS_ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
EndFunc   ;==>_GuiRoundCorners
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...