Jump to content

File->New|Open|Save|Save As


Recommended Posts

Hello my teachers and friends,

I have just written a program:

 

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstants.au3>

Global $gaDropFiles[1]


$hGUI = GUICreate("Test - Untitled *", 602, 484,- 1,- 1, -1, $WS_EX_ACCEPTFILES)
$Menue_Main = GUICtrlCreateMenu("File")
    GUICtrlCreateMenuItem("New", $Menue_Main)
    GUICtrlCreateMenuItem("Open...", $Menue_Main)
    GUICtrlCreateMenuItem("Save", $Menue_Main)
    GUICtrlCreateMenuItem("Save as...", $Menue_Main)
    GUICtrlCreateMenuItem("Exit", $Menue_Main)
$2 = GUICtrlCreateMenu("Help")
    GUICtrlCreateMenuItem("Web site FAQ...", $2)
    GUICtrlCreateMenuItem("About...", $2)
$hToolLabel = GUICtrlCreateLabel( "Tool Location", 20, 14, 88, 14)
$hToolFileInput = GUICtrlCreateInput( "", 19, 33, 474, 19)
$hToolFileButton = GUICtrlCreateButton( "Browse", 510, 31, 73, 23)
$hFileLabel = GUICtrlCreateLabel( "File Location", 21, 67, 190, 13)
$hFileInput = GUICtrlCreateInput( "", 21, 83, 358, 20)
$hPasswordLabel = GUICtrlCreateLabel( "Password", 392, 66, 82, 13)
$hPasswordInput = GUICtrlCreateInput( "", 392, 83, 101, 19,$ES_PASSWORD)
$hFileButton = GUICtrlCreateButton( "Browse", 509, 81, 74, 23)
$hURLLabel = GUICtrlCreateLabel( "URL (optional)", 21, 120, 162, 15)
$hURLCombo = GUICtrlCreateCombo( "", 23, 137, 469, 21)
GUICtrlSetData( -1, "http://www.google.com|https://www.facebook.com")
$hProgramLabel = GUICtrlCreateLabel( "Program Title", 25, 173, 150, 13)
$hProgramInput = GUICtrlCreateInput( "", 24, 193, 470, 20)
$hWebLabel = GUICtrlCreateLabel( "Program Web URL (optional)", 25, 229, 141, 14)
$hWebInput = GUICtrlCreateInput( "", 25, 247, 470, 21)
$hListFileLabel = GUICtrlCreateLabel( "Program File To Run", 25, 283, 121, 14)
$hListFile = GUICtrlCreateList( "", 26, 302, 469, 102)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$hAddButton = GUICtrlCreateButton( "Add", 511, 302, 76, 41)
$hRemoveButton = GUICtrlCreateButton( "Remove", 511, 359, 75, 40)
$hRunButton = GUICtrlCreateButton( "Run File", 196, 413, 210, 40)

GUISetState()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")
While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $GUI_EVENT_DROPPED
            For $i = 0 To UBound($gaDropFiles) - 1
            AddToList($hListFile, $gaDropFiles[$i])
            Next
         Case $hToolFileButton
            BrowsetoolFile()
         Case $hFileButton
            BrowseFile()
         Case $hAddButton
            Local $szFileDir = FileOpenDialog("Select Program Files to Run", "", "Program files (*.exe;*.msi)|All files (*.*)", 7)
            If Not @error Then
               Local $aSplit = StringSplit($szFileDir, "|")
            If Not @error Then
            For $i = 2 To $aSplit[0]
               AddToList($hListFile, StringRight($aSplit[1], 1) == "\" ? $aSplit[1] & $aSplit[$i] : $aSplit[1] & "\" & $aSplit[$i])
            Next
            Else
            AddToList($hListFile, $szFileDir)
            EndIf
            EndIf
            If @error Then
               MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
            EndIf
         Case $hRemoveButton
            RemoveSelectedFromList($hListFile)
         Case $hRunButton
    EndSwitch
Sleep(50)
WEnd


Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
Local $nSize, $pFileName
Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
For $i = 0 To $nAmt[0] - 1
$nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
$nSize = $nSize[0] + 1
$pFileName = DllStructCreate("char[" & $nSize & "]")
DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
ReDim $gaDropFiles[$i + 1]
$gaDropFiles[$i] = DllStructGetData($pFileName, 1)
$pFileName = 0
Next
EndFunc ;==>WM_DROPFILES_FUNC

Func AddToList($iList, $szContent)
If (GUICtrlSendMsg($iList, $LB_FINDSTRING, -1, $szContent) == -1) Then Return GUICtrlSendMsg($iList, $LB_ADDSTRING, 0, $szContent)
Return 0
EndFunc ;==>AddToList

Func RemoveSelectedFromList($hListFile)
Return GUICtrlSendMsg($hListFile, $LB_DELETESTRING, GUICtrlSendMsg($hListFile, $LB_GETCARETINDEX, 0, 0), 0)
EndFunc ;==>RemoveSelectedFromList

Func GetItemText($hListFile, $iIndex)
Local $tText = DllStructCreate("wchar Text[" & GUICtrlSendMsg($hListFile, $LB_GETTEXTLEN, $iIndex, 0) + 1 & "]")
_SendMessage(GUICtrlGetHandle($hListFile), $LB_GETTEXT, $iIndex, $tText, 0, "wparam", "struct*")
Return DllStructGetData($tText, "Text")
EndFunc ;==>GetItemText

Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
If @error Then Return SetError(@error, @extended, "")
If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
Return $aResult
EndFunc ;==>_SendMessage



Func BrowsetoolFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate Tool.exe", "", "Program files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hToolFileInput, $sFileOpenDialog)
    EndIf
