Sign in to follow this  
Followers 0
Ibrahim

like IE 7 tabs

15 posts in this topic

what if i want to create a GUI with a button that when i press create new tab and so on and when i exit it keeps the tabs when i open it again

Share this post


Link to post
Share on other sites



Hi,

Nothing like IE7 tabs, but it does have an "Add Tab" which adds a new tab when clicked .

Saves any tabs that have been added when exited and loads them when it's run again.

Also opens at the last tab that was exited at.

Needs Beta to run as it's using the tab udf functions from v3.2.9.4

There's definitely a better way than this to do it.. but my time for learning curve is short atm.

#include <GUIConstants.au3>
#include <GuiTab.au3>

Opt("GUIOnEventMode", 1)

Global $Ini = @ScriptDir & "\tab.ini"

$Gui = GUICreate(":-)", 300, 100)
$Tab = GUICtrlCreateTab(5, 5, 290, 90)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Gui)
GUISetState() 

Load()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    Sleep(100)
WEnd

Func Load()
    If FileExists($Ini) And IniRead($Ini, "TABS", "Count", "") > 0 Then
        Dim $IRS = IniReadSection($Ini, "NAMES")
        For $i = 1 To IniRead($Ini, "TABS", "Count", "")
            GUICtrlCreateTabItem($IRS[$i][1])
        Next
        _GUICtrlTab_SetCurSel($Tab, Int(IniRead($Ini, "TABS", "Selected", "")))
    Else
        GUICtrlCreateTabItem("Add Tab")
    EndIf
EndFunc

Func WM_NOTIFY($hWnd, $Msg)
    Dim $GGCI = GUIGetCursorInfo($Gui)
    Dim $TH = _GUICtrlTab_HitTest($Tab, $GGCI[0] - 6, $GGCI[1] - 6)
    If IsArray($GGCI) And $GGCI[4] <> 0 And $TH[0] = 0 Then
        GUISetState(@SW_DISABLE, $Gui)
        Local $Inp = InputBox("New Tab Name", "Enter a name for the new tab", "", "", 200, 140, -1, -1)
        If Not @error And $Inp <> "" Then 
            GUICtrlCreateTabItem($Inp)
            _GUICtrlTab_SetCurSel($Tab, _GUICtrlTab_GetItemCount($Tab) - 1)
        EndIf
        GUISetState(@SW_ENABLE, $Gui)
        Return
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func Close()
    IniWrite($Ini, "TABS", "Count", _GUICtrlTab_GetItemCount($Tab))
    IniWrite($Ini, "TABS", "Selected", _GUICtrlTab_GetCurSel($Tab))
    For $i = 1 To _GUICtrlTab_GetItemCount($Tab)
        IniWrite($Ini, "NAMES", "Tab" & $i,_GUICtrlTab_GetItemText($Tab, $i - 1))
    Next
    Exit
EndFunc
Cheers

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

although I updated my autoit to the beta,when i run the script it's full of undefined functions and undeclared variables

>Running AU3Check (1.54.9.0) from:d:\Program Files\AutoIt3

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(15,26) : WARNING: $WM_NOTIFY: possibly used before declaration.

