billthecreator Posted January 18, 2009 Share Posted January 18, 2009 (edited) So i have my weather program in my signature. And i want to make menu items of the 5 resent searches made. how would i go about doing that? So far i have that the menu items will be called from an ini file. The only problem i have is that i dont know how to get the message of each menu like that. shown below $HistoryMen = GUICtrlCreateMenu("&History") $HistoryVar = IniReadSection(@AppDataDir & "\WeatherTray\WeatherGadget.ini", "History") If Not @error Then For $i = 1 To $HistoryVar[0][0] $Hist[$i] = GUICtrlCreateMenuItem($HistoryVar[$i][1], $HistoryMen) ;this part i got Next EndIf ;its this whole part that i dont get While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Hist[1] To $Hist[5] _GetWeatherInfo(StringTrimRight(GUICtrlRead(-1),8),1) EndSwitch Wend Edited January 18, 2009 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 18, 2009 Moderators Share Posted January 18, 2009 Not the greatest way to pull it off, but it works. expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> GUICreate("My GUI menu", 300, 200) Global $aHist Global $hHistoryMen = GUICtrlCreateMenu("&History") Global $aHistoryVar = IniReadSection(@ScriptDir & "\WeatherGadget.ini", "History") ;~ _ArrayDisplay($aHistoryVar) If Not @error Then Dim $aHist[$aHistoryVar[0][0] + 1] For $i = 1 To $aHistoryVar[0][0] $aHist[$i] = GUICtrlCreateMenuItem($aHistoryVar[$i][1], $hHistoryMen) ;this part i got Next EndIf GUISetState() ;its this whole part that i dont get While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $aHist[1] To $aHist[UBound($aHist) - 1] For $i = 1 To UBound($aHist) - 1 If $nMsg = $aHist[$i] Then ConsoleWrite($i & @CR) _GetWeatherInfo(StringTrimRight(GUICtrlRead($aHist[$i]), 8), 1) EndIf Next EndSwitch WEnd Func _GetWeatherInfo($Parm1, $Parm2) ; EndFunc ;==>_GetWeatherInfo Link to comment Share on other sites More sharing options...
billthecreator Posted January 18, 2009 Author Share Posted January 18, 2009 sorry. i cant seem to get it to work... [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 18, 2009 Moderators Share Posted January 18, 2009 sorry. i cant seem to get it to work...Well...you started off good by posting example code, but now you don't even state what it is you can't get to work.I posted a self contained "working" example. If you can't figure it out from there or at least state what exactly you can't get to work, I'm not sure anyone can help you. Link to comment Share on other sites More sharing options...
smashly Posted January 18, 2009 Share Posted January 18, 2009 (edited) Hi, untested$HistoryMen = GUICtrlCreateMenu("&History") $HistoryVar = IniReadSection(@AppDataDir & "\WeatherTray\WeatherGadget.ini", "History") If Not @error Then For $i = 1 To $HistoryVar[0][0] $Hist[$i] = GUICtrlCreateMenuItem($HistoryVar[$i][1], $HistoryMen) ;this part i got Next EndIf ;its this whole part that i dont get While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Hist[1] To $Hist[Ubound($Hist) -1] _GetWeatherInfo(StringTrimRight(GUICtrlRead($nMsg, 1),8),1) EndSwitch Wend Edit: corrected Case & GUICtrlRead Edited January 18, 2009 by smashly Link to comment Share on other sites More sharing options...
rasim Posted January 18, 2009 Share Posted January 18, 2009 Another way: Opt("GuiOnEventMode", 1) $HistoryMen = GUICtrlCreateMenu("&History") $HistoryVar = IniReadSection(@AppDataDir & "\WeatherTray\WeatherGadget.ini", "History") If Not @error Then For $i = 1 To $HistoryVar[0][0] $Hist[$i] = GUICtrlCreateMenuItem($HistoryVar[$i][1], $HistoryMen) ;this part i got GUICtrlSetOnEvent($Hist[$i], "_GetWeatherInfo") Next EndIf While 1 Sleep(100) WEnd Func _GetWeatherInfo() ConsoleWrite("Menu Item ID: " & @GUI_CtrlId & @CRLF) EndFunc Link to comment Share on other sites More sharing options...
billthecreator Posted January 18, 2009 Author Share Posted January 18, 2009 the only thing that doesnt work is when you click on the menu item. it does nothing... i tried the Guictrlread($hist, 1) with the advanced option. and nothing... [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
billthecreator Posted January 18, 2009 Author Share Posted January 18, 2009 (edited) Another way: Opt("GuiOnEventMode", 1) $HistoryMen = GUICtrlCreateMenu("&History") $HistoryVar = IniReadSection(@AppDataDir & "\WeatherTray\WeatherGadget.ini", "History") If Not @error Then For $i = 1 To $HistoryVar[0][0] $Hist[$i] = GUICtrlCreateMenuItem($HistoryVar[$i][1], $HistoryMen) ;this part i got GUICtrlSetOnEvent($Hist[$i], "_GetWeatherInfo") Next EndIf While 1 Sleep(100) WEnd Func _GetWeatherInfo() ConsoleWrite("Menu Item ID: " & @GUI_CtrlId & @CRLF) EndFuncoÝ÷ Ûú®¢×¡ë'¶ØZµØ¬i¹^¶ º(¶k ~éܶ*'j[(ûayû§rبZ(ÉbëaÆ®¶sdgVæ2ôvWEvVFW$æfòb33c¶æfòÒb33c´VFEFÂb33c¶÷BÒ 7vF6b33c¶÷@ 66R bb33c¶æfòÒb33c´VFEF÷"b33c¶æfòÒgV÷C²gV÷C²FVà &WGW&âõ6WDW'&÷"ÂgV÷C²gV÷C²oÝ÷ Ú0Â¥te ÚåIëNKÞÝ7èx¬·Mú«¨´gYæêÈú*ºe¢jëwvÚ.±ëayø«²ÚZ©µêí¡·°«Z¦Þê®j[%G§¢¹çîËb¢{jY^vX¤zØb±«¢+Ù}Ñ]Ñ¡É%¹¼¡MÑÉ¥¹QÉ¥µI¥¡Ð¡U% ÑɱI ÀÌØí1°È¤°à¤°Ä ill try it... Edited January 18, 2009 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
rasim Posted January 18, 2009 Share Posted January 18, 2009 @billthecreator also. if the function looks like this: how would GUICtrlSetOnEvent($Hist[$i], "_GetWeatherInfo") look. cause i need to use the first parameter to be what a label equalsOpt("GuiOnEventMode", 1) $HistoryMen = GUICtrlCreateMenu("&History") $HistoryVar = IniReadSection(@AppDataDir & "\WeatherTray\WeatherGadget.ini", "History") If Not @error Then For $i = 1 To $HistoryVar[0][0] $Hist[$i] = GUICtrlCreateMenuItem($HistoryVar[$i][1], $HistoryMen) ;this part i got GUICtrlSetOnEvent($Hist[$i], "_MenuItemEvent") Next EndIf While 1 Sleep(100) WEnd Func _MenuItemEvent() ConsoleWrite("Menu Item ID: " & @GUI_CtrlId & @CRLF) _GetWeatherInfo() EndFunc Func _GetWeatherInfo($info = $EditTip, $opt = 0) Switch $opt Case 0 If $info = $EditTip Or $info = "" Then Return _SetError(0, "") EndIf EndSwitch EndFunc ;==>_GetWeatherInfo Link to comment Share on other sites More sharing options...
billthecreator Posted January 18, 2009 Author Share Posted January 18, 2009 (edited) OK Thank you every body. It is now working. everything is OnEvent. Cheers to all also, please check out my weather program and see what I've done all thanks to your help. Edited January 18, 2009 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap 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