Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 3)

Модерирует : gyra, Maz

gyra (23-01-2020 10:51): AutoIT (Часть 4)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

Leagnus

Junior Member
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору


Код:
; http://www.autoitscript.com/forum/index.php?showtopic=20827&st=0
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
 
;===============================================================================
; FileName:            splitterdemo.au3
; Description:      Splitter Bar demo
;
; Requirement:      Beta;!!! with this version beta is not required
; Author(s):        eltorro (Steve Podhajecki <gehossafats@netmdc.com>) modified by Tresa
; Note(s):            This is just a proof of concept at the moment.
;                    This could be tweaked into a udf with a little more work
;                    The basic principle is to create a pic box or label and drag it
;                    then resize the controls.
;                    I bowwored some filler for the tree and list from the help files.
;===============================================================================
;$WM_SIZE =0x0005

    Global $Form1Height=448
    Global $Form1Width=622
    Global $splitWidth=5
    Global $leftVSplit=144
    Global $topHSplit=320
    Global $topMargin=6
    Global $leftMargin=4
    Global $rigthMargin=4
    Global $bottomMargin=6
    Global $statusBarHeight
 
$Form1
 = GUICreate("Splitter Demo", $Form1Width, $Form1Height,192,125, BitOr($WS_SIZEBOX,  $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU,$WS_CLIPCHILDREN))
 
$TreeView1  = GUICtrlCreateTreeView($leftMargin, $topMargin, $leftVSplit-$leftMargin, $topHSplit-$topMargin, BitOR($TVS_HASBUTTONS,  $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP,  $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $generalitem = GUICtrlCreateTreeViewItem("General", $TreeView1)
    GUICtrlSetColor(-1, 0x0000C0)
    $displayitem = GUICtrlCreateTreeViewItem("Display", $TreeView1)
    GUICtrlSetColor(-1, 0x0000C0)
    $aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
    $compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
    $useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
    $resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
    $otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
    GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))  ; Expand the "General"-item and paint in bold
    GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))  ; Expand the "Display"-item and paint in bold
 
$ListView1 = GUICtrlCreateListView("col1  |col2|col3  ", $leftVSplit+$splitWidth, $topMargin, $Form1Width-$rigthMargin-($leftVSplit+$splitWidth), $topHSplit-$topMargin, -1, $WS_EX_CLIENTEDGE)
    $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $ListView1)
    $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $ListView1)
    $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $ListView1)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState()
    GUICtrlSetData($item2, "ITEM1")
    GUICtrlSetData($item3, "||COL33")
 
;horizontal divider.
$Pic2 = GUICtrlCreatePic("", $leftMargin, $topHSplit, $Form1Width-$leftMargin-$rigthMargin, $splitWidth,$SS_NOTIFY);!!! BitOR($SS_NOTIFY, $SS_ETCHEDFRAME), $WS_EX_CLIENTEDGE)
GUICtrlSetCursor($Pic2, 11)
 
;vertical divider
$Pic1 = GUICtrlCreateLabel("", $leftVSplit, $topMargin, $splitWidth, $topHSplit-$topMargin, $SS_NOTIFY)
GUICtrlSetCursor($Pic1, 13)
 
;statusBar
Local $a[3] = [150,350, -1]
Local $b[3] = ["Ready.", "",""], $DragCtrl=""
; $Status1 = _GuiCtrlStatusBarCreate ($Form1, $a, $b)
; Local $a_rect = _GUICtrlStatusBarGetRect ($Status1, 1)
; $statusBarHeight=($a_rect[3]-$a_rect[1])

 
$Edit1 = GUICtrlCreateEdit("", $leftMargin, $topHSplit+$splitWidth, $Form1Width-$leftMargin-$rigthMargin, $Form1Height-$bottomMargin-$statusBarHeight-$topHSplit-$splitWidth, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "Drag the bars between the controls and they will resize." & @CRLF & _
        "Resize the screen and see what happens."& @CRLF & _
        "The Status bar show True the left mouse button is down and over a splitter.")
 
opt("MouseCoordMode", 2)
 
GUISetState(@SW_SHOW)
dim $precedingMsg,$stopTime
ResizeControls()
GUIRegisterMsg($WM_SIZE,"RESIZE_CONTROLS")
While 1
    $msg = GUIGetMsg()
    Select
        Case
$msg = $GUI_EVENT_PRIMARYDOWN
;             _GuiCtrlStatusBarSetText ($Status1, "Primary Down", 0)
        Case $msg = $Pic1
;             if $DragCtrl="" then _GuiCtrlStatusBarSetText ($Status1, "Pic1 Primary Down",0)
            $DragCtrl = $Pic1
 
        Case $msg = $Pic2
;             _GuiCtrlStatusBarSetText ($Status1, "Pic2 Primary Down", 0)
            $DragCtrl = $Pic2
        Case $msg = $GUI_EVENT_PRIMARYUP
;             _GuiCtrlStatusBarSetText ($Status1, "Primary Up", 0)
            saveSplitPos()
;             _GuiCtrlStatusBarSetText ($Status1, "", 1)
            Select
                Case
$DragCtrl = $Pic1
                    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
                    $DragCtrl = ""
                Case $DragCtrl = $Pic2
                    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
                    $DragCtrl = ""
            EndSelect
 
        Case $msg = $GUI_EVENT_SECONDARYDOWN
            _GuiCtrlStatusBarSetText ($Status1, "Secondary Down", 0)
        Case $msg = $GUI_EVENT_SECONDARYUP
            _GuiCtrlStatusBarSetText ($Status1, "Secondary Up", 0)
        Case $msg = $GUI_EVENT_MOUSEMOVE
            $stopTime=TimerInit()
            if $DragCtrl<>"" then
