Jump to content

A bit of useless fun


BigDod
 Share

Recommended Posts

#include <GUIConstants.au3>
Opt("GUICoordMode", 1)

$Form1 = GUICreate("AForm1", 400, 400, -1, -1, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), 0)
GUISetBkColor(0xC0DCC0)
GUICtrlCreateLabel("A Round Tuit !", 50, 40, 300, 50, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
GUICtrlCreateLabel("At Long Last, we have a" & @CRLF & "sufficient quantity for each of you" & @CRLF & "to have your own. Guard it with your life." & @CRLF & "These tuits are hard to come by, especially" & @CRLF & "the round ones. This is an idespensable item." & @CRLF & "It will help you become a more efficient worker." & @CRLF & "For years we have heard people say" & @CRLF & """I'll do it as soon as I get a Round Tuit""" & @CRLF & " Now that you have a round tuit of your" & @CRLF & "very own, many things that have been" & @CRLF & "needing to be accomplished" & @CRLF & "will get done", 50, 100, 300, 250, $SS_CENTER)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
_GuiRoundCorners($Form1, 0, 0, 400, 400)
GUISetState(@SW_SHOW)

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

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

Beware of wrapping.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

I like this kind of stuff! I made this a while ago cos i was bored.

#include <GUIConstants.au3>

$GUI = GUICreate("test",300,300,-1,-1,$WS_POPUP)
GUISetBkColor(0xff0000)
$Exit = GUICtrlCreateButton("Exit",130,30,40,40)
GUICtrlCreateLabel("This uses a triangle, rectangle and round rectangle region, combining them with CombineMultiRgn", 60, 155, 230, 80)

;~ $a = CreateTriangleRgn(0, 0, 300, 100)
;~ $b = CreateRectRgn(140, 90, 20, 40)
;~ $c = CreateRectRgn(30, 110, 250, 80)
;~ $d = CreateRoundRectRgn(30, 145, 250, 100, 10, 100)
;~ Dim $a_rgns[4]
;~ $a_rgns[0] = $a
;~ $a_rgns[1] = $b
;~ $a_rgns[2] = $c
;~ $a_rgns[3] = $d
;~ CombineMutliRgn($a_rgns)
;~ SetWindowRgn($GUI,$a)
;~ GUISetState()
;NOTE: The below method I think is better
Dim $rgn[5]
$rgn[0] = CreateTriangleRgn(0, 0, 300, 100)
$rgn[1] = CreateRectRgn(140, 90, 20, 40)
$rgn[2] = CreateRectRgn(30, 110, 250, 80)
$rgn[3] = CreateRoundRectRgn(30, 145, 250, 100, 10, 100)
CombineMultiRgn($rgn)
SetWindowRgn($GUI,$rgn[0])
GUISetState()


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

;===============================================================================
;
; Function Name:   SetWindowRgn()
; Description::    Applies a generated region to a window handle returned by GUICreate
; Parameter(s):    $h_win - window handle, $rgn - The region returned by any Create..Rgn function
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       Larry
;
;===============================================================================
;

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

;===============================================================================
;
; Function Name:   CreateRectRegion()
; Description::    Creates a Rectangular Region
; Parameter(s):    left, top, width, height
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       RazerM
;
;===============================================================================
;

Func CreateRectRgn($l, $t, $w, $h)
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h)
    Return $ret[0]
EndFunc

;===============================================================================
;
; Function Name:   CreateRoundRectRgn()
; Description::    Creates a Rectangular Region with rounded corners
; Parameter(s):    left, top, width, height, horizontal rounding, vertical rounding
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       Larry
;
;===============================================================================
;

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

;===============================================================================
;
; Function Name:   CombineMultiRgn()
; Description::    Combine Mutliple Regions into first variable in array
; Parameter(s):    $a_rgns - Array of region variables to be combined Or use an array when creating regions
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       RazerM
;
;===============================================================================
;

Func CombineMultiRgn(ByRef $a_rgns)
    For $i = 1 To UBound($a_rgns)-1
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $a_rgns[0], "long", $a_rgns[0], "long", $a_rgns[$i], "int", 2)
    Next
EndFunc