EndFunc


Func BrowseFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate your file", "", "files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hFileInput, $sFileOpenDialog)
    EndIf
EndFunc

Okay, but i don't know create File->New|Open|Save|Save As:

10246620_290613551098711_586383077760252

After i select and choose and fill:  "browse", "Add file"... okay. Finish. I want "save" this project for next time, at next time, i only need "open" and don't need choose or fill again.

Can you show me and teach me: How to create them?

thank you so much.

Edited by anhyeuem
Link to comment
Share on other sites

anhyeuem,

I don't know what you want exactly because the menus are created.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

anhyeuem,

I don't know what you want exactly because the menus are created.

Br,

UEZ

VEry simple my friend,

When we select and choose at button: "browse", "add file",... okay, finish

i need save project with "save" 

Next time, when i "open" i don't need select and choose again, i only need open project it.

 

Edited by anhyeuem
Link to comment
Share on other sites

Try this:

#include <GuiListBox.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstants.au3>

Global $gaDropFiles[1]


$hGUI = GUICreate("Test - Untitled *", 602, 484, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Menue_File = GUICtrlCreateMenu("File")
$Menue_New = GUICtrlCreateMenuItem("New", $Menue_File)
$Menue_Open = GUICtrlCreateMenuItem("Open...", $Menue_File)
$Menue_Save = GUICtrlCreateMenuItem("Save", $Menue_File)
$Menue_SaveAs = GUICtrlCreateMenuItem("Save as...", $Menue_File)
$Menue_Exit = GUICtrlCreateMenuItem("Exit", $Menue_File)
$Menue_Help = GUICtrlCreateMenu("Help")
GUICtrlCreateMenuItem("Web site FAQ...", $Menue_Help)
GUICtrlCreateMenuItem("About...", $Menue_Help)
$hToolLabel = GUICtrlCreateLabel("Tool Location", 20, 14, 88, 14)
$hToolFileInput = GUICtrlCreateInput("", 19, 33, 474, 19)
$hToolFileButton = GUICtrlCreateButton("Browse", 510, 31, 73, 23)
$hFileLabel = GUICtrlCreateLabel("File Location", 21, 67, 190, 13)
$hFileInput = GUICtrlCreateInput("", 21, 83, 358, 20)
$hPasswordLabel = GUICtrlCreateLabel("Password", 392, 66, 82, 13)
$hPasswordInput = GUICtrlCreateInput("", 392, 83, 101, 19, $ES_PASSWORD)
$hFileButton = GUICtrlCreateButton("Browse", 509, 81, 74, 23)
$hURLLabel = GUICtrlCreateLabel("URL (optional)", 21, 120, 162, 15)
$hURLCombo = GUICtrlCreateCombo("", 23, 137, 469, 21)
GUICtrlSetData(-1, "http://www.google.com|https://www.facebook.com")
$hProgramLabel = GUICtrlCreateLabel("Program Title", 25, 173, 150, 13)
$hProgramInput = GUICtrlCreateInput("", 24, 193, 470, 20)
$hWebLabel = GUICtrlCreateLabel("Program Web URL (optional)", 25, 229, 141, 14)
$hWebInput = GUICtrlCreateInput("", 25, 247, 470, 21)
$hListFileLabel = GUICtrlCreateLabel("Program File To Run", 25, 283, 121, 14)
$hListFile = GUICtrlCreateList("", 26, 302, 469, 102)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$hAddButton = GUICtrlCreateButton("Add", 511, 302, 76, 41)
$hRemoveButton = GUICtrlCreateButton("Remove", 511, 359, 75, 40)
$hRunButton = GUICtrlCreateButton("Run File", 196, 413, 210, 40)

GUISetState()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")
While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case $GUI_EVENT_CLOSE, $Menue_Exit
            Exit
        Case $GUI_EVENT_DROPPED
            For $i = 0 To UBound($gaDropFiles) - 1
                AddToList($hListFile, $gaDropFiles[$i])
            Next
        Case $hToolFileButton
            BrowsetoolFile()
        Case $hFileButton
            BrowseFile()
        Case $hAddButton
            Local $szFileDir = FileOpenDialog("Select Program Files to Run", "", "Program files (*.exe;*.msi)|All files (*.*)", 7)
            If Not @error Then
                Local $aSplit = StringSplit($szFileDir, "|")
                If Not @error Then
                    For $i = 2 To $aSplit[0]
                        AddToList($hListFile, StringRight($aSplit[1], 1) == "\" ? $aSplit[1] & $aSplit[$i] : $aSplit[1] & "\" & $aSplit[$i])
                    Next
                Else
                    AddToList($hListFile, $szFileDir)
                EndIf
            EndIf
            If @error Then
                MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
            EndIf
        Case $hRemoveButton
            RemoveSelectedFromList($hListFile)
        Case $hRunButton

        Case $Menue_Save
            Save_Settings()
        Case $Menue_Open
            Load_Settings()
    EndSwitch
WEnd

Func Save_Settings()
    Local $sIniPath = @ScriptDir & "\Settings.ini", $sListviewItems, $i, $hListView = GUICtrlGetHandle($hListFile)
    For $i = 0 To _GUICtrlListBox_GetCount($hListView) - 1
        $sListviewItems &= _GUICtrlListBox_GetText($hListView, $i) & "|"
    Next
    IniWriteSection($sIniPath, "Settings", _
                    "hToolFileInput=" & GUICtrlRead($hToolFileInput) & @CRLF & _
                    "hFileInput=" & GUICtrlRead($hFileInput) & @CRLF & _
                    "hPasswordInput=" & GUICtrlRead($hPasswordInput) & @CRLF & _
                    "hURLCombo=" & GUICtrlRead($hURLCombo) & @CRLF & _
                    "hProgramInput=" & GUICtrlRead($hProgramInput) & @CRLF & _
                    "hWebInput=" & GUICtrlRead($hWebInput) & @CRLF & _
                    "hListFile=" & StringTrimRight($sListviewItems, 1))
    MsgBox(0, "Information", "Settings saved to " & $sIniPath)
EndFunc

Func Load_Settings()
    Local $sIniPath = FileOpenDialog("Select Ini File", "", "Ini (*.ini)", 3, "Settings.ini", $hGUI), $i
    If @error Then Return
    Local $aSettings = IniReadSection($sIniPath, "Settings")
    For $i = 1 To $aSettings[0][0]
        GUICtrlSetData(Eval($aSettings[$i][0]), $aSettings[$i][1])
    Next
EndFunc

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc   ;==>WM_DROPFILES_FUNC

Func AddToList($iList, $szContent)
    If (GUICtrlSendMsg($iList, $LB_FINDSTRING, -1, $szContent) == -1) Then Return GUICtrlSendMsg($iList, $LB_ADDSTRING, 0, $szContent)
    Return 0
EndFunc   ;==>AddToList

Func RemoveSelectedFromList($hListFile)
    Return GUICtrlSendMsg($hListFile, $LB_DELETESTRING, GUICtrlSendMsg($hListFile, $LB_GETCARETINDEX, 0, 0), 0)
EndFunc   ;==>RemoveSelectedFromList

Func GetItemText($hListFile, $iIndex)
    Local $tText = DllStructCreate("wchar Text[" & GUICtrlSendMsg($hListFile, $LB_GETTEXTLEN, $iIndex, 0) + 1 & "]")
    _SendMessage(GUICtrlGetHandle($hListFile), $LB_GETTEXT, $iIndex, $tText, 0, "wparam", "struct*")
    Return DllStructGetData($tText, "Text")
EndFunc   ;==>GetItemText

;~ Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
;~  Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
;~  If @error Then Return SetError(@error, @extended, "")
;~  If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
;~  Return $aResult
;~ EndFunc   ;==>_SendMessage

Func BrowsetoolFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate Tool.exe", "", "Program files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hToolFileInput, $sFileOpenDialog)
    EndIf
EndFunc   ;==>BrowsetoolFile


Func BrowseFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate your file", "", "files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hFileInput, $sFileOpenDialog)
    EndIf
