Sign in to follow this  
Followers 0
Paulie

Make a GUI Donut

15 posts in this topic

I don't understand the regions for a gui or how to delete one, I found a UDF to make them round, but how do i cut a circle out of the center? so it looks like a ring or a donut

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@Paulie:

maybe the script below helps, it creates a pic ctrl with transparent background. I'm sure you can work out the rest, i.e., disable the pic control and put whatever buttons.

How I created the gif file:

1) Create an outer circle on favorite img editing prog (Fireworks for this kind of stuff for me)

2) create inner circle (smaller)

3) punch the inner from the outer, save as gif with index transparency.

I'm not that hot scripting but I sometimes can help in design stuff.

Give me a shout should you need a donut circle, I'll be pleased to assist you since for me this is simple.

IVAN

PS: U can always send me a pm, just say say which radius or diameter you need and the color.

Regards.

donut_gui.zip

Edited by ivan

Share this post


Link to post
Share on other sites

@Paulie:

maybe the script below helps, it creates a pic ctrl with transparent background. I'm sure you can work out the rest, i.e., disable the pic control and put whatever buttons.

How I created the gif file:

1) Create an outer circle on favorite img editing prog (Fireworks for this kind of stuff for me)

2) create inner circle (smaller)

3) punch the inner from the outer, save as gif with index transparency.

I'm not that hot scripting but I sometimes can help in design stuff.

Give me a shout should you need a donut circle, I'll be pleased to assist you since for me this is simple.

IVAN

PS: U can always send me a pm, just say say which radius or diameter you need and the color.

Regards.

Thank for your help, your script works for making a GUI look like it has a hole in the center, But i can figure out how to actually make a hole that you can click through and everything, i've seen it don't but i don't understand how

thanks again for you help,

Any other ways?

Share this post


Link to post
Share on other sites

@paulie:

I know what you mean, more along the lines of custom shape gui posted by Larry in the scripts and scraps. I'm really bad at finding stuff i've seen, so can't give you the link.

Although this is a bit beyond my league, I read that using the Gdi32.lib (Gdi32.dll) there's a function ExtSelectClipRgn which "combines the specified region with the current clipping region using the specified mode".

Specifically, what's relevant is RGN_DIFF which states:

"The new clipping region combines the areas of the current clipping region with those areas excluded from the region identified by hrgn."

Here's the msdn link.

Again, hope to not have made you waste your time. However, if you do find an answer, i'd really appreciate it if you shared it coz i've been after this for a while.

IVAN

Share this post


Link to post
Share on other sites

DONIT, DONUT:

BY NO MEANS THIS IS MINE, I PLAYED AROUND WITH LARRY'S SCRIPT, SO I'M NOT TAKING ANY CREDITS.

#include <GUIConstants.au3>

$GUI = GUICreate("test",500,500,-1,-1,$WS_POPUP)
GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,300,300,300,300)
$b = CreateRoundRectRgn(100,100,100,100,100,100)

CombineRgn($a,$b)
SetWindowRgn($GUI,$a)


;$b = CreatePolyRgn("39,250,458,250,250,500")
;CombineRgn($a,$b)
;SetWindowRgn($GUI,$a)

$Eggzit = GUICtrlCreateButton("Bye",220,370,60,25)

GUISetState()

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

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

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)
   ;DllStructDelete($lppt)
    Return $ret[0]