;===============================================================================
;
; Function Name:   CombineRgn()
; Description::    Combine 2 Regions into first variable
; Parameter(s):    $rgn1, $rgn2 - Two Regions to be combined
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       Larry
;
;===============================================================================
;
Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2)
EndFunc

;===============================================================================
;
; Function Name:   CreateTriangleRgn()
; Description::    Creates a triangular region
; Parameter(s):    left, top, width, height
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       RazerM
;
;===============================================================================
;
Func CreateTriangleRgn($l, $t, $w, $h)
    Return CreatePolyRgn("0,0," & $l+($w/2) & "," & $t & "," & $l+$w & "," & $t+$h & "," & $l & "," & $t+$h & "," & $l+($w/2) & "," & $t & ",0,0")
EndFunc

;===============================================================================
;
; Function Name:   CreatePolyRgn()
; Description::    Create a polygon region
; Parameter(s):    $pt - co-ordinates separated by a comma
; Syntax:          Set of co-ordinates for certain points(must end with the starting point)
; Requirement(s):  AutoIt Beta
; Return Value(s): Region handle
; Author(s):       Larry, Improved by RazerM
;
;===============================================================================
;

Func CreatePolyRgn($pt)
    $pt = "0,0," & $pt & ",0,0"
    Local $ALTERNATE = 1
    Local $buffer = ""

    $pt = StringSplit($pt,",")
    For $i = 1 to $pt[0]
        $buffer = $buffer & "int;"
    Next
    $buffer = StringTrimRight($buffer,1)
    $lppt = DllStructCreate($buffer)
    For $i = 1 to $pt[0]
        DllStructSetData($lppt,$i,$pt[$i])
    Next
    $ret = DllCall("gdi32.dll","long","CreatePolygonRgn", _
            "ptr",DllStructGetPtr($lppt),"int",Int($pt[0] / 2), _
            "int",$ALTERNATE)
    $lppt = 0
    Return $ret[0]
EndFunc

Note: it uses mostly original functions from Larry

Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

:D!!!

I am glad someone found it amusing, perhaps it is a language thing. :D


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • 1 month later...

could any one post somthing to make the circle close after say 9 seconds

thanks for any help

Here ya go :wacko:

#include <GUIConstants.au3>
Opt("GUICoordMode", 1)

$Form1 = GUICreate("AForm1", 400, 400, -1, -1, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), 0)
GUISetBkColor(0xC0DCC0)
GUICtrlCreateLabel("A Round Tuit !", 50, 40, 300, 50, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
GUICtrlCreateLabel("At Long Last, we have a" & @CRLF & "sufficient quantity for each of you" & @CRLF & "to have your own. Guard it with your life." & @CRLF & "These tuits are hard to come by, especially" & @CRLF & "the round ones. This is an idespensable item." & @CRLF & "It will help you become a more efficient worker." & @CRLF & "For years we have heard people say" & @CRLF & """I'll do it as soon as I get a Round Tuit""" & @CRLF & " Now that you have a round tuit of your" & @CRLF & "very own, many things that have been" & @CRLF & "needing to be accomplished" & @CRLF & "will get done", 50, 100, 300, 250, $SS_CENTER)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
_GuiRoundCorners($Form1, 0, 0, 400, 400)
GUISetState(@SW_SHOW)

$time = TimerInit()
$allowed = 9; seconds <---------------
While TimerDiff($time)/1000 < $allowed
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;;;;;
    EndSelect
WEnd

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

@BigDod, very nice gesture, and almost true. :D

Link to comment
Share on other sites

  • 1 year later...

A bit of useless fun, .... Continued 2 years later

Added Color Regions

In the spirit of the scripts, of combining regions, I have combined three examples.

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin

;http://www.autoitscript.com/forum/index.php?s=&showtopic=27269&view=findpost&p=193061

;==> First Example - Several different Shaped Regions combined. And Set as Window Region ===
; Posted by RazerM
$GUI = GUICreate("test", 320, 250, -1, -1, $WS_POPUP)
GUISetBkColor(0xff0000)
GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin

GUICtrlCreateLabel("This uses a triangle, rectangle and round rectangle region, combining " & _
        "them with CombineMultiRgn", 60, 155, 230, 80)
GUISetState()
Dim $rgn[4]

$rgn[0] = CreateTriangleRgn(50, 0, 200, 100)
ColorRegion($GUI, $rgn[0], 0x0000ff)

$rgn[1] = CreateRoundRectRgn(30, 145, 250, 100, 100, 100)
ColorRegion($GUI, $rgn[1], 0x00ff00)

$rgn[2] = CreateRectRgn(140, 90, 20, 40)
$rgn[3] = CreateRectRgn(30, 110, 250, 80)
ColorRegion($GUI, $rgn[3], 0x00ffff)

CombineMultiRgn($rgn)
SetWindowRgn($GUI, $rgn[0])
$Exit = GUICtrlCreateButton("Exit", 125, 33, 40, 30)
GUICtrlSetBkColor($Exit, 0x0000ff)
GUICtrlSetColor($Exit, 0xffff00)
Do
    $msg = GUIGetMsg()
    If $msg = $Exit Or $msg = $GUI_EVENT_CLOSE Then
        GUIDelete($GUI)
        ExitLoop
    EndIf
Until $msg = $Exit Or $msg = $GUI_EVENT_CLOSE

;=============> End of first Example =====================
;
; =========> Poly Region Only by Malkey ============
Global $aPoints[20][2] = [[19, 0],[323, 0],[323, 69],[181, 69],[256, 173],[319, 173],[319, 225], _
                     [173, 225],[173, 173],[230, 173],[147, 69],[89, 152],[120, 152],[120, 204], _
                     [11, 204],[11, 152],[64, 152],[120, 69],[0, 69],[0, 0]]
$GUI = GUICreate("2nd Example using a polygon (19 points)", 320, 250, -1, -1);,$WS_POPUP)
GUISetBkColor(0xff0000)
GUISetState()

