Jump to content

guictrlread


gcue
 Share

Recommended Posts

not sure why the guictrlread isnt working. msbox does not come up. any ideas? thanks.

<autoit>

Opt("GUIOnEventMode", 1)

#Include <GuiConstants.au3>

#Include <Constants.au3>

#include <file.au3>

;$file = @DesktopDir & "\novell_broadcasts_settings.csv"

GUICreate("Checkers v0.1", 290,80); WS_EX_ACCEPTFILES

$filemenu = GUICtrlCreateMenu ("&File")

$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)

GUICtrlSetOnEvent(-1,"Open")

$fileexititem = GUICtrlCreateMenuitem ("Exit",$filemenu)

GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")

$helpchangeitem = GUICtrlCreateMenuItem("Change Log", $helpmenu)

GUICtrlSetOnEvent(-1,"Change")

$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

GUICtrlSetOnEvent(-1,"About")

$i = GUICtrlCreateCombo ("Bloomberg", 10,10,200,25) ; create first item

GUICtrlSetData(-1,"Notes Compression|Novell Broadcast|Reuters User Info","Bloomberg") ; add other item snd set a new default

$b = GUICtrlCreateButton("Check", 225, 8, 50)

GUICtrlSetState(-1, $GUI_FOCUS)

GUISetOnEvent($GUI_EVENT_CLOSE, "XButton")

GUISetState()

Do

$msg = GUIGetMsg()

if $msg = $b Then

Msgbox(0, "Selected listbox entry", GUICtrlRead($i)) ; display the selected listbox entry

$menustate = GUICtrlRead($filemenu) ; return the state of the menu item

$menutext = GUICtrlRead($filemenu, 1) ; return the text of the menu item

Msgbox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext)

EndIf

Until $msg = $GUI_EVENT_CLOSE

</autoit>

Link to comment
Share on other sites

Here you are using events:

$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)

GUICtrlSetOnEvent(-1,"Open")

But you have a GUI message loop at the bottom:

$msg = GUIGetMsg()

You can't mix OnEvent mode and GUI MessageLoop mode.

Link to comment
Share on other sites

not sure why the guictrlread isnt working. msbox does not come up. any ideas? thanks.

<autoit>

Opt("GUIOnEventMode", 1)

#Include <GuiConstants.au3>

#Include <Constants.au3>

#include <file.au3>

;$file = @DesktopDir & "\novell_broadcasts_settings.csv"

GUICreate("Checkers v0.1", 290,80); WS_EX_ACCEPTFILES

$filemenu = GUICtrlCreateMenu ("&File")

$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)

GUICtrlSetOnEvent(-1,"Open")

$fileexititem = GUICtrlCreateMenuitem ("Exit",$filemenu)

GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")

$helpchangeitem = GUICtrlCreateMenuItem("Change Log", $helpmenu)

GUICtrlSetOnEvent(-1,"Change")

$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

GUICtrlSetOnEvent(-1,"About")

$i = GUICtrlCreateCombo ("Bloomberg", 10,10,200,25) ; create first item

GUICtrlSetData(-1,"Notes Compression|Novell Broadcast|Reuters User Info","Bloomberg") ; add other item snd set a new default

$b = GUICtrlCreateButton("Check", 225, 8, 50)

GUICtrlSetState(-1, $GUI_FOCUS)

GUISetOnEvent($GUI_EVENT_CLOSE, "XButton")

GUISetState()

Do

$msg = GUIGetMsg()

if $msg = $b Then

Msgbox(0, "Selected listbox entry", GUICtrlRead($i)) ; display the selected listbox entry

$menustate = GUICtrlRead($filemenu) ; return the state of the menu item

$menutext = GUICtrlRead($filemenu, 1) ; return the text of the menu item

Msgbox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext)

EndIf

Until $msg = $GUI_EVENT_CLOSE

</autoit>

As weapon said:

You can't mix OnEvent mode and GUI MessageLoop mode.

Revised Code:

#Include <GuiConstants.au3>
#Include <Constants.au3>
#include <file.au3>

;$file = @DesktopDir & "\novell_broadcasts_settings.csv"

GUICreate("Checkers v0.1", 290,80); WS_EX_ACCEPTFILES
$filemenu = GUICtrlCreateMenu ("&File")
$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)
$fileexititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GUICtrlCreateMenu ("&Help")
$helpchangeitem = GUICtrlCreateMenuItem("Change Log", $helpmenu)
$helpaboutitem = GUICtrlCreateMenuitem ("About",$helpmenu)

$i = GUICtrlCreateCombo ("Bloomberg", 10,10,200,25); create first item
     GUICtrlSetData(-1,"Notes Compression|Novell Broadcast|Reuters User Info","Bloomberg"); add other item snd set a new default

$b = GUICtrlCreateButton("Check", 225, 8, 50)
     GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

while 1
    $msg = GUIGetMsg()
        switch $msg
            case $GUI_EVENT_CLOSE
                Exit
            case $b
                Msgbox(0, "Selected listbox entry", GUICtrlRead($i)); display the selected listbox entry
                $menustate = GUICtrlRead($filemenu); return the state of the menu item
                $menutext = GUICtrlRead($filemenu, 1); return the text of the menu item
                Msgbox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext)
            case $fileopenitem
            case $fileexititem
            case $helpchangeitem
            case $helpaboutitem
        EndSwitch
WEnd

NOTE: I'M NOT A TROLL, as some keep saying. I just take what is given and work with it till i can get it to work for me and then share what I have. I'm trying my darndest to learn Auto.IT more and more, and i'm not one to keep my opinions to myself :D

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

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