#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <Misc.au3>
GUICreate("Любимые ссылки", 500, 500)
Local $idMenu = GUICtrlCreateMenu("Команды")
Local $idItem1 = GUICtrlCreateMenuItem("Добавить ссылку", $idMenu)
Local $idItem2 = GUICtrlCreateMenuItem("Загрузить ссылки из файла", $idMenu)
Local $idItem3 = GUICtrlCreateMenuItem("Сохранить ссылки в файл", $idMenu)
Local $idItem4 = GUICtrlCreateMenuItem("Выход", $idMenu)
Local $idTreeview = GUICtrlCreateTreeView(6, 6, 450, 450, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $Values[1024]
Local $counterlink = 0
Local $iTreeView_Flag = false
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $idItem1
$linktext = InputBox ( "добавить ссылку", "введите ссылку")
$Values[$counterlink] = GUICtrlCreateTreeViewItem($linktext, $idTreeview)
$counterlink = $counterlink+1
Case $idItem2
_GUICtrlTreeView_DeleteAll($idTreeview)
$hFile = FileOpen("data.txt", 0)
$counterlink = 0
For $i = 1 to _FileCountLines("data.txt")
$line = FileReadLine("data.txt", $i)
$Values[$counterlink] = GUICtrlCreateTreeViewItem($line,$idTreeview)
$counterlink = $counterlink+1
Next
Case $idItem3
$hFile = FileOpen("data.txt", 2)
for $index = 0 to $counterlink - 1
FileWrite($hFile, GUICtrlRead($Values[$index],1 ) & @CRLF)
Next
Case $idItem4
Exit
EndSwitch
If $iTreeView_Flag Then
$iTreeView_Flag = False
$urltext = _GUICtrlTreeView_GetText($idTreeview, _GUICtrlTreeView_GetSelection($idTreeview))
ShellExecute("chrome.exe", "http://" & $urltext & """")
EndIf
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
$hWndTreeview = GUICtrlGetHandle($idTreeview)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeview
Switch $iCode
Case $NM_CLICK
$iTreeView_Flag = True
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
|