;                 _GuiCtrlStatusBarSetText ($Status1, "Dragging", 1)
                Local $picpos = ControlGetPos("", "", $DragCtrl)
                Local $mousepos = MouseGetPos()
                Local $winpos = WinGetClientSize("")
                If $DragCtrl = $Pic1 Then
                     If $mousepos[0] > 25 And $mousepos[0]<  ($winpos[0] - 25) Then GUICtrlSetPos($Pic1, $mousepos[0], $picpos[1],2)
                EndIf
                If $DragCtrl = $Pic2 Then
                     If $mousepos[1] > 25 And $mousepos[1]<  ($winpos[1] - 25) Then GUICtrlSetPos($Pic2, $picpos[0], $mousepos[1],$picpos[2],2)
                EndIf
            Else
;                 _GuiCtrlStatusBarSetText ($Status1, "Mouse Move", 0)
            EndIf
        Case $msg = $GUI_EVENT_RESIZED or $msg = $GUI_EVENT_MAXIMIZE or $msg=$GUI_EVENT_RESTORE;!!!
            ResizeControls()
            saveSplitPos()
 
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            $idleTime=TimerDiff($stopTime)
            if $idleTime>100 Then
                $stopTime=TimerInit()
                if $DragCtrl<>"" then
;                     _GuiCtrlStatusBarSetText ($Status1, "Idling", 1)
                Else
;                     _GuiCtrlStatusBarSetText ($Status1, "Idling", 0)
                EndIf
            EndIf
    EndSelect
WEnd
Exit
 
Func saveSplitPos()
    Local $winpos = WinGetClientSize("")
    $Form1Width=$winpos[0]
    $Form1Height=$winpos[1]
    Local $splitpos1 = ControlGetPos("", "", $Pic1)
    $leftVSplit=$splitpos1[0]
    Local $splitpos2 = ControlGetPos("", "", $Pic2)
    $topHSplit=$splitpos2[1]
EndFunc
 
Func RESIZE_CONTROLS($hWnd, $Msg, $wParam, $lParam)
    Local $winpos = WinGetClientSize("")
    Local $Hcoef=($winpos[0]-$leftMargin-$rigthMargin-$splitWidth)/($Form1Width-$leftMargin-$rigthMargin-$splitWidth)
    Local $Vcoef=($winpos[1]-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)/($Form1Height-$topMargin-$bottomMargin-$splitWidth-$statusBarHeight)
 
    GUICtrlSetPos($pic2,$leftMargin,$topMargin+($topHSplit-$topMargin)*$Vcoef,$winpos[0])
    GUICtrlSetPos($pic1,$leftMargin+($leftVSplit-$leftMargin)*$Hcoef,$topMargin,$splitWidth,($topHSplit-$topMargin)*$Vcoef)
 
    ResizeControls()
    Return $GUI_RUNDEFMSG
EndFunc
 
Func ResizeControls()
;     _GuiCtrlStatusBarResize ($Status1)
 
    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
EndFunc ;==>ResizeControls
 
Func SplitterVert($ctrl1, $ctrl2, $split1,$iop)
    GUICtrlSetState($split1,$gui_hide);!!!
    Local $splitpos1 = ControlGetPos("", "", $split1)
    Local $winpos = WinGetClientSize("")
 
    GUICtrlSetPos($split1,$splitpos1[0],$splitpos1[1],$splitWidth,$splitpos1[3]);!!!
 
    GUICtrlSetPos($ctrl1, $leftMargin, $splitpos1[1], _
            ($splitpos1[0] - $leftMargin), _
            $splitpos1[3])
 
    GUICtrlSetPos($ctrl2, $splitpos1[0] + $splitWidth, _
            $splitpos1[1], _
            $winpos[0] -$rigthMargin- $splitpos1[0] - $splitWidth, _
            $splitpos1[3])
    GUICtrlSetState($split1,$gui_show);!!!
EndFunc ;==>SplitterVert
 
Func SplitterHort($ctrl1, $ctrl2, $ctrl3, $split)
    Local $splitpos = ControlGetPos("", "", $split)
    Local $splitpic1 = ControlGetPos("", "", $pic1);!!!
    $splitpos[3]=$splitWidth
    GUICtrlSetPos($split,$splitpos[0],$splitpos[1],$splitpos[2],$splitWidth);!!!
    GUICtrlSetState($split,$gui_hide);!!!
 
    Local $winpos = WinGetClientSize("")
 
    Local $nh
    $nh = $splitpos[1]-$topMargin;jcd - 9
 
    GUICtrlSetPos($ctrl1, $leftMargin, $topMargin, $splitpic1[0]-$leftMargin,$nh)
    GUICtrlSetPos($ctrl2, $splitpic1[0]+$splitWidth,$topMargin,$winpos[0]-$rigthMargin-($splitpic1[0]+$splitWidth),$nh)
 
    Local $top = $splitpos[1] + $splitWidth
    GUICtrlSetPos($pic1, $splitpic1[0], $splitpic1[1], $splitpic1[2], $nh);!!!
 
    $nh = $winpos[1] - $top - $bottomMargin-$statusBarHeight; move this up above the status bar
 
    GUICtrlSetPos($ctrl3, $leftMargin, _
                              $top, _
                            $winpos[0]-$leftMargin-$rigthMargin, _
                            $nh)
 
    GUICtrlSetState($split,$gui_show);!!!
EndFunc ;==>SplitterHort

 

Всего записей: 148 | Зарегистр. 12-09-2008 | Отправлено: 11:29 25-06-2011 | Исправлено: Leagnus, 11:30 25-06-2011
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 3)
gyra (23-01-2020 10:51): AutoIT (Часть 4)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru