Jump to content
Sign in to follow this  
hot202

GuiRoundCorners help?

Recommended Posts

hot202

hi is there anyway to mae it so that _GuiRoundCorners cuts the corner not round it like so it makes the corner of the gui a 45 cut on a corner?

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
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
EndFunc
Edited by hot202

Share this post


Link to post
Share on other sites
Yashied

#Include <WindowsConstants.au3>

$hForm = GUICreate('MyGUI', 400, 400, -1, -1, $WS_POPUP)
_GuiRoundCorners($hForm, 0, 0, 100, 100)
GUISetState()

Do
Until GUIGetMsg() = -3

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
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
EndFunc   ;==>_GuiRoundCorners

Share this post


Link to post
Share on other sites
hot202

no i mean how to i get it to do a cut not round? like a angle \ on the corner

Share this post


Link to post
Share on other sites
hot202

Posted Image

like that on the corner?can it be done?

Share this post


Link to post
Share on other sites
Yashied

Posted Image

like that on the corner?can it be done?

Play with follows.

#Include <WindowsConstants.au3>

Global Const $ALTERNATE = 1
Global Const $WINDING = 2

$hForm = GUICreate('MyGUI', 400, 400, -1, -1, $WS_POPUP)
GUISetBkColor(0x880000)

$tPOINT = DllStructCreate('int[2];int[2];int[2];int[2];int[2];int[2];int[2];int[2]')

DllStructSetData($tPOINT, 1, 0, 1)
DllStructSetData($tPOINT, 1, 40, 2)
DllStructSetData($tPOINT, 2, 40, 1)
DllStructSetData($tPOINT, 2, 0, 2)
DllStructSetData($tPOINT, 3, 360, 1)
DllStructSetData($tPOINT, 3, 0, 2)
DllStructSetData($tPOINT, 4, 400, 1)
DllStructSetData($tPOINT, 4, 40, 2)
DllStructSetData($tPOINT, 5, 400, 1)
DllStructSetData($tPOINT, 5, 360, 2)
DllStructSetData($tPOINT, 6, 360, 1)
DllStructSetData($tPOINT, 6, 400, 2)
DllStructSetData($tPOINT, 7, 40, 1)
DllStructSetData($tPOINT, 7, 400, 2)
DllStructSetData($tPOINT, 8, 0, 1)
DllStructSetData($tPOINT, 8, 360, 2)

$Ret = DllCall('gdi32.dll', 'ptr', 'CreatePolygonRgn', 'ptr', DllStructGetPtr($tPOINT), 'int', 8, 'int', $ALTERNATE)
DllCall('user32.dll', 'int', 'SetWindowRgn', 'hwnd', $hForm, 'ptr', $Ret[0], 'int', 1)

GUISetState()

Do
Until GUIGetMsg() = -3
Edited by Yashied

Share this post


Link to post
Share on other sites
hot202

wow thanks so much. also how would i change it to only do it 2 the top right corner and bottom left?

Share this post


Link to post
Share on other sites
Yashied

wow thanks so much. also how would i change it to only do it 2 the top right corner and bottom left?

#Include <WindowsConstants.au3>

Global Const $ALTERNATE = 1
Global Const $WINDING = 2

$hForm = GUICreate('MyGUI', 400, 400, -1, -1, $WS_POPUP)
GUISetBkColor(0x880000)

$tPOINT = DllStructCreate('int[2];int[2];int[2];int[2];int[2];int[2]')

DllStructSetData($tPOINT, 1, 0, 1)
DllStructSetData($tPOINT, 1, 0, 2)
DllStructSetData($tPOINT, 2, 360, 1)
DllStructSetData($tPOINT, 2, 0, 2)
DllStructSetData($tPOINT, 3, 400, 1)
DllStructSetData($tPOINT, 3, 40, 2)
DllStructSetData($tPOINT, 4, 400, 1)
DllStructSetData($tPOINT, 4, 400, 2)
DllStructSetData($tPOINT, 5, 40, 1)
DllStructSetData($tPOINT, 5, 400, 2)
DllStructSetData($tPOINT, 6, 0, 1)
DllStructSetData($tPOINT, 6, 360, 2)

