Sign in to follow this  
Followers 0
GaryFrost

Hole In Gui

14 posts in this topic

#include <GuiConstants.au3>

$my_gui = GUICreate("MyGUI", 392, 323)

_GuiHole($my_gui, 80, 30, 200)
GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case Else
        ;;;
   EndSelect
WEnd
Exit

Func _GuiHole($h_win, $i_x, $i_y, $i_size)
   Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret
   $pos = WinGetPos($h_win)
   
   $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
    If IsArray($outer_rgn) Then
        $inner_rgn = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_size, "long", $i_y + $i_size)
        If IsArray($inner_rgn) Then
            $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
            If IsArray($combined_rgn) Then
                DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", 4)
                $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
                If $ret[0] Then
                    Return 1
                Else
                    Return 0
                EndIf
            Else
                Return 0
            EndIf
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
   
EndFunc  ;==>_GuiHole

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



Hmm thats freaky.

Share this post


Link to post
Share on other sites

Size the width and height seperatly

#include <GuiConstants.au3>

$my_gui = GUICreate("MyGUI", 392, 323)

_GuiHole($my_gui, 80, 30, 200, 300)
GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case Else
        ;;;
   EndSelect
WEnd
Exit

Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
   Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn, $ret
   $pos = WinGetPos($h_win)
   
   $outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
    If IsArray($outer_rgn) Then
        $inner_rgn = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh)
        If IsArray($inner_rgn) Then
            $combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
            If IsArray($combined_rgn) Then
                DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", 4)
                $ret = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
                If $ret[0] Then
                    Return 1
                Else
                    Return 0
                EndIf
            Else
                Return 0
            EndIf
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
   
EndFunc  ;==>_GuiHole

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

Some really interesting effects.

Cheers.. :(

Share this post


Link to post
Share on other sites

I have made my own function that is greatly based off of yours but instead of cutting off everything except a rectangle you specify (left, top, width, height) it will make the rectangle invisible. Basically it trims off the rectangle instead of everything around it. Except it has a problem. You can't call the function more than once, for some reason it will erase the previous rectangle. Help? :(

#include <GUIConstants.au3>

$gui = GUICreate("GUI", 500, 500)

_GUICreateInvRect($gui, 100, 150, 200, 200)

GUISetState()

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

Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
  $pos = WinGetPos($hwnd)

  $1 = 0
  $2 = 0
  $3 = $pos[2]
  $4 = $t
  $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = 0
  $2 = 0
  $3 = $l
  $4 = $pos[3]
  $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = $l + $w
  $2 = 0
  $3 = $pos[2]
  $4 = $pos[3]
  $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = 0
  $2 = $t + $h
  $3 = $pos[2]
  $4 = $pos[3]
  $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)

  DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
EndFunc

It seems like the problem is in the "CombineRgn" part. It doesn't combine the other rectangle into itself.

Share this post


Link to post
Share on other sites

nice, would this mean we could use custom shape GUI's?

like in some keygens for ex.

<{POST_SNAPBACK}>

Yes, we can...using CreatePolygonRgn function. (gdi32.dll) :(

Share this post


Link to post
Share on other sites

...i asked this question in the support before, why didn't anyone helped me there :( i feel supressed

but where can i find more about this CreatePolygonRgn ??


*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...

Share this post


Link to post
Share on other sites

MSDN


FootbaG

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I have made my own function that is greatly based off of yours but instead of cutting off everything except a rectangle you specify (left, top, width, height) it will make the rectangle invisible. Basically it trims off the rectangle instead of everything around it. Except it has a problem. You can't call the function more than once, for some reason it will erase the previous rectangle. Help?  :(

#include <GUIConstants.au3>

$gui = GUICreate("GUI", 500, 500)

_GUICreateInvRect($gui, 100, 150, 200, 200)

GUISetState()

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

Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
  $pos = WinGetPos($hwnd)

  $1 = 0
  $2 = 0
  $3 = $pos[2]
  $4 = $t
  $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = 0
  $2 = 0
  $3 = $l
  $4 = $pos[3]
  $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = $l + $w
  $2 = 0
  $3 = $pos[2]
  $4 = $pos[3]
  $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
  $1 = 0
  $2 = $t + $h
  $3 = $pos[2]
  $4 = $pos[3]
  $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
  DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)

  DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
EndFunc

It seems like the problem is in the "CombineRgn" part. It doesn't combine the other rectangle into itself.

