tresa Posted October 22, 2006 Posted October 22, 2006 Nice touch @tresa. Althought it still does not redraw the splitters correctly all the time. Increas the bottom area then decrease it. I thought this would do it, but no I modified again a few things, specially to have a correct resizing when dragging the window edges To do a udf I'm looking for the correct concept to link either the splitters either the divided zones (or both) Tresa expandcollapse popup#include <GUIConstants.au3> #include <GuiStatusbar.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
Uten Posted October 22, 2006 Posted October 22, 2006 Nice Keep it comming, keep it comming .... Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
jvanegmond Posted October 23, 2006 Posted October 23, 2006 (edited) Hurrah! 2^10 posts. Edited October 23, 2006 by Manadar github.com/jvanegmond
CroatianPig Posted August 21, 2013 Posted August 21, 2013 Hi. When I copy any of these scripts in my autoit, it doesn't start at all... Why please? ZOMG just saw, last post in 2006. YES, I know I ask facepalm questions. YES, I know you asked the God why I had to register to the forum where normal people are. YES, I know everything!
Moderators Melba23 Posted August 21, 2013 Moderators Posted August 21, 2013 CroatianPig,Always a good idea to look at the date. If you want to split your GUI, look at the GUIFrames UDF in my sig. But please ask any questions about it in the UDF thread and not here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now