Jump to content
Sign in to follow this  
Vision

Menü&Menüitem

Recommended Posts

Vision

Hi

i have created a menu and a menuitem

how i can provide that when i click on the menuitem a msg box came where a text stands and a button "Close" or something is in there, whats close the dialogbox/msgbox ?

best regards

Share this post


Link to post
Share on other sites
d4rk

GUICtrlCreateMenu()
GUISetOnEvent


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites
Vision

the msgbox is not the problem

how i can do that when i click on the menuitem the msg box pops up?

and how to close it via a button

Share this post


Link to post
Share on other sites
PsaltyDS

the msgbox is not the problem

how i can do that when i click on the menuitem the msg box pops up?

and how to close it via a button

Your script can't operate on its own MsgBox(), that required user intervention (or automation by another process).

If your msg box is a home made child GUI, then you can operate it exactly the same as your primary GUI.

How far have you gotten coding this? Does the menu item already work, and create the pop up? Did you create the pop up with GuiCreate() or with MsgBox()?

:)


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

Share this post


Link to post
Share on other sites
Ealric

#include <GUIConstants.au3>

Global $gParent = GUICreate("Test",100,100)

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("MsgBox",$filemenu)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $fileitem
            MsgBox(0,"MsgBox","Here is a default message box.")
    EndSwitch
WEnd


My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Share this post


Link to post
Share on other sites
PsaltyDS

#include <GUIConstants.au3>

Global $gParent = GUICreate("Test",100,100)

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("MsgBox",$filemenu)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $fileitem
            MsgBox(0,"MsgBox","Here is a default message box.")
    EndSwitch
WEnd
I could be misunderstanding the OP, but I thought he wanted the script to continue working, and even operate on the MsgBox() itself. The problem with this is that the script blocked (paused) until the operator answers the MsgBox().

To continue script execution would require replacing you MsgBox() with GuiCreate() for a child GUI. It would then also be easier to run the GUIs in event mode, vice GuiGetMsg() loops.

:)


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

Share this post


Link to post
Share on other sites
Vision

thanks in advance this where helpful,

but is it too possible to open a second dialog? i want to make a "about" window where some information are in it looks not so nice with a msgbox :)

some cane help me?

Share this post


Link to post
Share on other sites
PsaltyDS

thanks in advance this where helpful, but is it too possible to open a second dialog? i want to make a "about" window where some information are in it looks not so nice with a msgbox :)

some cane help me?

Then you definitely do not want MsgBox(). You should be creating a child GUI where you can set backgrounds, styles, etc. and get the look you want.

You can certainly get help here, but not someone to write it for you. Start with the code to just pop a plain GUI when the menu selection is made, then start tweaking the child GUI. You could look at Valuater's GUI skin UDF and others like it to see what's possible.

I'm more interested in the functional side of it. You will have to decide if you will do this in message or event mode. My preference is for event mode, especially with multiple GUIs involved.

:)


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

Share this post


Link to post
Share on other sites
Vision

here what i mean:

Func about_info()
GUICreate("About", 423, 259, 193, 125) ; will create a dialog box 
GUISetState (@SW_SHOW)    ; will display an empty dialog box

$okbtn = GUICtrlCreateButton("ok", 24, 80, 49, 49, 0)

While 1
    $msg2 = GUIGetMsg()
    Switch $msg2
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $okbtn 
        ;???? when i click this "ok" btn the GUI "About" must be cloesed but when i close the "About" window the main window will close too
    EndSwitch
Wend    
EndFunc

so when i click at the menu "About" the goes to hte func about_info()

and the dialog will open like i will it, but i cant close it simply :)

Share this post


Link to post
Share on other sites
PsaltyDS

here what i mean:

Func about_info()
GUICreate("About", 423, 259, 193, 125); will create a dialog box 
GUISetState (@SW_SHOW)   ; will display an empty dialog box

$okbtn = GUICtrlCreateButton("ok", 24, 80, 49, 49, 0)

While 1
    $msg2 = GUIGetMsg()
    Switch $msg2
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $okbtn 
    ;???? when i click this "ok" btn the GUI "About" must be cloesed but when i close the "About" window the main window will close too
    EndSwitch
Wend    
EndFunc

so when i click at the menu "About" the goes to hte func about_info()

and the dialog will open like i will it, but i cant close it simply :)

If you must stick with a message loop, it would look like this:
#include <GUIConstants.au3>

Global $gParent = GUICreate("Test", 200, 200)
$filemenu = GUICtrlCreateMenu("&File")
$fileitem = GUICtrlCreateMenuItem("About 'Test'", $filemenu)
GUISetState()

