Jump to content

Opt("GUIOnEventMode", 1)


Recommended Posts

Hi,

I have at the top of my script

Opt("GUIOnEventMode", 1)

but i have also a part is my script that sorts a tabel.

If i have Opt("GUIOnEventMode", 1) at thet top i can't sort the tabel and if i have at a lower section then if i press a label it does nothing

i hope that i explain it on a good way.

Greetsz UQOII

[center]uqoii.nl[/center]

Link to comment
Share on other sites

You should show code so we can better help you. Anyway, read this from the help file.

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

Is is possible that is why you are having the problem?

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

This is my script

#include <GUIConstants.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)

GUICreate("Test",950,700,-1,-1)

$filemenu = GUICtrlCreateMenu("&Bestand")
$exititem = GUICtrlCreateMenuitem("Exit", $filemenu)

;~ Tab menu
$tab=GUICtrlCreateTab (10,10, 900,650)

;~ tab1
$tab2=GUICtrlCreateTabitem ("Tab1")
GUICtrlSetState(-1,$GUI_SHOW)
$lijst = GUICtrlCreateListView("Test",13,35,893,620)
GUICtrlSendMsg($lijst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($lijst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("1|7",$lijst)
GUICtrlCreateListViewItem("6|2",$lijst)
GUISetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($lijst) ]

;~ tab2
$tab1=GUICtrlCreateTabitem ( "Tab2")
GUICtrlCreateLabel("test",13,45)
GUICtrlCreateCombo ("", 60,40,40,30)
$speeldag = GUICtrlSetData(-1,"1|2|3","1") 
GUICtrlCreateButton("OK", 110,40,30,20)
GUICtrlSetOnEvent(-1, "OK")
GUICtrlCreateTabitem ("")

While 1
   $msg = GUIGetMsg()
   Select
        Case $msg = $lijst
            _GUICtrlListViewSort($lijst, $B_DESCENDING, GUICtrlGetState($lijst))
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem
            _ExcelBookClose($oExcel)
            Exit
   EndSelect
WEnd

Func OK()
    GUICtrlRead($speeldag)
    MsgBox(0,"test","Ok pressed") 
EndFunc

I hope that someone can help me :rolleyes:

Edited by UQOII

[center]uqoii.nl[/center]

Link to comment
Share on other sites

Sure. Do not use OnEvent mode with Message Loop mode.

Read the help file under the section of "Gui Reference" for Gui Concepts, Gui MessageLoop Mode and Gui OnEvent Mode.

Using

Opt("GUIOnEventMode", 1)
;...
;...
While 1
   $msg = GUIGetMsg()
;...
;...
WEnd

is not good to use as 2 modes at the same time causes failure.

:rolleyes:

Link to comment
Share on other sites

It is not possible that i have 2 modes in my script?

What can i do now so that my script work?

You need to choose 1 mode. I commented OnEvent mode and return useable code for you to use with Message Loop. GuiGetMsg() will poll for events inside the loop.

#include <GUIConstants.au3>
#include <GuiListView.au3>

;~ Opt("GUIOnEventMode", 1); turned off onevent mode

GUICreate("Test",950,700,-1,-1)

$filemenu = GUICtrlCreateMenu("&Bestand")
$exititem = GUICtrlCreateMenuitem("Exit", $filemenu)

;~ Tab menu
$tab=GUICtrlCreateTab (10,10, 900,650)

;~ tab1
$tab2=GUICtrlCreateTabitem ("Tab1")
GUICtrlSetState(-1,$GUI_SHOW)
$lijst = GUICtrlCreateListView("Test",13,35,893,620)
GUICtrlSendMsg($lijst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($lijst, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("1|7",$lijst)
GUICtrlCreateListViewItem("6|2",$lijst)
GUISetState()
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($lijst) ]

;~ tab2
$tab1=GUICtrlCreateTabitem ( "Tab2")
GUICtrlCreateLabel("test",13,45)
GUICtrlCreateCombo ("", 60,40,40,30)
$speeldag = GUICtrlSetData(-1,"1|2|3","1")
$button_ok = GUICtrlCreateButton("OK", 110,40,30,20)
;~ GUICtrlSetOnEvent(-1, "OK"); disabled onevent ctrl
GUICtrlCreateTabitem ("")

While 1
   $msg = GUIGetMsg()
   Select
        Case $msg = $lijst
            _GUICtrlListViewSort($lijst, $B_DESCENDING, GUICtrlGetState($lijst))
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem
            _ExcelBookClose($oExcel) ; undeclared variable
            Exit
        Case $msg = $button_ok
            OK()
   EndSelect
WEnd

Func OK()
    GUICtrlRead($speeldag)
    MsgBox(0,"test","Ok pressed")
EndFunc

You will need to make adjustments to the code to make it work how you want it to.

:rolleyes:

Link to comment
Share on other sites

It is not possible that i have 2 modes in my script?

What can i do now so that my script work?

You cannot do both at the same time. The script will run in either event mode or message mode, not both.

By changing "GuiOnEventMode" between 0 and 1, you can switch between the two, but that is usually considered unnecessarily complicated. Most would just pick one mode or the other a go with that exclusively.

Sooo... which mode will you use? The answer to that drives the solution for your script.

:rolleyes:

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

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