GUIRegisterMsg($WM_NOTIFY,

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(15,26) : ERROR: $WM_NOTIFY: undeclared global variable.

GUIRegisterMsg($WM_NOTIFY,

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(27,79) : ERROR: _GUICtrlTab_SetCurSel(): undefined function.

_GUICtrlTab_SetCurSel($Tab, Int(IniRead($Ini, "TABS", "Selected", "")))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(35,67) : ERROR: _GUICtrlTab_HitTest(): undefined function.

Dim $TH = _GUICtrlTab_HitTest($Tab, $GGCI[0] - 6, $GGCI[1] - 6)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(41,70) : ERROR: _GUICtrlTab_GetItemCount(): undefined function.

_GUICtrlTab_SetCurSel($Tab, _GUICtrlTab_GetItemCount($Tab)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(51,66) : ERROR: _GUICtrlTab_GetCurSel(): undefined function.

IniWrite($Ini, "TABS", "Selected", _GUICtrlTab_GetCurSel($Tab)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3(53,80) : ERROR: _GUICtrlTab_GetItemText(): undefined function.

IniWrite($Ini, "NAMES", "Tab" & $i,_GUICtrlTab_GetItemText($Tab, $i - 1)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\Family\Desktop\101030\New AutoIt v3 Script.au3 - 6 error(s), 1 warning(s)

!>05:31:06 AU3Check ended.rc:2

+>05:31:07 AutoIt3Wrapper Finished

>Exit code: 0 Time: 2.084

Sorry installation problem------------>Working fine now, thanks again

cour i ask u to replace the new tab control with a button and when the new tab created can contain Listview control and some buttons and ofcourse a larger GUI,I'm not leaving all the work to u <_<

Edited by Ibrahim

Share this post


Link to post
Share on other sites

Hi,

Can do it all <_<

How about instead of a button to add a new tab , use right click on any tab and have a context menu with the option to "Add New Tab" , "Rename Tab" , "Delete Tab" ?

Cheers

Share this post


Link to post
Share on other sites

Hi,

here you go it's a directory launcher example,

It loads the folder paths of your @HomeDrive into an array then returns the array as a "|" delimited string.

Select a directory from the combo list and it opens with ShellExecute ..

#include <GUIConstants.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)

$Gui = GUICreate("Directory Launcher :-)", 250, 40, -1, -1, -1, $WS_EX_TOPMOST)
$Combo = GUICtrlCreateCombo("", 5, 10, 240, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, _SetComboData(), "Select a directory...")
GUICtrlSetOnEvent(-1, "Event")
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)
GUISetState()

While 1
    Sleep(100)
WEnd

Func Event()
    Local $cID = @GUI_CtrlId
    Switch $cID
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            If FileExists(GUICtrlRead($Combo)) Then ShellExecute(GUICtrlRead($Combo))
    EndSwitch
EndFunc

Func _SetComboData()
    Dim $FL2A = _FileListToArray(@HomeDrive, "*", 2)
    If Not @error Then
        Local $sTemp
        For $i = 1 To $FL2A[0]
            $sTemp &= @HomeDrive & "\" & $FL2A[$i] & "|"
        Next
        Return "Select a directory..." & "|" & StringTrimRight($sTemp, 1)
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

already did that,but got so many errors,which i think have something to do with the length of the array

what i'm gonna give u is a big script,simple though,loads the ini files which starts with the _ character and edit and add the keys and sections take a look at its errors (((((((hope it's not exhausting,gonna need u later !!!!))))))))))

Turk.rar

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Edited that------->

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=G:\Administrator\icons\vistaicons\vistaicons\imageres.46.ico
#AutoIt3Wrapper_outfile=save.exe
#AutoIt3Wrapper_Res_Description=Application By Ibrahim Ghorabah
#AutoIt3Wrapper_Res_Fileversion=3.1.0.0
#AutoIt3Wrapper_Res_LegalCopyright=This Is Ibrahim Ghorabah Program
#AutoIt3Wrapper_Res_Language=1033
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <File.au3>
#include <Array.au3>

;~ Opt("GUIOnEventMode", 1)