EndFunc   ;==>BrowseFile

To implement the rest is a homework for you. ;)

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@anhyeuem:

What you expected may be a MRU (most-recently-used) menu, like this?

figure1.jpg

(image from Google, I'm too lazy to capture my screen :sweating:  )

If it's what you want, you may have 2 options to produce:

1. When you open a file, save an entry (the file path) in the Regedit. The next time your program opened, retrieve info in that storage and create the MRU menu, or

2. When open a file, save an entry in a setting file. The next time, retrieve info from that file to create your menu.

That's the idea, I think it's pretty simple, so may be a good exercise for you  :evil:

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

Try this:

#include <GuiListBox.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstants.au3>

Global $gaDropFiles[1]


$hGUI = GUICreate("Test - Untitled *", 602, 484, -1, -1, -1, $WS_EX_ACCEPTFILES)
$Menue_File = GUICtrlCreateMenu("File")
$Menue_New = GUICtrlCreateMenuItem("New", $Menue_File)
$Menue_Open = GUICtrlCreateMenuItem("Open...", $Menue_File)
$Menue_Save = GUICtrlCreateMenuItem("Save", $Menue_File)
$Menue_SaveAs = GUICtrlCreateMenuItem("Save as...", $Menue_File)
$Menue_Exit = GUICtrlCreateMenuItem("Exit", $Menue_File)
$Menue_Help = GUICtrlCreateMenu("Help")
GUICtrlCreateMenuItem("Web site FAQ...", $Menue_Help)
GUICtrlCreateMenuItem("About...", $Menue_Help)
$hToolLabel = GUICtrlCreateLabel("Tool Location", 20, 14, 88, 14)
$hToolFileInput = GUICtrlCreateInput("", 19, 33, 474, 19)
$hToolFileButton = GUICtrlCreateButton("Browse", 510, 31, 73, 23)
$hFileLabel = GUICtrlCreateLabel("File Location", 21, 67, 190, 13)
$hFileInput = GUICtrlCreateInput("", 21, 83, 358, 20)
$hPasswordLabel = GUICtrlCreateLabel("Password", 392, 66, 82, 13)
$hPasswordInput = GUICtrlCreateInput("", 392, 83, 101, 19, $ES_PASSWORD)
$hFileButton = GUICtrlCreateButton("Browse", 509, 81, 74, 23)
$hURLLabel = GUICtrlCreateLabel("URL (optional)", 21, 120, 162, 15)
$hURLCombo = GUICtrlCreateCombo("", 23, 137, 469, 21)
GUICtrlSetData(-1, "http://www.google.com|https://www.facebook.com")
$hProgramLabel = GUICtrlCreateLabel("Program Title", 25, 173, 150, 13)
$hProgramInput = GUICtrlCreateInput("", 24, 193, 470, 20)
$hWebLabel = GUICtrlCreateLabel("Program Web URL (optional)", 25, 229, 141, 14)
$hWebInput = GUICtrlCreateInput("", 25, 247, 470, 21)
$hListFileLabel = GUICtrlCreateLabel("Program File To Run", 25, 283, 121, 14)
$hListFile = GUICtrlCreateList("", 26, 302, 469, 102)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$hAddButton = GUICtrlCreateButton("Add", 511, 302, 76, 41)
$hRemoveButton = GUICtrlCreateButton("Remove", 511, 359, 75, 40)
$hRunButton = GUICtrlCreateButton("Run File", 196, 413, 210, 40)

GUISetState()
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")
While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
        Case $GUI_EVENT_CLOSE, $Menue_Exit
            Exit
        Case $GUI_EVENT_DROPPED
            For $i = 0 To UBound($gaDropFiles) - 1
                AddToList($hListFile, $gaDropFiles[$i])
            Next
        Case $hToolFileButton
            BrowsetoolFile()
        Case $hFileButton
            BrowseFile()
        Case $hAddButton
            Local $szFileDir = FileOpenDialog("Select Program Files to Run", "", "Program files (*.exe;*.msi)|All files (*.*)", 7)
            If Not @error Then
                Local $aSplit = StringSplit($szFileDir, "|")
                If Not @error Then
                    For $i = 2 To $aSplit[0]
                        AddToList($hListFile, StringRight($aSplit[1], 1) == "\" ? $aSplit[1] & $aSplit[$i] : $aSplit[1] & "\" & $aSplit[$i])
                    Next
                Else
                    AddToList($hListFile, $szFileDir)
                EndIf
            EndIf
            If @error Then
                MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
            EndIf
        Case $hRemoveButton
            RemoveSelectedFromList($hListFile)
        Case $hRunButton

        Case $Menue_Save
            Save_Settings()
        Case $Menue_Open
            Load_Settings()
    EndSwitch
WEnd

Func Save_Settings()
    Local $sIniPath = @ScriptDir & "\Settings.ini", $sListviewItems, $i, $hListView = GUICtrlGetHandle($hListFile)
    For $i = 0 To _GUICtrlListBox_GetCount($hListView) - 1
        $sListviewItems &= _GUICtrlListBox_GetText($hListView, $i) & "|"
    Next
    IniWriteSection($sIniPath, "Settings", _
                    "hToolFileInput=" & GUICtrlRead($hToolFileInput) & @CRLF & _
                    "hFileInput=" & GUICtrlRead($hFileInput) & @CRLF & _
                    "hPasswordInput=" & GUICtrlRead($hPasswordInput) & @CRLF & _
                    "hURLCombo=" & GUICtrlRead($hURLCombo) & @CRLF & _
                    "hProgramInput=" & GUICtrlRead($hProgramInput) & @CRLF & _
                    "hWebInput=" & GUICtrlRead($hWebInput) & @CRLF & _
                    "hListFile=" & StringTrimRight($sListviewItems, 1))
    MsgBox(0, "Information", "Settings saved to " & $sIniPath)
EndFunc

Func Load_Settings()
    Local $sIniPath = FileOpenDialog("Select Ini File", "", "Ini (*.ini)", 3, "Settings.ini", $hGUI), $i
    If @error Then Return
    Local $aSettings = IniReadSection($sIniPath, "Settings")
    For $i = 1 To $aSettings[0][0]
        GUICtrlSetData(Eval($aSettings[$i][0]), $aSettings[$i][1])
    Next
EndFunc

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
EndFunc   ;==>WM_DROPFILES_FUNC

Func AddToList($iList, $szContent)
    If (GUICtrlSendMsg($iList, $LB_FINDSTRING, -1, $szContent) == -1) Then Return GUICtrlSendMsg($iList, $LB_ADDSTRING, 0, $szContent)
    Return 0
EndFunc   ;==>AddToList

Func RemoveSelectedFromList($hListFile)
    Return GUICtrlSendMsg($hListFile, $LB_DELETESTRING, GUICtrlSendMsg($hListFile, $LB_GETCARETINDEX, 0, 0), 0)
EndFunc   ;==>RemoveSelectedFromList

Func GetItemText($hListFile, $iIndex)
    Local $tText = DllStructCreate("wchar Text[" & GUICtrlSendMsg($hListFile, $LB_GETTEXTLEN, $iIndex, 0) + 1 & "]")
    _SendMessage(GUICtrlGetHandle($hListFile), $LB_GETTEXT, $iIndex, $tText, 0, "wparam", "struct*")
    Return DllStructGetData($tText, "Text")
EndFunc   ;==>GetItemText

;~ Func _SendMessage($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iReturn = 0, $wParamType = "wparam", $lParamType = "lparam", $sReturnType = "lresult")
;~  Local $aResult = DllCall("user32.dll", $sReturnType, "SendMessageW", "hwnd", $hWnd, "uint", $iMsg, $wParamType, $wParam, $lParamType, $lParam)
;~  If @error Then Return SetError(@error, @extended, "")
;~  If $iReturn >= 0 And $iReturn <= 4 Then Return $aResult[$iReturn]
;~  Return $aResult
;~ EndFunc   ;==>_SendMessage

Func BrowsetoolFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate Tool.exe", "", "Program files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hToolFileInput, $sFileOpenDialog)
    EndIf
EndFunc   ;==>BrowsetoolFile


Func BrowseFile()
    Local $sFileOpenDialog = FileOpenDialog("Locate your file", "", "files (*.exe)")
    If @error Then
        MsgBox($MB_ICONERROR, "", "No file(s) were selected.")
    Else
        GUICtrlSetData($hFileInput, $sFileOpenDialog)
    EndIf
EndFunc   ;==>BrowseFile

To implement the rest is a homework for you. ;)