$Ret = DllCall('gdi32.dll', 'ptr', 'CreatePolygonRgn', 'ptr', DllStructGetPtr($tPOINT), 'int', 6, 'int', $ALTERNATE)
DllCall('user32.dll', 'int', 'SetWindowRgn', 'hwnd', $hForm, 'ptr', $Ret[0], 'int', 1)

GUISetState()

Do
Until GUIGetMsg() = -3

Share this post


Link to post
Share on other sites
Yashied

Red star!

>_<

#Include <GUIConstantsEx.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global $aPoint[10][2] = [[0, 180], [190, 180], [250, 0], [308, 180], [500, 180], [344, 294], [404, 475], [250, 362], [94, 475], [154, 294]]

$hForm = GUICreate('MyGUI', 500, 475, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Button = GUICtrlCreateButton('Exit', 215, 255, 70, 23)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUISetBkColor(0xAA0000)

$hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_SetWindowRgn($hForm, $hRgn)

GUISetState()

Do
Until GUIGetMsg() = $Button

Func _WinAPI_CreatePolygonRgn($aPoint, $iStart = 0, $iEnd = -1, $iMode = 1)

    If UBound($aPoint, 2) < 2  Then
        Return SetError(1, 0, 0)
    EndIf

    Local $Count, $tData, $Struct = ''

    If ($iEnd < 0) Or ($iEnd > UBound($aPoint) - 1) Then
        $iEnd = UBound($aPoint) - 1
    EndIf
    For $i = $iStart To $iEnd
        $Struct &= 'int[2];'
    Next
    $tData = DllStructCreate(StringTrimRight($Struct, 1))
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $Count = 1
    For $i = $iStart To $iEnd
        For $j = 0 To 1
            DllStructSetData($tData, $Count, $aPoint[$i][$j], $j + 1)
        Next
        $Count += 1
    Next

    Local $Ret = DllCall('gdi32.dll', 'ptr', 'CreatePolygonRgn', 'ptr', DllStructGetPtr($tData), 'int', $Count - 1, 'int', $iMode)

    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_CreatePolygonRgn

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    If _WinAPI_DefWindowProc($hWnd, $Msg, $wParam, $lParam) = $HTCLIENT Then
        Return $HTCAPTION
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

Share this post


Link to post
Share on other sites
CodyBarrett

Share this post


Link to post
Share on other sites
picea892

Hi Yashied

The red star is very nice. I also like the red maple leaf.....

PS: Watch the line wrap

#Include <GUIConstantsEx.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global $aPoint[25][2] = [[196, 31], [220, 92], [258, 77], [248, 158], [295, 125], [307, 157], [357, 149], [326, 206], [357, 214], [271, 273], [282, 296], [202, 282], [200, 361], [188, 360], [188, 280], [109, 295], [122, 276], [34, 214], [62, 204], [37, 152], [84, 156], [97, 122], [143, 156], [132, 75], [170, 89]]
$hForm = GUICreate('MyGUI', 500, 475, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
$Button = GUICtrlCreateButton('Exit', 160, 160, 70, 23)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUISetBkColor(0xAA0000)

$hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_SetWindowRgn($hForm, $hRgn)

GUISetState()

Do
Until GUIGetMsg() = $Button

Func _WinAPI_CreatePolygonRgn($aPoint, $iStart = 0, $iEnd = -1, $iMode = 1)

    If UBound($aPoint, 2) < 2  Then
        Return SetError(1, 0, 0)
    EndIf

    Local $Count, $tData, $Struct = ''

    If ($iEnd < 0) Or ($iEnd > UBound($aPoint) - 1) Then
        $iEnd = UBound($aPoint) - 1
    EndIf
    For $i = $iStart To $iEnd
        $Struct &= 'int[2];'
    Next
    $tData = DllStructCreate(StringTrimRight($Struct, 1))
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $Count = 1
    For $i = $iStart To $iEnd
        For $j = 0 To 1
            DllStructSetData($tData, $Count, $aPoint[$i][$j], $j + 1)
        Next
        $Count += 1
    Next

    Local $Ret = DllCall('gdi32.dll', 'ptr', 'CreatePolygonRgn', 'ptr', DllStructGetPtr($tData), 'int', $Count - 1, 'int', $iMode)

    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc   ;==>_WinAPI_CreatePolygonRgn

Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
    If _WinAPI_DefWindowProc($hWnd, $Msg, $wParam, $lParam) = $HTCLIENT Then
        Return $HTCAPTION
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

Share this post


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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.