Dim $rgn[2]

$pts = ""
For $x = 1 To $aPoints[0][0]
    For $y = 0 To 1
        $pts &= $aPoints[$x][$y] & ","
    Next
Next
$pts = StringTrimRight($pts, 1)
GUISetState()
$rgn[0] = CreatePolyRgn($pts)
ColorRegion($GUI, $rgn[0], 0x00FF00)
SetWindowRgn($GUI, $rgn[0])

$Exit = GUICtrlCreateButton("Exit", 125, 33, 40, 30)

While 1
    $msg = GUIGetMsg()
    If $msg = $Exit Or $msg = $GUI_EVENT_CLOSE Then 
        GUIDelete($GUI)
        ExitLoop
    EndIf
WEnd

;=============> End of Second Example =====================
;
;=====> Round Gui - Closes after 9secs  by   MHz  similiar to Initial post by BigDod ====
Opt("GUICoordMode", 1)

$Form1 = GUICreate("AForm1", 400, 400, -1, -1, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), 0)
GUISetBkColor(0xC0DCC0)
GUICtrlCreateLabel("A Round Tuit !", 50, 40, 300, 50, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
GUICtrlCreateLabel("At Long Last, we have a" & @CRLF & "sufficient quantity for each of you" & @CRLF & _
"to have your own. Guard it with your life." & @CRLF & "These tuits are hard to come by, especially" & _
@CRLF & "the round ones. This is an idespensable item." & @CRLF & "It will help you become a more efficient worker." & _
@CRLF & "For years we have heard people say" & @CRLF & """I'll do it as soon as I get a Round Tuit""" & @CRLF & _
" Now that you have a round tuit of your" & @CRLF & "very own, many things that have been" & @CRLF & _
"needing to be accomplished" & @CRLF & "will get done", 50, 100, 300, 250, $SS_CENTER)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xff0000)
_GuiRoundCorners($Form1, 0, 0, 400, 400)
GUISetState(@SW_SHOW)

$time = TimerInit()
$allowed = 9; seconds <---------------
While TimerDiff($time)/1000 < $allowed
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;;;;;
    EndSelect
WEnd

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

;==========> End of third Example ==============================
;
; Function Name:   SetWindowRgn()
; Description::    Applies a generated region to a window handle returned by GUICreate
; Parameter(s):    $h_win - window handle, $rgn - The region returned by any Create..Rgn function
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       Larry
;
;===============================================================================
;
Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc   ;==>SetWindowRgn