Br,

UEZ

My friend

Maybe, i'm going to get good mark: A+++

I need this code very much.

I have just known link:

'?do=embed' frameborder='0' data-embedContent>>

Hehe

Thank you so much.

Can you answer me a question?

When I use: File->new -> remove all  options

 

Link to comment
Share on other sites

@anhyeuem:

What you expected may be a MRU (most-recently-used) menu, like this?

figure1.jpg

(image from Google, I'm too lazy to capture my screen :sweating:  )

If it's what you want, you may have 2 options to produce:

1. When you open a file, save an entry (the file path) in the Regedit. The next time your program opened, retrieve info in that storage and create the MRU menu, or

2. When open a file, save an entry in a setting file. The next time, retrieve info from that file to create your menu.

That's the idea, I think it's pretty simple, so may be a good exercise for you  :evil:

this is a perfect idea for me. I am going to think and make it.

but if you can write a few lines code for me

Thanks

Link to comment
Share on other sites

My friend

Maybe, i'm going to get good mark: A+++

I need this code very much.

I have just known link:

'?do=embed' frameborder='0' data-embedContent>>

Hehe

Thank you so much.

Can you answer me a question?

When I use: File->new -> remove all  options

I will not do your complete homework - that would not be fair to the other classmates.   ;) 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@anhyeuem:
So, first, I want to clarify exactly what you want to acquire:

  • When you open your program and select the File menu, there are some menu items which you can use to open recently file, as my suggestion, or
  • When you open your program and select the menu item Open from the File menu then a dialog will open, and you can select your previous opened file from it, like this link: '?do=embed' frameborder='0' data-embedContent>>