<{POST_SNAPBACK}>

If understand you correctly, your wanting to cut out more that one rectangle, correct?

If so, then your correct, you'll have to do it all at one time and combine the regions.

Take a look at the following thread:

http://www.autoitscript.com/forum/index.php?showtopic=12476

Edited by gafrost

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

Yes, we can...using CreatePolygonRgn function. (gdi32.dll) :(

<{POST_SNAPBACK}>

After reading this I thought I'd give it a shot but....pfffff....only errors here!! :(

Can anyone tell me I am going in the right direction?

I altered the original script from gafrost but I have no VB or DLL experiance whatsoever so I have figure it out somehow.

Have looked at MSDN for some info.

Well here it is. (dont laugh) :

#include <GuiConstants.au3>

$my_gui = GUICreate("   SkinIt", 300, 300)
$button = GUICtrlCreateButton("Exit", 35, 10)
_MyForm2($my_gui)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
            ExitLoop
        Case Else
       ;;;
    EndSelect
WEnd
Exit

Func _MyForm2($h_win)
    Dim $ret, $ret2, $ret3, $ret4
    $ret = DllCall("gdi32.dll", "long", "CreatePolygonRgn", "long",150, "long", 150, "long", 250, "long", 200, "long", 100, "long", 200, "int",3 ,"int", "alternate")

    $ret5 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
EndFunc

Share this post


Link to post
Share on other sites

Looking at MSDN for CreatePolygonRgn you'll need to use DllStruct functions

CreatePolygonRgn only takes 3 params, 1st is an array of points, 2nd number of points in the array, and 3rd fill mode


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

Looking at MSDN for CreatePolygonRgn you'll need to use DllStruct functions

CreatePolygonRgn only takes 3 params, 1st is an array of points, 2nd number of points in the array, and 3rd fill mode

<{POST_SNAPBACK}>

eehhh....OK.....

After playing with it for a while (and only getting errors) I would like to ask for some assistance.

Like I said, I have no VB experiance whatsoever and I'm trying to find out how these functions work.

I tried to make an triangle-GUI and maybe go from there but I'm not even close.

Anyway here's my effort for this afternoon:

(Probably doesn't make any sense..)

Func _MyForm2($h_win)
    Dim $ret, $ret2
    Dim $str = "int;int;int;int;int;int"
    Dim $a        = DllStructCreate($str)
Dim $v1="150,150"
Dim $v2="250,200"
Dim $v3="100,200"
DllStructSetData($a,1,$v1)
DllStructSetData($a,2,$v2)
DllStructSetData($a,3,$v3)
$create = DllStructGetData($a,1) + DllStructGetData($a,2) + DllStructGetData($a,3)

    $ret = DllCall("gdi32.dll", "long", "CreatePolygonRgn", "int", $create, "int",3 ,"int", "alternate")

    $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret, "int", 1)
EndFunc

PS: Downloaded the latest BETA now for the DLLstruct function too.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I tried CreatePolygonRgn a few weeks ago. Still has some bugs...like its at the wrong coordinates.

#include<gdi32.au3>
$dc = _GetDC( 0)
$dll = DllOpen( "Gdi32.dll")

Dim $my_array [4] [3]
$my_array [0] [0] = 3

$my_array [1] [1] = 436;lx1
$my_array [1] [2] = 35;ry2

$my_array [2] [1] = 78;ly1
$my_array [2] [2] = 430;bx3

$my_array [3] [1] = 706;rx2
$my_array [3] [2] = 456;by3




$r = _CreatePolygonRgn( $my_array, $ALTERNATE, $dll)
$g = _CreateSolidBrush( 0x00ff00, $dll)

HotKeySet( "{ESC}", "quit")
While 1
    _FillRgn($dc, $r, $g)
    Sleep(20)
WEnd

Func _GetDC( $hwnd, $dll_h = "user32.dll")
    $return = DllCall( $dll_h, "ptr", "GetDC", "hwnd", $hwnd)
    Return $return[0]
EndFunc

Func _ReleaseDC( $hwnd, $dc, $dll_h = "user32.dll")
    $return = DllCall( $dll_h, "int", "ReleaseDC", "hwnd", $hwnd, "ptr", $dc)
    Return $return[0]
EndFunc

Func quit()
DllClose( $dll)
_ReleaseDC( 0, $dc)
Exit
EndFunc

gdi32.au3

Fixed link.

Edited by UP NORTH

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