$Types = FileReadLine("temp.dat")
FileDelete("temp.dat")
$guiwidth = @DesktopWidth - 100
$guiheight = @DesktopHeight - 300
Opt('MustDeclareVars', 0)
Dim $listview, $btn_save, $btn_delete, $Btn_Exit, $msg, $Status, $ret, $count, $myini, $btn_add, $item, $initem, $no, $nooflines, $text, $edit, $btn_edit, $save, $listviewheight = @DesktopHeight - 600, $listviewwidth = @DesktopWidth - 200, $save_edit, $cancel_edit
Global $labe_edit[10], $Input[10], $text[10], $Type[20], $Types
GUICreate("المخزن", $guiwidth, $guiheight)
;~ GUICtrlCreatePic("Ets.JPG",40,$listviewheight+80,137,162,$SS_SUNKEN)
;~ GUICtrlCreatePic("mobi.JPG",180,$listviewheight+80,183,86,$SS_SUNKEN)
$listview = GUICtrlCreateListView("فئة|عدد(باكو)|س.شراء|س.بيع|أحر تعديل", 40, 30, $listviewwidth, $listviewheight)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$ListType = GUICtrlCreateCombo("", 10, 1, 150, 20)
GUICtrlSetData($ListType, _SetComboData(), "Select a directory...")
GUICtrlSetOnEvent(-1, "Event")
$btn_save = GUICtrlCreateButton("&Save", 10, $guiheight - 40, 50, 30)
$btn_delete = GUICtrlCreateButton("&Delete", 80, $guiheight - 40, 50, 30)
$btn_add = GUICtrlCreateButton("&Add", 150, $guiheight - 40, 50, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 220, $guiheight - 40, 50, 30)
$Status = GUICtrlCreateLabel("", 290, $guiheight - 40, 50, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$btn_edit = GUICtrlCreateButton("&Edit", 360, $guiheight - 40, 50, 30)
$btn_edit = GUICtrlCreateButton("&Edit", 360, $guiheight - 40, 50, 30)
$btn_LoadType = GUICtrlCreateButton("Load", 170, 1, 150, 20)
$btn_addtype = GUICtrlCreateButton("Add New", 330, 1, 150, 20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    $myini = "_" & GUICtrlRead($ListType) & ".ini"
    Select
        
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            $save = MsgBox(36, "save settings", "you wanna save settings?")
            If $save = 6 Then save()
            ExitLoop
        Case $msg = $btn_save
            save()
            
        Case $msg = $btn_delete
            _GUICtrlListViewDeleteItemsSelected($listview)
            _GUICtrlListView_SetItemSelected ($listview, 0, True)
            
            
        Case $msg = $btn_add
            add()
            
        Case $msg = $btn_edit
            edit()
            
        Case $msg = $btn_addtype
            addType()
        Case $msg = $btn_LoadType
            load()

            
            
    EndSelect
WEnd
GUIDelete()

;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;
Func save()
    $count = _GUICtrlListViewGetItemCount($listview)
    FileDelete($myini)
    For $noofitems = 0 To $count - 1
        $section = _GUICtrlListViewGetItemText($listview, $noofitems, 0)
        $quantity = _GUICtrlListViewGetItemText($listview, $noofitems, 1)
        $Buy = _GUICtrlListViewGetItemText($listview, $noofitems, 2)
        $Sell = _GUICtrlListViewGetItemText($listview, $noofitems, 3)
        $LastEdit = _GUICtrlListViewGetItemText($listview, $noofitems, 4)

        GUICtrlSetData($Status, "")
        IniWrite($myini, $section, "Quantity", $quantity)
        IniWrite($myini, $section, "Buy", $Buy)
        IniWrite($myini, $section, "Sell", $Sell)
        IniWrite($myini, $section, "LastEdit", $LastEdit)
    Next
    MsgBox(0, "MyIni", "Your state is saved")
EndFunc;==>save
;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func load()
    _GUICtrlListView_DeleteAllItems ($listview)
    $SectNames = IniReadSectionNames($myini)
    If $SectNames <> "" Then
        For $i = 1 To $SectNames [0]
            $quantity = IniRead($myini, $SectNames [$i], "Quantity", "0")
            $Buy = IniRead($myini, $SectNames [$i], "Buy", "0")
            $Sell = IniRead($myini, $SectNames [$i], "Sell", "0")
            $LastEdit = IniRead($myini, $SectNames [$i], "LastEdit", "0")
            $initem = $SectNames [$i] & "|" & $quantity & "|" & $Buy & "|" & $Sell & "|" & $LastEdit
            GUICtrlCreateListViewItem($initem, $listview)
            
        Next
    EndIf
EndFunc;==>load
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func edit()
    $no = _GUICtrlListViewGetSelectedIndices($listview)
    $text[2] = _GUICtrlListViewGetItemText($listview, $no, 1)
    $text[3] = _GUICtrlListViewGetItemText($listview, $no, 2)
    $text[4] = _GUICtrlListViewGetItemText($listview, $no, 3)
    $text[5] = _GUICtrlListViewGetItemText($listview, $no, 4)
    opennew()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $cancel_edit
                remove()
                ExitLoop
            Case $msg = $save_edit
                _GUICtrlListViewSetItemText($listview, $no, 1, GUICtrlRead($Input[2]))
                _GUICtrlListViewSetItemText($listview, $no, 2, GUICtrlRead($Input[3]))
                _GUICtrlListViewSetItemText($listview, $no, 3, GUICtrlRead($Input[4]))
                _GUICtrlListViewSetItemText($listview, $no, 4, GUICtrlRead($Input[5]))
                remove()
                ExitLoop
        EndSelect
    WEnd
    

EndFunc;==>edit

Func remove()
    GUICtrlDelete($save_edit)
    GUICtrlDelete($cancel_edit)
    For $n = 1 To 5
        Sleep(50)
        GUICtrlDelete($Input[$n])
        GUICtrlDelete($labe_edit[$n])
    Next
EndFunc;==>remove

Func add()
    opennew()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $cancel_edit
                remove()
                ExitLoop
            Case $msg = $save_edit
                $item = GUICtrlRead($Input[2]) & "|" & GUICtrlRead($Input[3]) & "|" & GUICtrlRead($Input[4]) & "|" & GUICtrlRead($Input[5]) & "|" & @MDAY & "/" & @MON & "/" & @YEAR
                _GUICtrlListViewInsertItem($listview, -1, $item)
                remove()
                ExitLoop
        EndSelect
    WEnd
EndFunc;==>add


Func addType()
    $labe_edit[1] = GUICtrlCreateLabel("النوع", 100, $listviewheight + 35)
    $Input[1] = GUICtrlCreateInput($text[1], 40, $listviewheight + 55, 150, 20)
    opennew()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $cancel_edit
                remove()
                ExitLoop
            Case $msg = $save_edit
                IniWrite("_" & GUICtrlRead($Input[1]) & ".ini", GUICtrlRead($Input[2]), "Quantity", GUICtrlRead($Input[3]))
                IniWrite("_" & GUICtrlRead($Input[1]) & ".ini", GUICtrlRead($Input[2]), "Buy", GUICtrlRead($Input[4]))
                IniWrite("_" & GUICtrlRead($Input[1]) & ".ini", GUICtrlRead($Input[2]), "Sell", GUICtrlRead($Input[5]))
                IniWrite("_" & GUICtrlRead($Input[1]) & ".ini", GUICtrlRead($Input[2]), "LastEdit", @MDAY & "/" & @MON & "/" & @YEAR)
                remove()
                ExitLoop
        EndSelect
    WEnd
    Sleep(50)
    $Types = FileReadLine("temp.dat")
    FileDelete("temp.dat")
    GUICtrlSetData($ListType, $Types)
EndFunc;==>addType

Func opennew()
    $labe_edit[2] = GUICtrlCreateLabel("الفئة", 235, $listviewheight + 35)
    $Input[2] = GUICtrlCreateInput($text[2], 210, $listviewheight + 55, 50, 20)
    Sleep(50)
    $labe_edit[3] = GUICtrlCreateLabel("ع.كروت", 285, $listviewheight + 35)
    $Input[3] = GUICtrlCreateInput($text[3], 270, $listviewheight + 55, 50, 20)
    Sleep(50)
    $labe_edit[4] = GUICtrlCreateLabel("س.شراء", 380, $listviewheight + 35)
    $Input[4] = GUICtrlCreateInput($text[4], 330, $listviewheight + 55, 100, 20)
    Sleep(50)
    $labe_edit[5] = GUICtrlCreateLabel("س.بيع", 500, $listviewheight + 35)
    $Input[5] = GUICtrlCreateInput($text[5], 440, $listviewheight + 55, 100, 20)
    Sleep(50)
    $save_edit = GUICtrlCreateButton("حفظ", 550, $listviewheight + 55, 50, 20)
    $cancel_edit = GUICtrlCreateButton("إلغاء", 610, $listviewheight + 55, 50, 20)
EndFunc;==>opennew



Func _SetComboData()
    Dim $FL2A = _FileListToArray(@ScriptDir, "_*.ini", 1)
    If Not @error Then
        Local $sTemp
        For $i = 1 To $FL2A[0]
            $FL2A[$i] = StringTrimLeft($FL2A[$i], 1)
            $FL2A[$i] = StringTrimRight($FL2A[$i], 4)
            $sTemp &= $FL2A[$i] & "|"

        Next
        Return "Select a directory..." & "|" & StringTrimRight($sTemp, 1)
    EndIf

EndFunc;==>_SetComboData

Func Event()
    Local $cID = @GUI_CtrlId
    Switch $cID
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ListType
            If FileExists(GUICtrlRead("_"&$ListType&".ini")) Then load()
    EndSwitch
EndFunc;==>Event
Edited by Ibrahim

Share this post


Link to post
Share on other sites

I'm not sure what else you need... Is there still a question? I fixed the load function that was giving me errors.

;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func load()
    _GUICtrlListView_DeleteAllItems ($listview)
    $SectNames = IniReadSectionNames($myini)
    If Not @error Then
        For $i = 1 To $SectNames [0]
            $quantity = IniRead($myini, $SectNames [$i], "Quantity", "0")
            $Buy = IniRead($myini, $SectNames [$i], "Buy", "0")
            $Sell = IniRead($myini, $SectNames [$i], "Sell", "0")
            $LastEdit = IniRead($myini, $SectNames [$i], "LastEdit", "0")
            $initem = $SectNames [$i] & "|" & $quantity & "|" & $Buy & "|" & $Sell & "|" & $LastEdit
            GUICtrlCreateListViewItem($initem, $listview)
            
        Next
    EndIf
EndFunc  ;==>load

Share this post


Link to post
Share on other sites

1st, thanks for ur help,when u add new ur load function NOT WORKING

Whats not working? Considering 90% of us don't speak the language, we can't understand it, or what it does. might make it easier to bug test... =D

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  
Followers 0