EndFunc

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 CombineRgn(ByRef $rgn1, ByRef $rgn2)
   ;DllCall("gdi32.dll", "long", "ExtSelectClipRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2);ORIGINAL LARRY
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

IVAN

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That works, But i have NO IDEA what just went on (never understood what for/how to use DLL calls, so i can't figure out what "ExtSelectClipRgn" does nor do i know how to find out

if i could have a UDF that has parameters I understand, I would be so happy I'd kiss you

Not really, but i would be really happy

Thanks

Edited by Paulie

Share this post


Link to post
Share on other sites

Paulie:

As I said, it's a bit beyond me, and all i did was modify a script i downloaded a while ago.

in the script

$a = CreateRoundRectRgn(0,0,300,300,300,300)

$b = CreateRoundRectRgn(100,100,100,100,100,100)

both define regions for a circle $a and $b. now to get the donut, i just played around a bit.

I also am foreign to dll calls, so... I looked at the original script, checked what the hell the func CombineRgn of gdi32.dll did in the original script through msdn.

msdn says under CombineRgn

hrgnDest

[in] Handle to a new region with dimensions defined by combining two other regions. (This region must exist before CombineRgn is called.)

hrgnSrc1

[in] Handle to the first of two regions to be combined.

hrgnSrc2

[in] Handle to the second of two regions to be combined.

fnCombineMode

[in] Specifies a mode indicating how the two regions will be combined. This parameter can be one of the following values.

and these values are :

RGN_AND Creates the intersection of the two combined regions.

RGN_COPY Creates a copy of the region identified by hrgnSrc1.

RGN_DIFF Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.

RGN_OR Creates the union of two combined regions.

RGN_XOR Creates the union of two combined regions except for any overlapping areas.

Coming back to the script, I modified the last parameter to match RGN_DIFF

DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)

Finally, if to start trying to understand dlls i downloaded a nice program from dll export viewer

Try it, it's better than nothing.

Sorry if i left you oblivious here, but half this stuff makes little sense to me.

IVAN

Share this post


Link to post
Share on other sites

Paulie:

As I said, it's a bit beyond me, and all i did was modify a script i downloaded a while ago.

in the script

$a = CreateRoundRectRgn(0,0,300,300,300,300)

$b = CreateRoundRectRgn(100,100,100,100,100,100)

both define regions for a circle $a and $b. now to get the donut, i just played around a bit.

I also am foreign to dll calls, so... I looked at the original script, checked what the hell the func CombineRgn of gdi32.dll did in the original script through msdn.

msdn says under CombineRgn

Coming back to the script, I modified the last parameter to match RGN_DIFF

DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)

Finally, if to start trying to understand dlls i downloaded a nice program from dll export viewer

Try it, it's better than nothing.

Sorry if i left you oblivious here, but half this stuff makes little sense to me.

IVAN

Thanks man... that helps a little...

i'm going to look into DllCall a little more, it's just one of those little 'black boxes' that i haven't had the time (or energy) to figure out.

But it seems it's so usefull for autoit scripting, i got to at least understand some of it

Share this post


Link to post
Share on other sites

No problemo.

I've been thinking about how on earth to make that udf, but I think I'll leave it there coz my brain's about to explode!

I defined a couple of controls on that gui and they've gone walkies...

There's lots of people going nuts about dlls, but most of the ones one can rely on are the ones distributed with the OS, so the definitions and their use is not a logical process, but a documented one in msdn. I've been visiting them more regularly lately.

IVAN

Share this post


Link to post
Share on other sites

At last, controls do work but they have to be on the donut, otherwise they are not visible.

I had to make an anormous button to realize that!

Although not a udf, i simplified the script leaving out the stuff that was no used, narrowing down to 3 funcs, and supply an explanation below:

#include <GUIConstants.au3>

$GUI = GUICreate("test",500,500,-1,-1,$WS_POPUP)

GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,300,300,300,300) ; CREATE REGION FOR CIRCLE $a

; YOU GET A CIRCLE BY SETTING PARAMETERS 3 TO 6 OF SAME SIZE PARM 3=WIDTH, 4=HEIGHT 5 AND 6 ARE ROUNDING CORNERS FROM A RECTANGLE

$b = CreateRoundRectRgn(100,100,100,100,100,100) ; SAME AS ABOVE, EXCEPT THAT PARMS 1 AND 2 ARE THE POSITION OF CIRCLE $a WITHIN $b

CombineRgn($a,$:D ; EXTRACT $b from $a, setting the result to the larger circle $a

SetWindowRgn($GUI,$a) ; Set to gui as region $a

;$b = CreatePolyRgn("39,250,458,250,250,500")

;CombineRgn($a,$:wacko:

;SetWindowRgn($GUI,$a)

$Eggzit = GUICtrlCreateButton("Bye",0,0,100,50)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $Eggzit Or $msg = $GUI_EVENT_CLOSE Then Exit

WEnd

Func CombineRgn(ByRef $rgn1, ByRef $rgn2)

DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3) ;LAST PARM WITH VALUE 3 DOES THE EXTRACTING OF $b FROM $a

EndFunc

Func SetWindowRgn($h_win, $rgn)

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

EndFunc

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) ; CREATES THE CIRCLES