Case 2, the question in that link has already an answer. You need to follow the answer's instruction to get what you expected. 
 

When I use: File->new -> remove all  options

What exactly is your question? 
 
Case 1, something like this:

; When you create the window

;$idMnuRecent = GUICtrlCreateMenuItem(...)
Local $aFiles = GetRecentlyOpenedFile()
Local $aidRecent[0]
If ($aFiles[0] > 0) Then
    ReDim $aidRecent[$aFiles[0]]
    For $i = 1 To $aFiles[0]
        $aidRecent[$i - 1] = GUICtrlCreateMenuItem($aFiles[$i], $idMnuRecent)
    Next
EndIf

; And the function to get and save the file list:
Func GetRecentlyOpenedFile()
    Local $sFiles = IniRead($CONST_SETTING_PATH, 'General', 'RecentlyOpened', '')
    If ($sFiles == '') Then
        Local $aRet[1] = [0]
        Return $aRet
    EndIf
    Return StringSplit($sFiles, '|')
EndFunc

Func AddRecentlyOpenedFile($sFile)
    Local $sFiles = IniRead($CONST_SETTING_PATH, 'General', 'RecentlyOpened', '')
    If ($sFiles == '') Then
        IniWrite($CONST_SETTING_PATH, 'General', 'RecentlyOpened', $sFile)
    Else
        Local $aFiles = 
        For $sFl in $aFiles
            If ($sFl = $sFile) Then Return
        Next
        IniWrite($CONST_SETTING_PATH, 'General', 'RecentlyOpened', $sFiles & '|' & $sFile)
    EndIf
