BPBNA Posted August 9, 2006 Posted August 9, 2006 I guess I posted this in the wrong forum last time so heres a link to it. Any help would be greatly appreciated.http://www.autoitscript.com/forum/index.ph...c=30369&hl=
Holger Posted August 9, 2006 Posted August 9, 2006 Just like: expandcollapse popup#include <GUIConstants.au3> GUICreate("My GUI menu", 300, 200) Global $defaultstatus = "Ready" Global $status Dim $count = 0 Dim $lastindex = 0 Dim $maxrecentfiles = 5 ; max 5 recent files Dim $recentfiles[$maxrecentfiles][2] $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuitem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") $saveitem = GUICtrlCreateMenuitem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuitem("Info", $helpmenu) $exititem = GUICtrlCreateMenuitem("Exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu ("Recent Files", $filemenu, 1) $separator1 = GUICtrlCreateMenuitem("",$filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuitem("Statusbar", $viewmenu) GUICtrlSetState(-1,$GUI_CHECKED) $okbutton = GUICtrlCreateButton("OK", 50, 130, 70, 20) GUICtrlSetState(-1,$GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOr($SS_SIMPLE, $SS_SUNKEN)) GUISetState () While 1 $msg = GUIGetMsg() Switch $msg Case $fileitem $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error = 0 Then $found = 0 For $i = 0 To $maxrecentfiles - 1 If $file = $recentfiles[$i][1] Then $found = 1 ExitLoop EndIf Next If Not $found Then $item = GUICtrlCreateMenuitem ($file, $recentfilesmenu, 0) If $count > $maxrecentfiles - 1 Then GUICtrlDelete($recentfiles[$lastindex][0]) EndIf $recentfiles[$lastindex][0] = $item $recentfiles[$lastindex][1] = $file $lastindex = $lastindex + 1 If $lastindex = $maxrecentfiles Then $lastindex = 0 $count = $count + 1 EndIf EndIf Case $viewstatusitem If BitAnd(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf Case $GUI_EVENT_CLOSE, $cancelbutton, $exititem ExitLoop Case $infoitem Msgbox(0, "Info", "Only a test...") Case Else For $i = 0 To $maxrecentfiles - 1 If $msg > 0 And $msg = $recentfiles[$i][0] Then $file = $recentfiles[$i][1] ; now you have the file that was clicked Msgbox(0, "Open File", $file) ExitLoop EndIf Next EndSwitch WEnd GUIDelete() Exit Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
BPBNA Posted August 9, 2006 Author Posted August 9, 2006 Perfect! Thanks for the help! It works great.
DjDeep00 Posted August 10, 2006 Posted August 10, 2006 Is there a way to delete a specific menu item(recent files) that was create earlier?
DjDeep00 Posted August 10, 2006 Posted August 10, 2006 Nevermind I got it... GUICtrlDelete($recentfiles[$index][0])
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