Jump to content
Sign in to follow this  
E1M1

Hello world!

Recommended Posts

E1M1

Just made my own GUI controls because I didn't find how to use GTK with autoit so I decided to make my own controls :mellow:

Bugs: title bar doesn't work.

Button click has no effect if you click left side of button.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Opt("MouseCoordMode", 2)

Local $child,$CLOSE
$child = _GUICreate("Hello World!",95,75+15)
$button1 = _GuiCreateButton("Hello World!", 10, 20, 75, 25)
$button2 = _GuiCreateButton("Exit", 10, 50, 75, 25)

Func _GUICreate($title,$width,$height,$left = Default,$top = Default)
    $child = GUICreate($title,$width,$height,$left,$top,0x80000000)
    FileDelete(@TempDir&"\title.bmp")
    FileWrite(@TempDir&"\title.bmp",Binary("0x424D3A000000000000003600000028000000010000000100000001001800000000000400000000000000000000000000000000000000FF000000"))
    _GuiCreateTitleBar($title,$width)
EndFunc

Func _GuiCreateButton($text, $x, $y, $x2, $y2)
    GUICtrlCreateGraphic($x, $y, $x2, $y2, 0)
    GUICtrlSetBkColor(-1, 0xcccccc)
    GUICtrlSetColor(-1, 0x999999)
    $width = StringLen($text) * 5
    GUICtrlCreateLabel($text, $x + 8, $y + 7, $x2, $y2)
    GUICtrlSetBkColor(-1, -2)
    Return $x&"|"& $y&"|"&$x2&"|"& $y2
EndFunc   ;==>_GuiCreateButton

Func _GuiCreateTitleBar($title,$width)
    GUICtrlCreatePic(@TempDir&"\title.bmp",0, 0, $width, 15,0, $GUI_WS_EX_PARENTDRAG);Doesn't work as titlebar
    GUICtrlCreateLabel($title, 3,3)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, -2)
    $CLOSE = GUICtrlCreateLabel("X", $width - 15,3)
    GUICtrlSetColor(-1, 0xcc0000)
    GUICtrlSetBkColor(-1, -2)
EndFunc   ;==>_GuiCreateButton

GUISetState()

Func MinLeft($i)
    If $i > 0 Then
        Return $i
    Else
        Return 0
    EndIf
EndFunc   ;==>MinLeft

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $CLOSE
            Exit
EndSwitch
    If $nMsg = -7 Then _CoordToButton()
WEnd

Func _CoordToButton()
    $pos = StringSplit($button1,"|")
    ;x,y,w,h

    $b = MouseGetPos(0) >= $pos[1] And MouseGetPos(0) >= $pos[2] And MouseGetPos(1) <= $pos[3]+$pos[1] And MouseGetPos(1) <= $pos[4]+$pos[2]
    If $b = True Then
        MsgBox(0,"Hello World!","Hello world clicked!")
        Return
    EndIf
;~  ------------------------
    $pos = StringSplit($button2,"|")
    $b = MouseGetPos(0) >= $pos[1] And MouseGetPos(0) >= $pos[2] And MouseGetPos(1) <= $pos[3]+$pos[1] And MouseGetPos(1) <= $pos[4]+$pos[2]
    If $b = True Then
        Exit
    EndIf
EndFunc
Edited by E1M1

edited

Share this post


Link to post
Share on other sites
E1M1

Maybe I wasn't clear enough. I meant I created my own buttons as alternative for GTK because I was unable to use GTK. Point is: Now I have my own gui controls.

I just wanted to use something other than just win32 buttons so I decided to build my own buttons..

It doesn't help using GTK, it's just replacement for it.

Sorry if my english was bad.


edited

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.