Jump to content
Sign in to follow this  
milos83

Gui rounded rectangle hole

Recommended Posts

I can create a hole in a semi transparent gui but I don't know how to create a rounded rectangle hole.

2018-01-10_0053.png

 

I need this shape:

102215_1200_howtoroundt6.png?w=1600

 

See my two examples

 

Example one:

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

$hGUI = GUICreate("a",1000,800,100,100,-1,$WS_EX_LAYERED);can be $WS_POPUP
GUISetBkColor(0x0000)  ; will change background color
;~ WinSetTrans($hGUI,"",100)

GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 100)
$g1 = GUICtrlCreateGraphic(0,0,0,0)
GUICtrlSetGraphic(-1,$GUI_GR_COLOR,0xABCDEF,0xABCDEF)


;~ GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, 100, 30, 10)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 100, 100, 100, 30)


GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)


While 1
  If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
Wend

 

Example two:

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0x0000)
WinSetTrans($hGUI,"",100)

_GUICreateInvRect($hGUI, 50, 50, 80, 30)

GUISetState()

While 1
  If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
Wend





Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH)

    $aPos = WinGetPos($hWnd)


    Local $hMask_1 = _WinAPI_CreateRectRgn(0, 0, $aPos[2], $iY)
    Local $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, $aPos[3])
    Local $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, $aPos[2], $aPos[3])
    Local $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, $aPos[2], $aPos[3])

    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2)
    _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2)


    _WinAPI_DeleteObject($hMask_2)
    _WinAPI_DeleteObject($hMask_3)
    _WinAPI_DeleteObject($hMask_4)

    _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1)


EndFunc

 

 

Thanks in advance.

Edited by milos83

Share this post


Link to post
Share on other sites
9 hours ago, spudw2k said:

A quick search brought up this post: 

 

I did far more then a quick search.

The code provided creates a circle, but what I need is a rect with radius.

Any clues?

 

Thank you for your effort

Share this post


Link to post
Share on other sites

Sorry to ask, but what is a rectangle with radius?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Did you search for "round corner rectangle" ?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
12 minutes ago, jchd said:

Did you search for "round corner rectangle" ?

I did but it didn't help.

All examples I found are creating round control or round gui...

I don't know how to use those examples in order to make a hole.

Tried using _WinAPI_CreateRoundRectRgn instead of _WinAPI_CreateRectRgn but again the invisible part is reversed (the rounded rect is visible, rest of the gui is not)

Thanks in advance

Share this post


Link to post
Share on other sites

Search again!


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

I tweaked the the _GuiHole function in the _WinAPI_CreateRoundRectRgn example in the help file to produce this result.
 

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0x0000)
WinSetTrans($hGUI,"",100)

_GuiHole($hGUI, 50, 50, 80, 30, 8, 8)

GUISetState()

While 1
  If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
Wend

Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH, $iWidthEllipse, $iHeightEllipse)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn, $aPos = WinGetPos($hWin)

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $aPos[2], $aPos[3])
    $hInner_rgn = _WinAPI_CreateRoundRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH, $iWidthEllipse, $iHeightEllipse)
    $hCombined_rgn = _WinAPI_CreateRoundRectRgn(0, 0, 0, 0, 0 ,0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

 


Share this post


Link to post
Share on other sites
On 1/12/2018 at 1:21 AM, spudw2k said:

I tweaked the the _GuiHole function in the _WinAPI_CreateRoundRectRgn example in the help file to produce this result.
 

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0x0000)
WinSetTrans($hGUI,"",100)

_GuiHole($hGUI, 50, 50, 80, 30, 8, 8)

GUISetState()

While 1
  If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
Wend

Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH, $iWidthEllipse, $iHeightEllipse)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn, $aPos = WinGetPos($hWin)

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $aPos[2], $aPos[3])
    $hInner_rgn = _WinAPI_CreateRoundRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH, $iWidthEllipse, $iHeightEllipse)
    $hCombined_rgn = _WinAPI_CreateRoundRectRgn(0, 0, 0, 0, 0 ,0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

 

@spudw2k Thank you!
I have learned from your example!

@jchd Now, searching for 'rounded rectangle hole' produces actual results!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...