Sign in to follow this  
Followers 0
GioVit

Draw A Gui Window Border

5 posts in this topic

Hi there

I'm trying to draw a border line into a rounded rectangle window but, I can't find the way to make the function RoundRect to work.

Any help will be appreciated

#include <GuiConstants.au3>
$handle = GUICreate("Round Rect", 500, 500, -1, -1, $WS_POPUP);$WS_SIZEBOX + $WS_POPUPWINDOW)
GUISetBkColor(0x0000FF)
$Salir = GUICtrlCreateButton("Bye",220,370,60,25)

$a = CreateRoundRectRgn(0,0, 500,500,30,30)
SetWindowRgn($handle,$a)
CreateSolidBrush(155)
RoundRect($handle, 2,2,496,496,30,30)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $Salir Or $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc
Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc
Func RoundRect($h_win, $l, $t, $w, $h, $e1, $e2)
    $hdc = GetWindowDC($h_win)
    $ret = DllCall("gdi32.dll","long", "RoundRect", "long", $hdc, "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc
Func GetWindowDC($h_win)
    $Ret = DllCall("gdi32.dll", "long", "GetWindowDC", "hwnd", $h_win)
    Return $Ret
EndFunc
Func CreateSolidBrush($nColor)
    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    Return $hBrush[0]
EndFunc  ;==>CreateSolidBrush

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>

$my_gui = GuiCreate("MyGUI", 392, 323)
_GuiRoundCorners($my_gui, 0, 0, 50, 50)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;
    EndSelect
WEnd
Exit

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


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Let me be more explicit, Gary, I just want to draw a "black line border" around the window region

btw thanks for the very fast answer

Share this post


Link to post
Share on other sites

Don't have time to debug it all but here's a few things

$handle = GUICreate("Round Rect", 500, 500, -1, -1, $WS_POPUP);$WS_SIZEBOX + $WS_POPUPWINDOW)
$h_win = WinGetHandle($handle)
GUISetBkColor(0x0000FF)
$Salir = GUICtrlCreateButton("Bye",220,370,60,25)

$a = CreateRoundRectRgn(0,0, 500,500,30,30)
SetWindowRgn($h_win,$a)
CreateSolidBrush(0x000000)
RoundRect($h_win, 10,10,490,490,30,30)

you had gdi32.dll in the following and wasn't returning the $Ret[0]

Func GetWindowDC($h_win)
    $Ret = DllCall("user32.dll", "long", "GetWindowDC", "hwnd", $h_win)
    Return $Ret[0]
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Still not showing the black border, do I have to implement and register my own $WM_DRAWITEM function?

Some Ideas?

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  
Followers 0