EndFunc

I think it's enough example. You will need to calm down and exercise if you want to get A mark (not A+, it is usually only given to a unexpected smart solution  :evil:

PS: If you find it hard to write your question in English, than use Google translate  :sweating:  don't trying to "simplize" your sentences and we must use 1000% BPU (brain processing unit  o:) ) to try to understand what you try to ask  :sweating:

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

I will not do your complete homework - that would not be fair to the other classmates.   ;)

Br,

UEZ

Haha

Lol

My homework is at "Run button". it will total config and run. But i want get good mark, therefore i create File->New|Open|Save|Save As. :D

Don't worry my friend, Pupil from my school and my classmates always visit our forum. 

This topic is public. 

Thank you so much for the last time.

if possible please help me.

New idea: add more language: Multilingual(French,Russian...)

-> A++++++ :D

Link to comment
Share on other sites

@anhyeuem:

So, first, I want to clarify exactly what you want to acquire:

  • When you open your program and select the File menu, there are some menu items which you can use to open recently file, as my suggestion, or
  • When you open your program and select the menu item Open from the File menu then a dialog will open, and you can select your previous opened file from it, like this link: '?do=embed' frameborder='0' data-embedContent>>

Case 2, the question in that link has already an answer. You need to follow the answer's instruction to get what you expected. 

 

