Splitter

toc

Simple splitter
(uses ideas from ResizeHandler) (uses interesting fact: then you click and hold in a graphic box, you will receive events even then dragging outside of it) Simple version. Scroll down for more advanced version by Brandon (nukesrus21) code format="lb" 'vertical splitter work-alike 'tsh73 sept 2010

nomainwin

WindowWidth = 466 WindowHeight = 446

UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)

txt1.h = 200 splitSize=6 txt2.h = 395-splitSize-txt1.h   texteditor #main.txt1, 0, 0, 450, txt1.h    texteditor #main.txt2, 0, txt1.h+ splitSize, 450, txt2.h    graphicbox #main.splitter, 0, txt1.h, 450, splitSize menu #main, "Edit"   '<--- Text-editor Menu can be moved but not removed.

open "splitter work-alike" for window_nf as #main print #main, "trapclose [quit.main]" #main.splitter, "down; fill buttonface; flush" print #main.splitter, "when leftButtonDown [startDrag]" print #main.splitter, "when leftButtonUp [endDrag]"

print #main, "font ms_sans_serif 10"

wait

[startDrag] splitter.y0=MouseY wait

[endDrag] splitter.y = txt1.h+MouseY-splitter.y0   print #main.splitter, "locate 0 "; splitter.y;" 450 ";splitSize txt1.h = splitter.y   txt2.h = 395-splitSize-txt1.h    print #main, "refresh" wait

[quit.main] Close #main END code

Advanced version
by Brandon (nukesrus21) code format="lb" 'vertical splitter work-alike, another version 'tsh73 sept 2010 'Edited by nukesrus21 (Brandon)

NoMainWin

WindowWidth = 746 WindowHeight = 596

UpperLeftX = Int((DisplayWidth - WindowWidth)/ 2) UpperLeftY = Int((DisplayHeight - WindowHeight)/ 2)

txt1.h = 290 splitSize = 8 txt2.h = (550 - splitSize - txt1.h)   txt.w = 740 GraphicBox #main.splitter, 0, txt1.h, txt.w + 1, splitSize TextEditor #main.txt1, 0, 0, txt.w, txt1.h+1 TextEditor #main.txt2, 0, (txt1.h + splitSize - 1), txt.w, txt2.h   'control order and +/- 1 for Y hides GraphicBox black border Menu #main, "Edit"   '<--- Texteditor Menu can be moved but not removed.

Open "Splitter Work-Alike" For window_nf As #main Print #main, "TrapClose [quit.main]" Print #main.splitter, "Down; Fill ButtonFace; Flush Splitter" Print #main.splitter, "When leftButtonDown [startDrag]" Print #main.splitter, "When leftButtonMove [moveDrag]" Print #main.splitter, "When leftButtonUp [endDrag]"

Print #main, "Font MS_SANS_SERIF 10" Print #main.txt1, "Hello" Print #main.txt2, "Splitter World!!" Wait

[startDrag] Print #main.splitter, "DelSegment Splitter; Fill DarkGray; Flush Splitter" splitter.y0 = MouseY Wait

[moveDrag] If ((txt1.h + MouseY - splitter.y0) > 40) And ((txt1.h + MouseY - splitter.y0) < (WindowHeight - 100)) Then splitter.y = (txt1.h + MouseY - splitter.y0) Print #main.splitter, "Locate 0 "; splitter.y; " "; txt.w + 1; " "; splitSize txt1.h = splitter.y       txt2.h = (550 - splitSize - txt1.h)        Print #main, "refresh" End If   Wait

[endDrag] Print #main.splitter, "DelSegment Splitter; Fill ButtonFace; Flush Splitter" Wait

[quit.main] Close #main End code