kylomas Posted January 23, 2011 Share Posted January 23, 2011 Gui Experts, When I click on a menu sub-item ($opt11,$opt12 or $opt13) my event handler is being driven but the control value does not change. Consolewrite messaqges verify this. My intent is to use this to set a variable ($numl) that is used for label control creation. This app is a handy little logic game usefull for the kids, those long conference calls or playing for coffee with the guy in the next office. I'm also doing this to get familiar with GUI management so any and all suggestions are welcome. expandcollapse popup; ; BAGELS ; #include <array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> opt('mustdeclarevars',1) opt('guioneventmode',1) global $width = 800, $height = 600, $gui010, $numl = 3, $aGTXT[11], $aRSLT[11][$numl], $aGNUM[11][$numl] global $gui010, $hdr, $lbl10, $opts, $opt10, $opt11, $opt12, $opt13 global $txt10 = 'Guess the number:' & @crlf & @crlf & ' Each digit in the number is unique (0-9)' & @CRLF & @CRLF $txt10 &= ' Guess results:' & @CRLF & @crlf $txt10 &= ' Black - none of your numbers are correct' & @CRLF $txt10 &= ' Yellow - one of you numbers is correct but in the wrong position' & @CRLF $txt10 &= ' Red - one of your numbers is correct and in the correct position' & @CRLF init_gui() while 1 sleep(100) wend func init_gui() guidelete($gui010) $gui010 = guicreate('Bagels',$width,$height,(@desktopwidth-$width)/2,(@DesktopHeight-$height)/2) $hdr = guictrlcreatelabel('BAGELS',10,10,780,40,$ss_center+$ss_sunken) guictrlsetfont($hdr,20,400,2,'comic sans ms') guictrlsetcolor($hdr,0x800000) $lbl10 = guictrlcreatelabel('',10,70,700,150) guictrlsetdata($lbl10,$txt10) guictrlsetfont($lbl10,9,600,0,'Courier New') guisetfont(12,800,0,'comic sans ms') $opts = guictrlcreatemenu('Options') $opt10 = GUICtrlCreateMenu("# Size", $opts) $opt11 = GUICtrlCreateMenuItem("3", $opt10) ;guictrlsetstate($opt11,$gui_checked) guictrlsetonevent($opt11,'chg_size') $opt12 = GUICtrlCreateMenuItem("4", $opt10) guictrlsetonevent($opt12,'chg_size') $opt13 = GUICtrlCreateMenuitem("5", $opt10) guictrlsetonevent($opt13,'chg_size') for $i = 1 to 10 $aGTXT[$i] = guictrlcreatelabel('Guess # ' & stringformat("%02d",$i) & '-',150,200 + ($i*30),120,20) for $j = 0 to $numl - 1 $aGNUM[$i][$j] = guictrlcreatelabel('',300+($j*30),200 + ($i*30),20,20,$ss_sunken) $aRSLT[$i][$j] = guictrlcreatelabel('',500+($j*30),200 + ($i*30),20,20,$ss_sunken) next next GUISetState(@sw_show) GUISetOnEvent($gui_event_close,'_fini') endfunc func chg_size() consolewrite('at chg_size' & @crlf) consolewrite('opt11 = ' & binary(guictrlread($opt11)) & @crlf) consolewrite('opt12 = ' & binary(guictrlread($opt12)) & @crlf) consolewrite('opt13 = ' & binary(guictrlread($opt13)) & @crlf) if BitAND(GUICtrlRead($opt11), $GUI_CHECKED) = $GUI_CHECKED Then $numl = 3 init_gui() endif if BitAND(GUICtrlRead($opt12), $GUI_CHECKED) = $GUI_CHECKED Then $numl = 4 init_gui() endif if BitAND(GUICtrlRead($opt13), $GUI_CHECKED) = $GUI_CHECKED Then $numl = 5 init_gui() endif endfunc func _fini() Exit endfunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 (edited) OK, firstly look at @GUI_CtrlId because currently you are using BitAND(GUICtrlRead($opt11), $GUI_CHECKED) = $GUI_CHECKED which isn't technically correct in your case. Secondly you declare $aGNUM & $aRSLT the Start but of course they will change when a user selects a different Size, so have a look at ReDim. Here is a simple work around for now (not my best work! ) expandcollapse popup; ; BAGELS ; #AutoIt3Wrapper_UseX64=N #include <array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt('mustdeclarevars', 1) Opt('guioneventmode', 1) Global $width = 800, $height = 600, $gui010, $numl = 3, $aGTXT[11], $aRSLT[11][$numl], $aGNUM[11][$numl] Global $gui010, $hdr, $lbl10, $opts, $opt10, $opt11, $opt12, $opt13 Global $txt10 = 'Guess the number:' & @CRLF & @CRLF & ' Each digit in the number is unique (0-9)' & @CRLF & @CRLF $txt10 &= ' Guess results:' & @CRLF & @CRLF $txt10 &= ' Black - none of your numbers are correct' & @CRLF $txt10 &= ' Yellow - one of you numbers is correct but in the wrong position' & @CRLF $txt10 &= ' Red - one of your numbers is correct and in the correct position' & @CRLF init_gui() While 1 Sleep(100) WEnd Func init_gui() ReDim $aRSLT[11][$numl], $aGNUM[11][$numl] GUIDelete($gui010) $gui010 = GUICreate('Bagels', $width, $height, (@DesktopWidth - $width) / 2, (@DesktopHeight - $height) / 2) $hdr = GUICtrlCreateLabel('BAGELS', 10, 10, 780, 40, $ss_center + $ss_sunken) GUICtrlSetFont($hdr, 20, 400, 2, 'comic sans ms') GUICtrlSetColor($hdr, 0x800000) $lbl10 = GUICtrlCreateLabel('', 10, 70, 700, 150) GUICtrlSetData($lbl10, $txt10) GUICtrlSetFont($lbl10, 9, 600, 0, 'Courier New') GUISetFont(12, 800, 0, 'comic sans ms') $opts = GUICtrlCreateMenu('Options') $opt10 = GUICtrlCreateMenu("# Size", $opts) $opt11 = GUICtrlCreateMenuItem("3", $opt10) ;guictrlsetstate($opt11,$gui_checked) GUICtrlSetOnEvent($opt11, 'chg_size') $opt12 = GUICtrlCreateMenuItem("4", $opt10) GUICtrlSetOnEvent($opt12, 'chg_size') $opt13 = GUICtrlCreateMenuItem("5", $opt10) GUICtrlSetOnEvent($opt13, 'chg_size') For $i = 1 To 10 $aGTXT[$i] = GUICtrlCreateLabel('Guess # ' & StringFormat("%02d", $i) & '-', 150, 200 + ($i * 30), 120, 20) For $j = 0 To $numl - 1 $aGNUM[$i][$j] = GUICtrlCreateLabel('', 300 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) $aRSLT[$i][$j] = GUICtrlCreateLabel('', 500 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) Next Next GUISetState(@SW_SHOW) GUISetOnEvent($gui_event_close, '_fini') EndFunc ;==>init_gui Func chg_size() ConsoleWrite('at chg_size' & @CRLF) ConsoleWrite('opt11 = ' & Binary(GUICtrlRead($opt11)) & @CRLF) ConsoleWrite('opt12 = ' & Binary(GUICtrlRead($opt12)) & @CRLF) ConsoleWrite('opt13 = ' & Binary(GUICtrlRead($opt13)) & @CRLF) If @GUI_CtrlId = $opt11 Then ConsoleWrite('at chg_size' & @CRLF) $numl = 3 init_gui() EndIf If @GUI_CtrlId = $opt12 Then $numl = 4 init_gui() EndIf If @GUI_CtrlId = $opt13 Then $numl = 5 init_gui() EndIf EndFunc ;==>chg_size Func _fini() Exit EndFunc ;==>_fini I would recommend looking at passing Variables to Functions e.g. _MyFunc($WhatsthisVar) look in the Help File for an Idea! Edited January 23, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
kylomas Posted January 23, 2011 Author Share Posted January 23, 2011 (edited) guinness, thanks, the array resizing was a "miss" on my part (trying to find the "slap me" button). I looked at @gui_ctrlid but all examples that I could find used the bitand method. When I set the variable state to checked right after I create it I get 0x41 but when I click on it the value it returns is 0x44 (not checked). Any thoughts on that? I'm not sure what parms I would pass at this point, this is just the front end. When I start coding actual game play I'm sure I'll be using "black box" type functions. Am I getting your point, or not? Again, thanks, kylomas Edit : addendum guinness, used a switch stmt to implement the grid size logic and works perfectly. Did some more looking around for handling selected sub-menu items and I keep running into the bitand stuff. Can you explain what you mean by "not technically correct"? kylomas Edited January 23, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 (trying to find the "slap me" button).Look in the Help File Because you Delete the GUI all values are sort of Reset! Have a look here >> expandcollapse popup; ; BAGELS ; #AutoIt3Wrapper_UseX64=N #include <array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt('mustdeclarevars', 1) Opt('guioneventmode', 1) Global $width = 800, $height = 600, $gui010, $numl = 3, $aGTXT[11], $aRSLT[11][$numl], $aGNUM[11][$numl] Global $gui010, $hdr, $lbl10, $opts, $opt10, $opt11, $opt12, $opt13 Global $txt10 = 'Guess the number:' & @CRLF & @CRLF & ' Each digit in the number is unique (0-9)' & @CRLF & @CRLF $txt10 &= ' Guess results:' & @CRLF & @CRLF $txt10 &= ' Black - none of your numbers are correct' & @CRLF $txt10 &= ' Yellow - one of you numbers is correct but in the wrong position' & @CRLF $txt10 &= ' Red - one of your numbers is correct and in the correct position' & @CRLF init_gui() While 1 Sleep(100) WEnd Func init_gui() ReDim $aRSLT[11][$numl], $aGNUM[11][$numl] GUIDelete($gui010) $gui010 = GUICreate('Bagels', $width, $height, (@DesktopWidth - $width) / 2, (@DesktopHeight - $height) / 2) $hdr = GUICtrlCreateLabel('BAGELS', 10, 10, 780, 40, $ss_center + $ss_sunken) GUICtrlSetFont($hdr, 20, 400, 2, 'comic sans ms') GUICtrlSetColor($hdr, 0x800000) $lbl10 = GUICtrlCreateLabel('', 10, 70, 700, 150) GUICtrlSetData($lbl10, $txt10) GUICtrlSetFont($lbl10, 9, 600, 0, 'Courier New') GUISetFont(12, 800, 0, 'comic sans ms') $opts = GUICtrlCreateMenu('Options') $opt10 = GUICtrlCreateMenu("# Size", $opts) $opt11 = GUICtrlCreateMenuItem("3", $opt10) ;guictrlsetstate($opt11,$gui_checked) GUICtrlSetOnEvent($opt11, 'chg_size') $opt12 = GUICtrlCreateMenuItem("4", $opt10) GUICtrlSetOnEvent($opt12, 'chg_size') $opt13 = GUICtrlCreateMenuItem("5", $opt10) GUICtrlSetOnEvent($opt13, 'chg_size') _MenuCheck($opt11, $opt13, $numl) ; My Quick Work Around Function! For $i = 1 To 10 $aGTXT[$i] = GUICtrlCreateLabel('Guess # ' & StringFormat("%02d", $i) & '-', 150, 200 + ($i * 30), 120, 20) For $j = 0 To $numl - 1 $aGNUM[$i][$j] = GUICtrlCreateLabel('', 300 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) $aRSLT[$i][$j] = GUICtrlCreateLabel('', 500 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) Next Next GUISetState(@SW_SHOW) GUISetOnEvent($gui_event_close, '_fini') EndFunc ;==>init_gui Func chg_size() If @GUI_CtrlId = $opt11 Then $numl = 3 If @GUI_CtrlId = $opt12 Then $numl = 4 If @GUI_CtrlId = $opt13 Then $numl = 5 _MenuCheck($opt11, $opt13, $numl) ; My Quick Work Around Function! ConsoleWrite('at chg_size' & @CRLF) ; Now this should show correctly! Because before you were deleting the GUI and never setting the Check. ConsoleWrite('opt11 = ' & Binary(GUICtrlRead($opt11)) & @CRLF) ConsoleWrite('opt12 = ' & Binary(GUICtrlRead($opt12)) & @CRLF) ConsoleWrite('opt13 = ' & Binary(GUICtrlRead($opt13)) & @CRLF) init_gui() EndFunc ;==>chg_size Func _MenuCheck($MenuItemStart, $MenuItemEnd, $SelectedNumber) Local $Number = 3 For $A = $MenuItemStart To $MenuItemEnd If $Number = $SelectedNumber Then GUICtrlSetState($A, $GUI_CHECKED) Else GUICtrlSetState($A, $GUI_UNCHECKED) EndIf $Number += 1 Next EndFunc ;==>_MenuCheck Func _fini() Exit EndFunc ;==>_fini UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 I can explain why "it technically isn't correct." Because when a user selects the Number 3-5 there was no code to Check the selected item, so with the BitAND() it wouldn't work. The only way to know if a user has selected a number is using @GUI_CtrlId and then you set the number and state, from there you can check if its checked see >> expandcollapse popup; ; BAGELS ; #AutoIt3Wrapper_UseX64=N #include <array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt('mustdeclarevars', 1) Opt('guioneventmode', 1) Global $width = 800, $height = 600, $gui010, $numl = 3, $aGTXT[11], $aRSLT[11][$numl], $aGNUM[11][$numl] Global $gui010, $hdr, $lbl10, $opts, $opt10, $opt11, $opt12, $opt13 Global $txt10 = 'Guess the number:' & @CRLF & @CRLF & ' Each digit in the number is unique (0-9)' & @CRLF & @CRLF $txt10 &= ' Guess results:' & @CRLF & @CRLF $txt10 &= ' Black - none of your numbers are correct' & @CRLF $txt10 &= ' Yellow - one of you numbers is correct but in the wrong position' & @CRLF $txt10 &= ' Red - one of your numbers is correct and in the correct position' & @CRLF init_gui() While 1 Sleep(100) WEnd Func init_gui() ReDim $aRSLT[11][$numl], $aGNUM[11][$numl] GUIDelete($gui010) $gui010 = GUICreate('Bagels', $width, $height, (@DesktopWidth - $width) / 2, (@DesktopHeight - $height) / 2) $hdr = GUICtrlCreateLabel('BAGELS', 10, 10, 780, 40, $ss_center + $ss_sunken) GUICtrlSetFont($hdr, 20, 400, 2, 'comic sans ms') GUICtrlSetColor($hdr, 0x800000) $lbl10 = GUICtrlCreateLabel('', 10, 70, 700, 150) GUICtrlSetData($lbl10, $txt10) GUICtrlSetFont($lbl10, 9, 600, 0, 'Courier New') GUISetFont(12, 800, 0, 'comic sans ms') $opts = GUICtrlCreateMenu('Options') $opt10 = GUICtrlCreateMenu("# Size", $opts) $opt11 = GUICtrlCreateMenuItem("3", $opt10) ;guictrlsetstate($opt11,$gui_checked) GUICtrlSetOnEvent($opt11, 'chg_size') $opt12 = GUICtrlCreateMenuItem("4", $opt10) GUICtrlSetOnEvent($opt12, 'chg_size') $opt13 = GUICtrlCreateMenuItem("5", $opt10) GUICtrlSetOnEvent($opt13, 'chg_size') _MenuCheck($opt11, $opt13, $numl) ; My Quick Work Around Function! For $i = 1 To 10 $aGTXT[$i] = GUICtrlCreateLabel('Guess # ' & StringFormat("%02d", $i) & '-', 150, 200 + ($i * 30), 120, 20) For $j = 0 To $numl - 1 $aGNUM[$i][$j] = GUICtrlCreateLabel('', 300 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) $aRSLT[$i][$j] = GUICtrlCreateLabel('', 500 + ($j * 30), 200 + ($i * 30), 20, 20, $ss_sunken) Next Next GUISetState(@SW_SHOW) GUISetOnEvent($gui_event_close, '_fini') EndFunc ;==>init_gui Func chg_size() If @GUI_CtrlId = $opt11 Then $numl = 3 If @GUI_CtrlId = $opt12 Then $numl = 4 If @GUI_CtrlId = $opt13 Then $numl = 5 _MenuCheck($opt11, $opt13, $numl) ; My Quick Work Around Function! ConsoleWrite('at chg_size' & @CRLF) ; Now this should show correctly! Because before you were deleting the GUI and never setting the Check. ConsoleWrite('opt11 = ' & Binary(GUICtrlRead($opt11)) & @CRLF) ConsoleWrite('opt12 = ' & Binary(GUICtrlRead($opt12)) & @CRLF) ConsoleWrite('opt13 = ' & Binary(GUICtrlRead($opt13)) & @CRLF) Local $Count = 3 For $A = $opt11 To $opt13 ; Now you can see if its checked. If _IsChecked($A) Then MsgBox(0, "_IsChecked()", "OK so the Number Checked is " & $Count) $Count += 1 Next init_gui() EndFunc ;==>chg_size Func _MenuCheck($MenuItemStart, $MenuItemEnd, $SelectedNumber) Local $Number = 3 For $A = $MenuItemStart To $MenuItemEnd If $Number = $SelectedNumber Then GUICtrlSetState($A, $GUI_CHECKED) Else GUICtrlSetState($A, $GUI_UNCHECKED) EndIf $Number += 1 Next EndFunc ;==>_MenuCheck Func _IsChecked($iControl) Return BitAND(GUICtrlRead($iControl), 1) = 1 EndFunc ;==>_IsChecked Func _fini() Exit EndFunc ;==>_fini UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
kylomas Posted January 23, 2011 Author Share Posted January 23, 2011 guinness, Don't want to belabor this but I need to understand it (stubborn). I was testing the menu sub-item before I deleted the gui so I expected a change in value on-click. However, I was using guictrlread (from examples) and should have been using guictrlgetstate or using the macro you showed me. Does that sound correct?????? I'm still fuzzy on the why and where of using bitand against $gui_checked????? Thanks Again, kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 I was testing the menu sub-item before I deleted the gui so I expected a change in value on-click. However, I was using guictrlread (from examples) and should have been using guictrlgetstate or using the macro you showed me.No, when a user clicks on the Item is doesn't change the state (unlike in TrayMenu for example) so you have to find out what the user clicked (the Macro) on and then set the state manually. Once you have done this then you can use you GUICtrlRead() and BitAND() Functions after.Using GUICtrlGetState() will only Return the State so it's best to use GUICtrlRead() and BitAND() to find if it's Checked or Not.It's not the easiest thing to learn straight away. But have a look at the two examples to get an idea, thats how I did it. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
kylomas Posted January 23, 2011 Author Share Posted January 23, 2011 guinness, I got it. The problem was that I ASSUMED that a click event changed the state. My bad!! kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted January 23, 2011 Share Posted January 23, 2011 You know what they say about assumption! My problem is explaining, I would rather let the code do the talking UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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