E1M1 Posted June 3, 2010 Share Posted June 3, 2010 (edited) 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 Bugs: title bar doesn't work. Button click has no effect if you click left side of button. expandcollapse popup#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 June 3, 2010 by E1M1 edited Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 3, 2010 Share Posted June 3, 2010 I don't get it. How does this help with using GTK? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
E1M1 Posted June 3, 2010 Author Share Posted June 3, 2010 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 Link to comment Share on other sites More sharing options...
Zibit Posted June 4, 2010 Share Posted June 4, 2010 well im sure theres a good use for it but i dont see it ^^ though the script is good 4 stars - ( becouse i dont see the use for it ) Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now