Jump to content

Creating Menu with Open option


 Share

Recommended Posts

the code:

#include <GUIConstants.au3>

$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("?")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)

$Form1 = GUICreate("TEST", 498, 303) 
GUISetState()


While 1
   $msg = GuiGetMsg()
   Select 
   Case $msg = $GUI_EVENT_CLOSE 
      ExitLoop 

Case $msg = $fileitem
    $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")

Case $msg = $exititem
    ExitLoop

Case $msg = $aboutitem
    Msgbox(0,"About","GUI Menu Test")

Case Else
      ;;;;;;; 
   EndSelect 
WEnd

GUIDelete()

Exit

it is just an example and this should just create a simple GUI with a menu.

but instead of creating a GUI with a menu it creates one wihtout a menu and also forces to open a file (here from the menu: Open...)

i want to just have a menu and want that it opens the dialog "Choose file...." only if i press in the menu "Open..."

what do i need to change to get it working?

Link to comment
Share on other sites

i want to just have a menu and want that it opens the dialog "Choose file...." only if i press in the menu "Open..."

what do i need to change to get it working?

xXx,

I only moved one line:

$Form1 = GUICreate("TEST", 498, 303)

taurus905

#include <GUIConstants.au3>
$Form1 = GUICreate("TEST", 498, 303) 

$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("?")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)

GUISetState()


While 1
   $msg = GuiGetMsg()
   Select 
   Case $msg = $GUI_EVENT_CLOSE 
      ExitLoop 

Case $msg = $fileitem
    $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")

Case $msg = $exititem
    ExitLoop

Case $msg = $aboutitem
    Msgbox(0,"About","GUI Menu Test")

Case Else
     ;;;;;;; 
   EndSelect 
WEnd

GUIDelete()

Exit

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

xXx,

I only moved one line:

$Form1 = GUICreate("TEST", 498, 303)

taurus905

#include <GUIConstants.au3>
$Form1 = GUICreate("TEST", 498, 303) 

$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$helpmenu = GuiCtrlCreateMenu ("?")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)

GUISetState()
While 1
   $msg = GuiGetMsg()
   Select 
   Case $msg = $GUI_EVENT_CLOSE 
      ExitLoop 

Case $msg = $fileitem
    $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")

Case $msg = $exititem
    ExitLoop

Case $msg = $aboutitem
    Msgbox(0,"About","GUI Menu Test")

Case Else
    ;;;;;;; 
   EndSelect 
WEnd

GUIDelete()

Exit
ROFL...

thx for your help i really didnt see that

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