Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Gui buttons


  • Please log in to reply
18 replies to this topic

#1 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 05:44 PM

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 ?







#2 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 25 November 2004 - 05:52 PM

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!

#3 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 05:53 PM

and with double quotes around the filename?

GUICtrlSetImage ( $Button1, "C:\Icons\itunes.ico" )

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#4 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 06:01 PM

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]

#5 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 06:17 PM

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


#6 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 06:20 PM

Add Opt("GuiOnEventMode", 1) to your script ... :)

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#7 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 25 November 2004 - 06:23 PM

How come nothing happens when I click button 1 ?

<{POST_SNAPBACK}>

You need include this line at startup.

Opt("GUIOnEventMode", 1)



#8 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 25 November 2004 - 06:29 PM

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, 25 November 2004 - 06:30 PM.


#9 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 06:41 PM

Still not working 4 sum reason ! :)

Plain Text         
#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


#10 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 06:51 PM

Still not working 4 sum reason !  :)


Your code works fine for me... shows the msgbox when button is pressed.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#11 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 25 November 2004 - 06:52 PM

Still not working 4 sum reason !  :)

:) Are you sure?
Works fine here.

What about this code:
Plain Text         
#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


#12 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 07:04 PM

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 ?

#13 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 07:09 PM

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

#14 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 07:12 PM

This probably has to do with the fact that controls are overlapping and that the picture control is "hiding" the button control.....

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#15 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 07:19 PM

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, 25 November 2004 - 07:24 PM.


#16 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 07:24 PM

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, 25 November 2004 - 07:25 PM.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#17 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 25 November 2004 - 07:37 PM

$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, 25 November 2004 - 07:37 PM.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#18 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,351 posts

Posted 25 November 2004 - 07:40 PM

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

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#19 Nova

Nova

    Gui creation freak

  • Active Members
  • PipPipPipPipPipPip
  • 675 posts

Posted 25 November 2004 - 08:34 PM

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 !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users