;===============================================================================
;
; Function Name:   CreateRectRegion()
; Description::    Creates a Rectangular Region
; Parameter(s):    left, top, width, height
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       RazerM
;
;===============================================================================
;

Func CreateRectRgn($l, $t, $w, $h)
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $l, "long", $t, "long", $l + $w, _
            "long", $t + $h)
    Return $ret[0]
EndFunc   ;==>CreateRectRgn

;===============================================================================
;
; Function Name:   CreateRoundRectRgn()
; Description::    Creates a Rectangular Region with rounded corners
; Parameter(s):    left, top, width, height, horizontal rounding, vertical rounding
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       Larry
;
;===============================================================================
;
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   ;==>CreateRoundRectRgn

;===============================================================================
;
; Function Name:   CombineMultiRgn()
; Description::    Combine Mutliple Regions into first variable in array
; Parameter(s):    $a_rgns - Array of region variables to be combined Or use an array when creating regions
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       RazerM
;
;===============================================================================
;
Func CombineMultiRgn(ByRef $a_rgns)
    For $i = 1 To UBound($a_rgns) - 1
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $a_rgns[0], "long", $a_rgns[0], "long", _
                $a_rgns[$i], "int", 2)
    Next
EndFunc   ;==>CombineMultiRgn

;===============================================================================
;
; Function Name:   CombineRgn()
; Description::    Combine 2 Regions into first variable
; Parameter(s):    $rgn1, $rgn2 - Two Regions to be combined
; Requirement(s):  AutoIt Beta
; Return Value(s): None
; Author(s):       Larry
;
;===============================================================================
;
Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2)
EndFunc   ;==>CombineRgn

;===============================================================================
;
; Function Name:   CreateTriangleRgn()
; Description::    Creates a triangular region
; Parameter(s):    left, top, width, height
; Requirement(s):  AutoIt Beta
; Return Value(s): Region Handle
; Author(s):       RazerM
;
;===============================================================================
;
Func CreateTriangleRgn($l, $t, $w, $h)
    Return CreatePolyRgn("0,0," & $l + ($w / 2) & "," & $t & "," & $l + $w & "," & $t + $h & "," & $l & "," _
             & $t + $h & "," & $l + ($w / 2) & "," & $t & ",0,0")
EndFunc   ;==>CreateTriangleRgn

;===============================================================================
;
; Function Name:   CreatePolyRgn()
; Description::    Create a polygon region
; Parameter(s):    $pt - co-ordinates separated by a comma
; Syntax:          Set of co-ordinates for certain points(must end with the starting point)
; Requirement(s):  AutoIt Beta
; Return Value(s): Region handle
; Author(s):       Larry, Improved by RazerM
;
;===============================================================================
;
Func CreatePolyRgn($pt)
    Local $ALTERNATE = 1
    Local $buffer = ""

    $pt = StringSplit($pt, ",")
    For $i = 1 To $pt[0]
        $buffer = $buffer & "int;"
    Next
    $buffer = StringTrimRight($buffer, 1)
    $lppt = DllStructCreate($buffer)
    For $i = 1 To $pt[0]
        DllStructSetData($lppt, $i, $pt[$i])
    Next
    $ret = DllCall("gdi32.dll", "long", "CreatePolygonRgn", _
            "ptr", DllStructGetPtr($lppt), "int", Int($pt[0] / 2), _
            "int", $ALTERNATE)
    $lppt = 0
    Return $ret[0]
EndFunc   ;==>CreatePolyRgn

