Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32api.inc"
%IDC_Left = 500
%IDC_Right = 501
%IDC_LabelH = 532
Global hDlg As Dword, M, T, SplitHInWork, HBarLeft, OldProc As Long
Function PBMain()
Dialog New Pixels, 0, "Splitter Text",300,300,410,340, %WS_OverlappedWindow Or %WS_ClipChildren To hDlg
'add the controls + splitter bars (labels)
Control Add TextBox, hDlg, %IDC_Left, "Left", 20, 20, 160, 80
Control Add TextBox, hDlg, %IDC_Right, "Right", 20, 80, 160, 80
Control Add Label, hDlg, %IDC_LabelH, "", 200, 20, 6, 125, %SS_Notify , %WS_Ex_ClientEdge ' up/down - does horizontal split
Dialog Show Modal hDlg Call DlgProc()
End Function
CallBack Function DlgProc() As Long
Local iReturn As Long, x,y,w,h As Long
Select Case Cb.Msg
Case %WM_InitDialog
Dialog Get Client hDlg To w,h
HBarLeft = 150 : T = 6 : M = 6
Control Set Size hDlg, %IDC_LabelH, T, h - 2*M - 10
Control Set Loc hDlg, %IDC_LabelH, HBarLeft, 10
Control Set Color hDlg, %IDC_LabelH, %Black, %Blue
Case %WM_Size
ResizeWindow
Case %WM_SetCursor
iReturn = GetDlgCtrlID (Cb.WParam) 'determine which over which label control mouse was moved
If iReturn = %IDC_LabelH Then MousePtr 9 : Function = 1 '9 = horizontal cursor
Select Case Hi(Word, Cb.LParam)
Case %WM_LButtonDown
If iReturn = %IDC_LabelH Then SplitHInWork = 1 : MoveBarLeftRight
Case %WM_MouseMove
If SplitHInWork Then MoveBarLeftRight
Case %WM_LButtonUp
If SplitHInWork Then
SplitHInWork = 0 'sets flags to say splitter action has ended
MoveBarLeftRight
Control Set Color hDlg, %IDC_LabelH, %Black, %Blue
ResizeWindow
End If
End Select
End Select
End Function
Sub MoveBarLeftRight
Local pt As Point, w,h,BarColor As Long
'get new HBarLeft position
GetCursorPos pt 'pt has xy screen coordinates
ScreenToClient hDlg, pt 'pt now has client coordinates
HBarLeft = pt.x-3
'splitterbar colors - change colors when move is in work
Control Set Color hDlg, %IDC_LabelH, %Black, %Red
'resize splitterbars
Dialog Get Client hDlg To w,h
Control Set Loc hDlg, %IDC_LabelH, HBarLeft, 10
Dialog ReDraw hDlg
End Sub
Sub ResizeWindow
Local w,h As Long
Dialog Get Client hDlg To w,h
Control Set Loc hDlg, %IDC_Left, 5, 10
Control Set Size hDlg, %IDC_Left, HBarLeft - 10, h - 20
Control Set Loc hDlg, %IDC_Right, HBarLeft + 10, 10
Control Set Size hDlg, %IDC_Right, w - HBarLeft - 20, h - 20
End Sub
'gbs_01386
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm