Jump to content
Sign in to follow this  
GaryFrost

Gui Shapes

Recommended Posts

GaryFrost

#include <GuiConstants.au3>

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

Func _MyForm($h_win)
    Dim $ret, $ret2, $ret3, $ret4
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", 48, "long", 48, "long", 300, "long", 200, "long", 20, "long", 20)
    If IsArray($ret) Then
        $ret2 = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", 16, "long", 4, "long", 90, "long", 80)
        If IsArray($ret2) Then
            $ret3 = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", 48, "long", 200, "long", 300, "long", 220, "long", 20, "long", 20)
            If IsArray($ret3) Then
                $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 245, "long", 4, "long", 300, "long", 29)
                If IsArray($ret4) Then
                    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
                    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret3[0], "long", $ret3[0], "long", $ret[0], "int", 2)
                    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret4[0], "long", $ret4[0], "long", $ret3[0], "int", 2)
                    $ret5 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret4[0], "int", 1)
                    If $ret5[0] Then
                        Return 1
                    Else
                        Return 0
                    EndIf
                Else
                    Return 0
                EndIf
            Else
                Return 0
            EndIf
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
EndFunc  ;==>_MyForm
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
Helge

Hmmm ! :( Really nice, Gary !

Ooh, and thanks for all the great UDFs you've made !

Share this post


Link to post
Share on other sites
GaryFrost

Func _MyForm2($h_win)
    Dim $ret, $ret2, $ret3, $ret4
    $ret = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", 0, "long", 0, "long", 100, "long", 100)
    $ret2 = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", 90, "long", 0, "long", 190, "long", 100)
    $ret3 = DllCall("gdi32.dll", "long", "CreateEllipticRgn", "long", 180, "long", 0, "long", 280, "long", 100)

    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)

    $ret5 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
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
layer

Awesome! 8)


FootbaG

Share this post


Link to post
Share on other sites
Valuater

Wow.... you know what your doing and ....

You have great timing

I just ran into this problem yesterday about rounded corners

Posted Image

Nice work... and thanks again

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
blindwig

@gafrost:

As long as you're having fun with transparent regions...

A while back I wrote a routine in VB6 that would take a GIF file as input, and create a titleless/borderless form the size of the GIF, and apply that GIF as the form background. If the GIF was transparent, it would region the transparent areas as transparent on the form. This way I could make custom-shaped forms easily - using any GIF editor, no more programming required.

Think you can tackle that task in AutoIt? I could try to dig up my VB6 project source, but it looks like you already know pretty well what you're doing.

Oh yeah - I did mine using multiple horizontal lines as regions. If you think of a better way, I'd love to hear about it! :(

Anyway, just an idea, if you're looking for something to code...

Share this post


Link to post
Share on other sites
GaryFrost

@gafrost:

As long as you're having fun with transparent regions...

A while back I wrote a routine in VB6 that would take a GIF file as input, and create a titleless/borderless form the size of the GIF, and apply that GIF as the form background.  If the GIF was transparent, it would region the transparent areas as transparent on the form.  This way I could make custom-shaped forms easily - using any GIF editor, no more programming required.

Think you can tackle that task in AutoIt?  I could try to dig up my VB6 project source, but it looks like you already know pretty well what you're doing.

Oh yeah - I did mine using multiple horizontal lines as regions.  If you think of a better way, I'd love to hear about it! :(

Anyway, just an idea, if you're looking for something to code...

<{POST_SNAPBACK}>

I know what your talking about have some old vb code for doing that somewhere.

Takes a little more, if your is like mine was it will need DllStruct and more region calls.

If you want to zip up the code and image to be translated, when I have time I would be glad to give it a shot.

Gary


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
Nova

Nice one gafrost,

You never fail to amaze, ive been waiting for this for so long!

My exams finish in 2 weeks, I cant wait to start playing with the above code.

Thanx again,

Yours greatfully, Nova.

Share this post


Link to post
Share on other sites
DaLiMan

Wow, this is so COOL!!! :

How do you come up with this stuff. :(

I will see if I can understand the code and go play with models also. :(

Share this post


Link to post
Share on other sites
blindwig

I know what your talking about have some old vb code for doing that somewhere.

Takes a little more, if your is like mine was it will need DllStruct and more region calls.

If you want to zip up the code and image to be translated, when I have time I would be glad to give it a shot.

Gary

<{POST_SNAPBACK}>

Not that I need it translated per se, but you seem to be on a roll with transparent GUI effects, so I thought you'd be interested...

anyway, here's my old VB source. It's not commented, but it's short and sweet and shouldn't be hard to figure out. It might not be terrible effecient - it's one of the first external-dll-call programs I ever wrote.

Anyway, here goes nothing...

Alpha_Notice_src.zip

Share this post


Link to post
Share on other sites
GaryFrost

Think it needs some work, don't have my vb compiler installed so I can see what it's suppose to look like.

But this conversion of the function should get you started.

Func _GetBitmapRegion($cPicture, $cTransparent)
    Dim $hRgn, $tRgn, $obj
    Dim $X, $Y, $X0
    Dim $hDC, $BM
    Dim $BM
    Dim $bmType = 1
    Dim $bmWidth = 2
    Dim $bmHeight = 3
    Dim $bmWidthBytes = 4
    Dim $bmPlanes = 5
    Dim $bmBitsPixel = 6
    Dim $bmBits = 7
    
    $BM = DllStructCreate ("int;int;int;int;int;int;int")
    If @error Then
        MsgBox(0, "", "Error in DllStructCreate " & @error);
        Exit
    EndIf
    
    $hDC = DllCall("gdi32.dll", "long", "CreateCompatibleDC", "long", 0)
    If $hDC[0] Then
        DllCall("gdi32.dll", "long", "SelectObject", "long", $hDC[0], "long", $cPicture)
        DllCall("gdi32.dll", "long", "GetObject", "long", $cPicture, "long", DllStructGetSize ($BM), "ptr", DllStructGetPtr ($BM))
        $hRgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", DllStructGetData ($BM, $bmWidth), "long", DllStructGetData ($BM, $bmHeight))
        For $Y = 0 To DllStructGetData ($BM, $bmHeight)
            For $X = 0 To DllStructGetData ($BM, $bmWidth)
                While $X <= DllStructGetData ($BM, $bmWidth) And _GetPixel($hDC[0], $X, $Y) <> $cTransparent
                    $X = $X + 1
                WEnd
                $X0 = $X
                While $X <= DllStructGetData ($BM, $bmWidth) And _GetPixel($hDC[0], $X, $Y) = $cTransparent
                    $X = $X + 1
                WEnd
                If $X0 < $X Then
                    $tRgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $X0, "long", $Y, "long", $X, "long", $Y + 1)
                    DllCall("gdi32.dll", "long", "CombineRgn", "long", $hRgn[0], "long", $hRgn[0], "long", $tRgn[0], "int", 4)
                    DllCall("gdi32.dll", "long", "DeleteObject", "long", $tRgn[0])
                EndIf
            Next
        Next
        $obj = DllCall("gdi32.dll", "long", "SelectObject", "long", $hDC[0], "long", $cPicture)
        DllCall("gdi32.dll", "long", "DeleteObject", "long", $obj[0])
    EndIf
    DllCall("gdi32.dll", "long", "DeleteDC", "long", $hDC[0])
    DllStructDelete ($BM)
    Return $hRgn[0]
EndFunc  ;==>_GetBitmapRegion

Func _GetPixel($hDC, $X, $Y)
    Dim $c
    $c = DllCall("gdi32.dll", "long", "GetPixel", "long", $hDC, "long", $X, "long", $Y)
    Return $c[0]
EndFunc  ;==>_GetPixel
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
Valuater

.... Help Me! Mr. Wizard... Help Me!!!

The round corners worked absolutely perfect for the radio.... thanks

I have been playing with your codes trying to round the top corners and cut a curve on the bottom...... I just can't get it

well... here's the project

the GUI is 248 x 393

Twizle... Twazle.. Twozle...Twone

Hope you can help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
blindwig

plug in your bitmap and bitmap size and transparent color... (quickly whipped)

<{POST_SNAPBACK}>

I think it was LazyCat that wrote a routine for extracting image file size from an image file. Search for that and plug it in and you won't have to do it manually.

Share this post


Link to post
Share on other sites
Valuater

Thanks Larry,

I couldn't get it to work.... nothing showed, just an icon in the icon tray

so, I put a "; " semicolon in front of the function call to test my stuff like this

$file = "C:\XPClean-web\Settings\XPClean-pics\GPS-2.jpg" ; ".\mybmp.bmp"

$bmpwidth = 248

$bmpheight = 393

$transparentcolor = 0xffffff ;>>>> I didn't change this

$my_gui = GUICreate(" SkinIt", $bmpheight +10, $bmpheight + 10 ,-1,-1,$WS_POPUP)

GUICtrlCreatePic($file, 0, 0, $bmpwidth, $bmpheight )

;_SkinMyGUI($my_gui,$file,$transparentcolor )

GUISetState()

and here is what i got

???.... sorry, I dont know how to test other than this

Thanks Larry

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

gotta be bmp

<{POST_SNAPBACK}>

got it!.... thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

gotta be bmp

<{POST_SNAPBACK}>

saved the pic as a bmp and changed the $file location..

hold on that ****

didn't remove the ";"

the new look

scary..!!

I noticed the size was transparent, however was still larger than the actual bmp

????.... what next

thx

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
GaryFrost

saved the pic as a bmp and changed the $file location..

looks exactly the same... ??????

thx

8(

*******EDIT ********* hold on that ****

didn't remove the ";"

<{POST_SNAPBACK}>

Also make sure to change

$my_gui = GUICreate(" SkinIt", $bmpheight +10, $bmpheight + 10 ,-1,-1,$WS_POPUP)

to

$my_gui = GUICreate(" SkinIt", $bmpwidth +10, $bmpheight + 10 ,-1,-1,$WS_POPUP)


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
Valuater

Also make sure to change

$my_gui = GUICreate(" SkinIt", $bmpwidth +10, $bmpheight + 10 ,-1,-1,$WS_POPUP)

<{POST_SNAPBACK}>

so far...

looking better all the time... 8)

thx

*********** thanks guys, gone to Mexico, have a great weekend 8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
myspacee

Hello,

sorry for resumin post but can't understand

how create a simple rectangular hole in a GUI ...

[feel stupid]

anyone can help ?

Thank you

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.