While 1
    $msg = GUIGetMsg()

    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $fileitem
            about_info()
    EndSwitch
WEnd

Func about_info()
    Local $gChild = GUICreate("About", 200, 200, 200, 200, Default, Default, $gParent); will create a dialog box
    Local $label = GUICtrlCreateLabel("All about 'Test'...", 10, 10, 180, 20)
    Local $okbtn = GUICtrlCreateButton("OK", 50, 160, 100, 30)
    GUISetState(@SW_SHOW); will display dialog box

    While 1
        $msg2 = GUIGetMsg()
        If $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $okbtn Then
            GUIDelete($gChild)
            ExitLoop
        EndIf
    WEnd
EndFunc  ;==>about_info

:)


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

Share this post


Link to post
Share on other sites
Ealric

Try out this code and change the author and title. Check the Help > About and also look at the system tray icon and play with it. It should give you a few examples of how to use the about feature.

#include <GUIConstants.au3>

Global $author = "YourName"
Global $title = "YourGuiTitle"

$gParent = GUICreate($title, 423, 259, 193, 125) ; will create a dialog box
; FILE MENU START
; POSITION -1,0
$filemenu = GUICtrlCreateMenu("File")
$filenewitem = GUICtrlCreateMenuItem("New", $filemenu)
GUICtrlSetState($filenewitem, $GUI_DEFBUTTON)
$fileopenitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState($fileopenitem, $GUI_ENABLE)
GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
; FILE MENU END

; HELP MENU START
$helpmenu = GUICtrlCreateMenu("Help", -1, 2)
$aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
; HELP MENU END

; tray menu options below
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
$abttray = TrayCreateItem("About Your Program")
TrayItemSetOnEvent($abttray, "Set_ABT")
TrayCreateItem("")
$resttray = TrayCreateItem("Show")
TrayItemSetOnEvent($resttray, "_restoregui")
TrayCreateItem("")
$exittray = TrayCreateItem("Exit")
TrayItemSetOnEvent($exittray, "_exitgui")
TraySetState()
TraySetToolTip($title)

$okbtn = GUICtrlCreateButton("ok", 24, 80, 49, 49, 0)

GUISetState(@SW_SHOW, $gParent)      ; will display an empty dialog box

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $aboutitem
            Set_ABT()
     EndSwitch
Wend    


; || Set_ABT() function
; || Set_ABT works with the Help > about menu for both the context menu and the system tray.
Func Set_ABT()
    $iMsgBoxAnswer = MsgBox(32, $title & ", by  " & $author, $title & @CRLF & _ 
            "© Copyright 2008 - (All Rights Reserved)" & @CRLF & @CRLF & _
            "First Explanation Line" & @CRLF & _
            "Second Explanation Line" & @CRLF & @CRLF & _
            "Closing Line", 60)
    Select
        Case $iMsgBoxAnswer = -1 ;Timeout
    EndSelect
EndFunc   ;==>Set_ABT

Func _exitgui()
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gParent, "int", 500, "long", 0x00090000)
    Exit
EndFunc   ;==>_exitgui

Func _restoregui()
    GUISetState(@SW_RESTORE, $gParent)
EndFunc   ;==>_restoregui
Edited by Ealric

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Share this post


Link to post
Share on other sites
Ealric

Also, you can do the msgbox 2 different ways. You can use a child gui like PsaltyDS suggested (which gives you a cleaner working area if you want to add a lot of lines or change the appearance), or a simple msgbox like I showed. I personally only use a child GUI for the about portion of my script if I need to add additional functionality to the about box. Otherwise, I leave it as a simple msgbox.

If you want to use a child gui you can add PsaltyDS's about function to the script I wrote and change the function pointer to use his instead. I definitely suggest using Tray options for your message and for restore and closing. This allows you to do a lot more with the script and gives added functionality from the tray. That's why I suggested and showed it.

Thanks,


My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Share this post


Link to post
Share on other sites
Vision

thanks mates, works wonderful :) !!!

Share this post


Link to post
Share on other sites
Vision

here is my next problem >.> ^^

i want to open a file, and its not realy hard but he dont opens the file o.O?!

Func _opendoc()

$file = FileOpen("text.txt", 0)

    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        Exit
    EndIf
FileClose($file)
EndFunc

the file are in the same folder as the script, but he dont wants to open it

Share this post


Link to post
Share on other sites
d4rk

did the file "text.txt" already exist ? if not, please try

$file = FileOpen("text.txt", 1)

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
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
Sign in to follow this  

×