;===============================================================================
;
; Function Name:   ColorRegion()
; Description::    Add colour to a region
; Parameter(s):    $hWnd    - Windows handle from GUICreate();
;                  $Rgn     - The region to be coloured;
;                  $Color - The RGB colour to be used.
; Requirement(s):  AutoIt
; Return Value(s): 1
; Author(s):       Malkey
; ==== and ===
;Follow used with GetDCEx
;Declare Function GetDCEx Lib "user32" Alias "GetDCEx" (ByVal hwnd As Long, ByVal hrgnclip As Long, 
;                                                                   ByVal fdwOptions As Long) As Long
; Note :- The GetDC function retrieves a handle to a device context (DC) for the client area of a 
;         specified window or for the entire screen
;         GetDCEx with DCX_WINDOW flag retrieves a handle to a device context (DC) for the entire 
;         window rectangle. 
;hrgnclip :-
;Const DCX_EXCLUDERGN = 0x40 The clipping region identified by hrgnClip is excluded from the visible 
;                                 region of the returned DC.
;DCX_INTERSECTRGN     = 0x80 The clipping region identified by hrgnClip is intersected with the visible 
;                                 region of the returned DC. 
;
;flags   (creation options):-
;DCX_WINDOW           = 0x1  Returns a DC that corresponds to the window rectangle rather than the 
;                                 client rectangle.
;DCX_CACHE            = 0x2  Returns a DC from the cache, rather than the OWNDC or CLASSDC window. 
;                                 Essentially overrides CS_OWNDC and CS_CLASSDC.
;DCX_PARENTCLIP       = 0x20  Uses the visible region of the parent window. The parent's 
;                                 WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored. The origin 
;                                 is set to the upper-left corner of the window identified by hWnd.
;DCX_CLIPSIBLINGS     = 0x10  Excludes the visible regions of all sibling windows above the window 
;                                 identified by hWnd.
;DCX_CLIPCHILDREN     = 0x8  Excludes the visible regions of all child windows below the window 
;                                 identified by hWnd.
;DCX_NORESETATTRS     = 0x4  Does not reset the attributes of this DC to the default attributes 
;                                 when this DC is released.
;DCX_LOCKWINDOWUPDATE = 0x400  Allows drawing even if there is a LockWindowUpdate call in effect that 
;                                 would otherwise exclude this window. Used for drawing during tracking.
;DCX_EXCLUDEUPDATE    = 0x100
;DCX_INTERSECTUPDATE  = 0x200  Reserved; do not use.
;DCX_NORECOMPUTE      = 0x100000
;DCX_VALIDATE         = 0x200000  Reserved; do not use.
;Ref:- http://msdn.microsoft.com/en-us/library/ms533257(VS.85).aspx
;      http://www.hpcc.ecs.soton.ac.uk/software/Win32API.Txt
;===============================================================================
Func ColorRegion($hWnd, $rgn, $Color)
    Local $Flag = 0x1  ; DCX_WINDOW = 0x1
    Local $hrgnclip = 0x80  ; DCX_INTERSECTRGN = 0x80 ; DCX_EXCLUDERGN = 0x40
    $Color = BitAND(BitShift(String(Binary($Color)), 8), 0xFFFFFF) ; Converts RGB to BGR colour and visa-versa
    $hDC = DllCall("user32.dll", "int", "GetDCEx", "hwnd", $hWnd, "long", $hrgnclip, "long", $Flag)
    $hBrush = DllCall("gdi32.dll", "long", "CreateSolidBrush", "int", $Color)
    DllCall("gdi32.dll", "long", "FillRgn", "long", $hDC[0], "long", $rgn, "long", $hBrush[0])
    DllCall("user32.dll", "int", "ReleaseDC", "int", $hDC[0], "hwnd", 0)
    Return 1
EndFunc   ;==>ColorRegion

; =================================================================
; Drag Window 3 of 3 addin
; =================================================================
Func _WinMove($hWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $hWnd, "int", $WM_NCLBUTTONDOWN, "int", _
            $HTCAPTION, "int", 0)
EndFunc   ;==>_WinMove

Point of Interest::-

In the ColorRegion() function, I had to use

$hDC = DllCall("user32.dll", "int", "GetDCEx", "hwnd", $hWnd, "long", $hrgnclip, "long", $Flag) , using the $Flag parameter of DCX_WINDOW = 0x1

This returns a DC that corresponds to the window rectangle.

When the commonly used GetDC command was used which returns a DC to the client rectangle, the FillRgn will appear about a title bar width below where it should appear. This only happens with a non popup style type Gui.

Example:- Change Local $Flag = 0x1 about line306, to

Local $Flag = 0x0

Run and notice 2nd example of Polygon, the coloured region has dropped.

Edited by Malkey
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...