Jump to content

Gui buttons


Nova
 Share

Recommended Posts

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

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

  • Developers

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

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

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

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 by josbe
Link to comment
Share on other sites

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

  • Developers

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

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
Link to comment
Share on other sites

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

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

  • Developers

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

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 by nova
Link to comment
Share on other sites

  • Developers

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 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

$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 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

  • Developers

$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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...