Nova Posted November 25, 2004 Share Posted November 25, 2004 Ok im trying to create a button in a gui which looks like an icon ! Heres my code ! $Gui = GUICreate("Gui", 250, 500, -1, -1, $WS_POPUP) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "", 75, 200 ,100 ,200 $BS_ICON) GUICtrlSetImage ( $Button1, C:\Icons\itunes.ico ) GUISetState() Ive never used GUICtrlCreateButton can anyone tell me why the above wont work ? Link to comment Share on other sites More sharing options...
CyberSlug Posted November 25, 2004 Share Posted November 25, 2004 C:\Icons\itunes.ico needs to be in quotes and you were missing a comma before $BS_ICON (and you were missing an #include or declaration for $WS_POPUP) #include <GuiConstants.au3> $Gui = GUICreate("Gui", 250, 500, -1, -1, $WS_POPUP) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "", 75, 200 ,100 ,200, $BS_ICON) GUICtrlSetImage ( $Button1, "C:\Icons\itunes.ico" ) GUISetState() sleep(5000) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 and with double quotes around the filename? GUICtrlSetImage ( $Button1, "C:\Icons\itunes.ico" ) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 C:\Icons\itunes.ico needs to be in quotes[Reply]CrapI hate when its something sosimple that I overlook[/Reply]and you were missing a comma before $BS_ICON[Reply]Damit !!![/Reply]and you were missing an #include or declaration for $WS_POPUP[Reply]Well that one I account for I only posted a smallsection of the code imworking on ! #include was in the original![/Reply] Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 How come nothing happens when I click button 1 ? #include <GuiConstants.au3> $Gui = GUICreate("Gui", 250, 500, -1, -1, $WS_POPUP) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 ,$BS_ICON) GUICtrlSetImage ($Button1, "C:\Icons\itunes.ico" ) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState() Func OKPressed() MsgBox(4096,"", "Ok pressed") EndFunc While 1 Sleep (10) Wend Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 Add Opt("GuiOnEventMode", 1) to your script ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Josbe Posted November 25, 2004 Share Posted November 25, 2004 How come nothing happens when I click button 1 ? <{POST_SNAPBACK}>You need include this line at startup. Opt("GUIOnEventMode", 1) AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Josbe Posted November 25, 2004 Share Posted November 25, 2004 (edited) Opss! (Double answer above). :"> From Helpfile:GUIOnEventMode Enable/disable OnEvent functions notifications.0 = (default) disable.1 = enable.Return previous mode.@Devs: I believe that the helpfile would to have more info about this. Edited November 25, 2004 by josbe AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 Still not working 4 sum reason ! #include <GUIConstants.au3> Opt("GuiOnEventMode", 1) $GuiWidth = 250 $GuiHeight = 500 $xPos = (@DesktopWidth - 250) $yPos = (@DesktopHeight - $GuiHeight) / 2 ;Main Gui $Gui = GUICreate("Gui", 250, 500, $xPos, $yPos, $WS_POPUP) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 ,$BS_ICON) GUICtrlSetImage ($Button1, "C:\Dev-Cpp\Icons\Console.ico" ) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState() Func OKPressed() MsgBox(4096,"", "Ok pressed") EndFunc While 1 Sleep(10) WEnd Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 Still not working 4 sum reason ! Your code works fine for me... shows the msgbox when button is pressed. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Josbe Posted November 25, 2004 Share Posted November 25, 2004 Still not working 4 sum reason ! Are you sure?Works fine here.What about this code:#include <GUIConstants.au3> Opt("GuiOnEventMode", 1) GUICreate("Gui", 150, 150) GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $Button1 = GUICtrlCreateButton ( "OK", 50, 50) GUICtrlSetOnEvent(-1, "OKPressed") GUISetState() While 1 Sleep(10) WEnd Exit Func OKPressed() MsgBox(4096,"", "Ok pressed") EndFunc Func SpecialEvents() If @GUI_CTRLID = $GUI_EVENT_CLOSE Then Exit EndFunc AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 It seems that the picture being displayed by GUICtrlCreatePic is stoping the button from working ! If the following line of code is removed it works ! $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) I need that line of code !!!!! Why is it causing this error ? Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 It seems that the picture being displayed by GUICtrlCreatePic is stoping the button from working ! If the following line of code is removed it works ! $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) But I need that line of code !!!!! Why is it causing this error ? Is this a bug ? Example #include <GUIConstants.au3> Opt("GuiOnEventMode", 1) $Gui = GUICreate("Gui", 250, 500, -1, -1, $WS_POPUP) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 ) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState() While 1 Sleep(10) WEnd Func OKPressed() MsgBox(4096,"", "Ok pressed") EndFunc Above works #include <GUIConstants.au3> Opt("GuiOnEventMode", 1) $Gui = GUICreate("Gui", 250, 500, -1, -1, $WS_POPUP) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500) GUISetBkColor(000000) $Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 ) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState() While 1 Sleep(10) WEnd Func OKPressed() MsgBox(4096,"", "Ok pressed") EndFunc Above dosent work Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 This probably has to do with the fact that controls are overlapping and that the picture control is "hiding" the button control..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 (edited) Shouldnt this keep the button on top ? $Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 ,$WS_EX_TOPMOST) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState() GUICtrlSetState($Button1, $GUI_FOCUS) Neither work to solve this little problem by the way Any ideas ? Edited November 25, 2004 by nova Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 (edited) Shouldnt this keep the button on top ?$Button1 = GUICtrlCreateButton ( "OK", 75, 125 ,100 ,50 , $WS_EX_TOPMOST) GUICtrlSetOnEvent($Button1, "OKPressed") GUISetState()It dosent by the way Any ideas ?<{POST_SNAPBACK}>just been playing with this a bit and the button responds ok when you first create the button and then the picture. but the strange thing i see is that the button initially isn't shown, but when clicked the msgbox pops up and the button is shown...... Edited November 25, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
CyberSlug Posted November 25, 2004 Share Posted November 25, 2004 (edited) $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500, $GUI_DISABLE) I had to do stuff like that in AutoBuilder.... Edited November 25, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Developers Jos Posted November 25, 2004 Developers Share Posted November 25, 2004 $Background = GUICtrlCreatePic("C:\Documents and Settings\Administrator\Desktop\Menu.bmp", 0, 0, 250, 500, $GUI_DISABLE)I had to do stuff like that in AutoBuilder....<{POST_SNAPBACK}>ok. that works... still the behaviour described is at least confusion........ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nova Posted November 25, 2004 Author Share Posted November 25, 2004 Tnx a million josbe, JdeB and CyberSlug its workin perfect now ! One last thing is there anyway of stopping a gui from showing up in the taskbar? I have a one or two scripts which start multiple GUI's sometimes as many as 8 and I dont like the taskbar being flooded with gui window titles ! 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