What exactly is your question? 

 

Case 1, something like this:

; When you create the window

;$idMnuRecent = GUICtrlCreateMenuItem(...)
Local $aFiles = GetRecentlyOpenedFile()
Local $aidRecent[0]
If ($aFiles[0] > 0) Then
    ReDim $aidRecent[$aFiles[0]]
    For $i = 1 To $aFiles[0]
        $aidRecent[$i - 1] = GUICtrlCreateMenuItem($aFiles[$i], $idMnuRecent)
    Next
EndIf

; And the function to get and save the file list:
Func GetRecentlyOpenedFile()
    Local $sFiles = IniRead($CONST_SETTING_PATH, 'General', 'RecentlyOpened', '')
    If ($sFiles == '') Then
        Local $aRet[1] = [0]
        Return $aRet
    EndIf
    Return StringSplit($sFiles, '|')
EndFunc

Func AddRecentlyOpenedFile($sFile)
    Local $sFiles = IniRead($CONST_SETTING_PATH, 'General', 'RecentlyOpened', '')
    If ($sFiles == '') Then
        IniWrite($CONST_SETTING_PATH, 'General', 'RecentlyOpened', $sFile)
    Else
        Local $aFiles = 
        For $sFl in $aFiles
            If ($sFl = $sFile) Then Return
        Next
        IniWrite($CONST_SETTING_PATH, 'General', 'RecentlyOpened', $sFiles & '|' & $sFile)
    EndIf
EndFunc

I think it's enough example. You will need to calm down and exercise if you want to get A mark (not A+, it is usually only given to a unexpected smart solution  :evil:

PS: If you find it hard to write your question in English, than use Google translate  :sweating:  don't trying to "simplize" your sentences and we must use 1000% BPU (brain processing unit  o:) ) to try to understand what you try to ask  :sweating:

Oh, you're a good friend.

althought, you don't know 100% my question but you're still trying to help me. 

I'm very happy for that. Thank you so much.

Yes: File->New|Open|Save|Save As: I want they like other program.  Maybe, everyone can understand what I want:

+ New: create new project

+ Save: save project

+ Open: open project was saved before

Blahblah...

Now, i don't know create "new"

Open|Save:  MrUEZ helped me.

New idea: i want add more language: Multilingual(French,Russian...)

Link to comment
Share on other sites

Don't worry my friend, Pupil from my school and my classmates always visit our forum. 

 

Doing so many parts of your homework is not only unfair to your classmate but also unfair to you. Yes, you need to thinking and try to doing the tasks yourself if you want to learn to program the right way.

I replied to you right after waking up this morning and my brain is not fully well performed  :sweating: . Now I understand what you means

Now, i don't know create "new"

 

Did you mean, you don't know how to implement the "new" functionality? (Implement is not equal to create, you created the menu, but after that did not know how to do with the menu you have created to make it works, right?)

When your new button is clicked, execute a function: If the current work is not saved yet, then display a dialog to ask users to save first. The remaining tasks is so simple, clear all input fields, to make your program like the one the user saw right after he/she run your program.

 

New idea: i want add more language: Multilingual(French,Russian...)

 

The idea of ML is nice. For each language, you should store the translated sentences in a separated file, and read from that file to display the right sentences.

Maybe I'm little curious, but I wonder what school teaching AutoIt in Vietnam? I think AutoIt has become more and more popular, but it's still not the chosen programming language to teach at school, and Pascal is the one, right?

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

Doing so many parts of your homework is not only unfair to your classmate but also unfair to you. Yes, you need to thinking and try to doing the tasks yourself if you want to learn to program the right way.

I replied to you right after waking up this morning and my brain is not fully well performed  :sweating: . Now I understand what you means

 

Did you mean, you don't know how to implement the "new" functionality? (Implement is not equal to create, you created the menu, but after that did not know how to do with the menu you have created to make it works, right?)

