Jump to content

Recommended Posts

Posted

lol I hope that's not too much to ask :)

I have the following code:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global Const $PS_SOLID = 0

$hGUI = GUICreate("TEST", 500, 500, -1, -1, BitOR($WS_POPUP, $WS_SIZEBOX))
_GuiRoundCorners($hGUI, 0, 0, 10, 10)
GUISetBkColor(0xEFEFEF)

GUIRegisterMsg($WM_NCPAINT, "WM_NCPAINT")
GUISetState(@SW_SHOW, $hGUI)

while 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func WM_NCPAINT($hWnd, $Msg, $wParam, $lParam)
    Local $hDC, $hPen, $OldPen, $OldBrush, $aHwndPos
   
    $hDC = _WinAPI_GetWindowDC($hWnd)
   
    $hPen = DllCall("gdi32.dll", "hwnd", "CreatePen", "int", $PS_SOLID, "int", 1, "int", 0x3F3F3F)
    $hPen = $hPen[0]
   
    $OldPen = _WinAPI_SelectObject($hDC, $hPen)
    $OldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_BRUSH))
   
    $aHwndPos = WinGetPos($hWnd)
   
    DllCall("gdi32.dll", "int", "Rectangle", "hwnd", $hDC, "int", 1, "int", 1, "int", $aHwndPos[2], "int", $aHwndPos[3])
   
    _WinAPI_SelectObject($hDC, $OldBrush)
    _WinAPI_SelectObject($hDC, $OldPen)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC($hWnd, $hDC)
   
    Return True
EndFunc
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

I got both functions seperately on the forums, however when put together they don't really play nicely.

There are two problems with this:

1) there is a 1px space between the border and the gui, allowing you to see what's behind the gui

2)when the rounded corners was added the right side of the border broke

anyone have any idea how to accomplish this?

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

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
×
×
  • Create New...