Return $ret[0]EndFunc

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Still trying to turn it into a udf, but never been any good at it.

please keep trying, :whistle::) that would be INCREDIBLE, from what i gathered here, i was able to pull off what i wanted to do (sorta), and it worked out okay, anyway, here are the fruits of the effort you put into my learning these functions

#include <GUIConstants.au3>

$GUI = GUICreate("Left",400,400,0,0,$WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
$a = CreateRoundRectRgn(50,50,100,200,300,300)
$b = CreateRoundRectRgn(66.5,75,66,150,300,300)
$c = CreateRoundRectRgn(150,50,100,200,300,300)
$d = CreateRoundRectRgn(166.5,75,66,150,300,300)
$GUI2 = GUICreate("Right",400,400,0,0,$WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
$Gui3 = GUICreate("Eye 1",20,20,100,125,$WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
$Gui4 = GUICreate("Eye 2",20,20,200,125,$WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
CombineRgn($a,$B)
CombineRgn($c,$d)
SetWindowRgn($GUI,$a)
SetWindowRgn($GUI2,$c)

;$b = CreatePolyRgn("39,250,458,250,250,500")
;CombineRgn($a,$B)
;SetWindowRgn($GUI,$a)



GUISetState(@SW_SHOW,$GUI)
GUISetState(@SW_SHOW,$GUI2)
GUISetState(@SW_SHOW,$GUI3)
GUISetState(@SW_SHOW,$GUI4)
While 1
    $msg = GUIGetMsg()
    $pos = MouseGetPos()
    $GUIPos1= WinGetPos("Eye 1")
    $GUIPos2= WinGetPos("Eye 2")
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $pos[0] > $GUIPos1[0] Then
        If $GuiPos1[0] < 100 then
            WinMove("Eye 1", "", $GuiPos1[0]+1, $GUIPos1[1])
        EndIf
    EndIf
    If $pos[0] < $GUIPos1[0] Then
        If $GUIPos1[0] > 75 Then
            WinMove("Eye 1", "", $GuiPos1[0]-1, $GUIPos1[1])
        EndIf
    Endif
    If $pos[1] > $GUIPos1[1] Then
        If $GuiPos1[1] < 190 then
            WinMove("Eye 1", "", $GuiPos1[0], $GUIPos1[1]+1)
        EndIf
    EndIf
    If $pos[1] < $GUIPos1[1] Then
        If $GUIPos1[1] > 100 Then
            WinMove("Eye 1", "", $GuiPos1[0], $GUIPos1[1]-1)
        EndIf
    Endif
;---------------------- 
    If $pos[0] > $GUIPos2[0] Then
        If $GuiPos2[0] < 200 then
            WinMove("Eye 2", "", $GuiPos2[0]+1, $GUIPos2[1])
        EndIf
    EndIf
    If $pos[0] < $GUIPos2[0] Then
        If $GUIPos2[0] > 175 Then
            WinMove("Eye 2", "", $GuiPos2[0]-1, $GUIPos2[1])
        EndIf
    Endif
    If $pos[1] > $GUIPos2[1] Then
        If $GuiPos2[1] < 190 then
            WinMove("Eye 2", "", $GuiPos2[0], $GUIPos2[1]+1)
        EndIf
    EndIf
    If $pos[1] < $GUIPos2[1] Then
        If $GUIPos2[1] > 100 Then
            WinMove("Eye 2", "", $GuiPos2[0], $GUIPos2[1]-1)
        EndIf
    Endif
WEnd

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

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)
   ;DllStructDelete($lppt)
    Return $ret[0]
EndFunc

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 CombineRgn(ByRef $rgn1, ByRef $rgn2)
   ;DllCall("gdi32.dll", "long", "ExtSelectClipRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 2);ORIGINAL LARRY
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

PS, i too played around with ivans play around with larry's

I'm 2nd generation "can't take credit"

Edit: can anyone help me with the movement of the eye and the fact that it has to open 4 windows in the taskbar?

Edited by Paulie

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