When your new button is clicked, execute a function: If the current work is not saved yet, then display a dialog to ask users to save first. The remaining tasks is so simple, clear all input fields, to make your program like the one the user saw right after he/she run your program.

 

The idea of ML is nice. For each language, you should store the translated sentences in a separated file, and read from that file to display the right sentences.

Maybe I'm little curious, but I wonder what school teaching AutoIt in Vietnam? I think AutoIt has become more and more popular, but it's still not the chosen programming language to teach at school, and Pascal is the one, right?

Only create "new"

Multilingual: i finished :D

I'm  also a hard worker. I will not stand waiting for you, i will research and made.

But if you help me or exchange knowledge with me, everything will be easier.

in place of (in lieu of) blame me, please provide ideas or your code.

i will happy for that

thanks

Link to comment
Share on other sites

@anhyeuem:

I think we need to solve the language problem before solving the programming problem  :sweating:

I'm Vietnamese  :sweating:  and you can send a message to me (view my profile and you will see a 'Send me a message' button.

I cannot help you until I understand what you ask.

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

@anhyeuem:

I think we need to solve the language problem before solving the programming problem  :sweating:

I'm Vietnamese  :sweating:  and you can send a message to me (view my profile and you will see a 'Send me a message' button.

I cannot help you until I understand what you ask.

Lol

everyone could understand me but you do not understand me. This is very poor for me.

I want everything is public: Why? 

Because if a newbie or someone have a similar problem, they can search this topic then they can understand.

->>> Our life (you and me) better than yesterday

There will be no right answer to "What makes your life better?" But I always try for that. I also seeks to create a better life by striving to realize the aspirations and dreams of me and all the people around the world. This is the ultimate goal of me.

Have a good time

Link to comment
Share on other sites

@anhyeuem:

Ya.. ya.. I know it's better to keep questions and answers public. It's the reason this forum created.

I mean, you can PM me about the question, in our language, and I can translate and post it here, and everyone will have a better discussion, about programming. It saves lots of time reading and guessing, solving the language problem, and saves lots of forum resources.

Best regard!

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to comment
Share on other sites

@anhyeuem:

Ya.. ya.. I know it's better to keep questions and answers public. It's the reason this forum created.

I mean, you can PM me about the question, in our language, and I can translate and post it here, and everyone will have a better discussion, about programming. It saves lots of time reading and guessing, solving the language problem, and saves lots of forum resources.

Best regard!

English:

Oh, i want when select File->New it will automatic remove options - as first time run program

Very simple :D

Translate google to Vietnamese:

Oh, rất đơn giản, tôi muốn khi bấm vào File->New thì nó sẽ chẳng khác gì các chương trình khác, là làm mới, và xóa hết các tùy chọn dã lựa chọn trc đó. Giống như lần đầu chạy chương trình vậy. :P Hú hú

 

Edited by anhyeuem
Link to comment
Share on other sites

English:

Oh, i want when select File->New it will automatic remove options - as first time run program

Very simple :D

Translate google to Vietnamese:

Oh, rất đơn giản, tôi muốn khi bấm vào File->New thì nó sẽ chẳng khác gì các chương trình khác, là làm mới, và xóa hết các tùy chọn dã lựa chọn trc đó. Giống như lần đầu chạy chương trình vậy. :P Hú hú

 

Oh, File->New: Finished

Case $Menue_New
            GUICtrlSetData($hToolFileInput, "")
            GUICtrlSetData($hFileInput, "")
....blahblah
Link to comment
Share on other sites

And, that was exactly what I said  :ermm:
It's not about create a New menu item. A single line did that!

$idItemNew = GUICtrlCreateMenuItem('New', $idMenuFile)

 
What you means is implementing functionality for the New menu item you have created.

While 1
  Swich GUIGetMsg()
    Case -3
      ExitLoop
    Case $idItemNew
      DoNew()
  EndSwitch
WEnd

Func DoNew()
  ; Do works when user click New menu item. This called 'implement' not 'create'!!!
  GUICtrlSetData($hToolFileInput, "")
  GUICtrlSetData($hFileInput, "")
EndFunc

 
That was totally the language problem. And that was the reason why I need a meaningful translation. Also note that you should not post a comment in other language than English. This is a global forum and people from many country visited to learn, research and find what they need. They should not need a translate engine to understand what you wrote. That was the reason why I asked you PM me.
Any other questions?

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

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